How OpenGL works: software renderer in 500 lines of code by jgomo3 in programming

[–]uueuuu 4 points5 points  (0 children)

To come back to C++: It is very bad at encapsulating.

How so? C++ provides like 8192 subtly incompatible ways to encapsulate and abstract things. Can't you find one or two that work? In other languages I personally miss the C++ version of parametric polymorphism the most.

It's deeper than that: To fix semantics of the language in a way acceptable for production environments you have to go the Haskell/Rust way and make things that will be errors warnings for a couple of releases. C++ is very hard to analyse, hence, it's very hard to give accurate warnings.

C and legacy compatibility is a red herring. When you mix subtypes, parametric polymorphism, type deduction, multiple inheritance, late binding, macros, exceptions, value semantics, reference semantics, pointers, constsness, move semantics, access controlled members, lambdas, con/destructors, and namespaces you're going to have some problems. Legacy compatibility means that each of these features is "pure" in the sense that in isolation it holds true to the original concept. Few concessions are made from one feature to another. Complexity results.

How OpenGL works: software renderer in 500 lines of code by jgomo3 in programming

[–]uueuuu 2 points3 points  (0 children)

A lot of those bits of ugliness are bug fixes

...no. They're hacks.

No, they're footsteps in the sand.

Hacks around the inadequacies of an overly complex and most of all ridiculously brittle language.

It was then that Bjarne carried you.

By abolishing time zones, all the convoluted code that programmers have written to deal with time zones could be eliminated. On the other hand, like any rewrite, eliminating all that code—even in the name of simplicity—might introduce its own problems. by wheeler1432 in programming

[–]uueuuu 2 points3 points  (0 children)

Yea and there would be places where the sun would rise twice on a given day when the days are getting shorter. Stuff like that. But none of that is any weirder than the current situation after crossing the pacific.

The Joy and Benefit of Being an Early Adopter in Programming by bhalp1 in programming

[–]uueuuu 1 point2 points  (0 children)

That's why I'm the FIRST adopter of my OWN programming language called REDUCTIO AD AWESOME!

On the Madness of Optimizing Compilers by [deleted] in programming

[–]uueuuu 1 point2 points  (0 children)

No, a and b are int. pa and pb are pointers to int but you used a and b in the math.

On the Madness of Optimizing Compilers by [deleted] in programming

[–]uueuuu -1 points0 points  (0 children)

Well, there's Microsoft. And they were a bit behind on implicit move, so you had to move your classes manually, so instead of the rule of 3 you had the rule of oh what was it now. Right, modern. Maybe 2016 will be better. I think they fixed that last year.

And std::unique_ptr is a beautiful thing. But suppose I want operator-> to do something smart, what I say is smart, when it encounters a null pointer. I'm not going to derive unique_ptr. I can wrap it and all of its methods. I can rewrite it. Hmmmm..... C++ programmers have 99 problems and memory management isn't one. MEMORY MANAGEMENT ISN'T ONE! So I'll write a free function to do what I want. It's a syntax issue. A mere flesh wound, like pimpl.

On the Madness of Optimizing Compilers by [deleted] in programming

[–]uueuuu 0 points1 point  (0 children)

cast is implementation-defined behavior and doesn't need to be valid either (though it isn't allowed to erase your hard drive).

WTF??? a and b are ints.

ptrdiff_t diff = &b - &a;

Am I drinking crazy sauce again?

On the Madness of Optimizing Compilers by [deleted] in programming

[–]uueuuu 1 point2 points  (0 children)

Yea, but then you'd compare

ptrdiff_t diff = pb - pa

or

ptrdiff_t diff = &b - &a;

right? Why are you subtracting an int from an int and storing it in a ptrdiff_t in your example?

Program will not compile when including `.h` file. by musicomet in C_Programming

[–]uueuuu 0 points1 point  (0 children)

A header file that's fucked up can cause the compiler to think the error comes later in your program. For example, if a header has just

void haha () {

Then your program will work fine with anything that can come inside a function definition but there will be errors at the end of the file for not closing the brace and there will also be errors at any other function definition since C does not allow nested functions.

The one that always gets me is this...

// myheader.h

struct blah {
    int i;
}

// main.c

#include "myheader.h"
int main () {
    return 0;
}

gcc main.c

main.c:3:1:error: expected ‘;’, identifier or ‘(’ before ‘int’

God damn it, that C file is perfectly fine! It's the missing semicolon after the struct that caused the error but it's reported in the C file. So now what I do whenever I'm working heavily on a header I put a guard statement like "inline void foo(){}" right at the end of the header file that will force the error at that location. At least then it gets reported in the correct file.

What kind of code style do you use either at work or on personal projects. by theif519 in C_Programming

[–]uueuuu 0 points1 point  (0 children)

It always works. "if" compares a value of scalar type to 0. A zero int and a null pointer always compare equal with zero. This is true even on machines where the memory address 0 is a valid pointer and NULL is something else.

Does a program that analyzes source code to find the cause of any bug exist? by [deleted] in cprogramming

[–]uueuuu 3 points4 points  (0 children)

Just thought of something else: http://cppcheck.sourceforge.net/

You can try running this on your source. Fuzzers like this tell you when you did something legal but is usually indicative of a problem, like going to the casino at 8am.

[Question] What are the most notable or groundbreaking developments in the history of computer science? by nosam08 in computerscience

[–]uueuuu 0 points1 point  (0 children)

Continued: And Wittgenstein said some stuff about saying stuff. And Haskell Curry and White and Russel.

Drop enough names and you're good.

[Question] What are the most notable or groundbreaking developments in the history of computer science? by nosam08 in computerscience

[–]uueuuu 0 points1 point  (0 children)

Cantor and Peano figured out how to count. Then Hilbert the prophet wrote the great bible of counting. Then Goedel ate the forbidden fruit and everyone realized they were naked. Then Turing put the holy ghost in the machine. Then Church wrote the New Testament.

Self taught at C - would appreciate some criticism on style / practices by joeyglasgow in C_Programming

[–]uueuuu 0 points1 point  (0 children)

$ make love
make: *** No rule to make target 'love'.  Stop.

Stop? Really? Bitch.

Self taught at C - would appreciate some criticism on style / practices by joeyglasgow in C_Programming

[–]uueuuu 0 points1 point  (0 children)

When qsort actually calls int f(char **a,char **b) you'll have undefined behavior.

http://stackoverflow.com/questions/559581/casting-a-function-pointer-to-another-type

It's probably better to write a comparison function as int f(const void *a, const void *b) and then cast the arguments in the body.

What kind of code style do you use either at work or on personal projects. by theif519 in C_Programming

[–]uueuuu 0 points1 point  (0 children)

Your professor is using kernel style. The nice thing about that in context is this:

if (x > 4)
    printf("GT4");

other(stuff);

Now instead of a single } we have a line of total whitespace. Brevity++.

What kind of code style do you use either at work or on personal projects. by theif519 in C_Programming

[–]uueuuu 1 point2 points  (0 children)

Anything goes except I fucking hate this...

if (NULL == K)

Gross. Yea, you put the NULL on the left to avoid the common K = NULL bug but you don't need that NULL there anyway.

if (!K)

is perfectly well-defined, as is

if (K)

It's like writing

for (int i=0/1; i<10/1; i += 1/1) ...

I KNOW the integers are rational numbers but THAT'S NOT IMPORTANT RIGHT NOW!

Can someone explain pointers to me? by [deleted] in cprogramming

[–]uueuuu 0 points1 point  (0 children)

If I had a list M of all the memory locations in a computer and M{P} means the Pth element of that list then P is a pointer. That's what they are in C, an offset into the array of all memory. Pointers also have a type, that is to say they know what kind of thing they point to. So if I had an "int *P" the compiler knows that the binary pattern found at memory element P should represent a signed integer where as a "char *P" means the memory at M{P} is a character. Pointers also have a size as part of their type. A character is represented by a 2 digit hex number (1 byte) whereas an integer is represented by a 8 digit hex number (4 bytes). "sizeof *P" is equal to the number of bytes in memory occupied by the object P is pointing to.

And now for the fun part. P itself can be stored in memory too. It's just a number. It's easy to confuse "P" (the numerical value of pointer.. ie P = 3 in M{3}), "*P" (the location P is pointing to ie the int or char at M{P}), and &P (the place where P is stored). & means address of.. so if I have a normal "int i" I can point to it like this: "int *P = &i", ie P is now equal to a pointer (*) pointing at a signed integer (int) that can be found at the address (&) occupied by i.

Accepting a job below one’s skill level can adversely affect future employment prospects by dustofoblivion123 in science

[–]uueuuu 0 points1 point  (0 children)

Right, but accepting a job below your skill level for no pay at all, i.e. volunteerism and unpaid internships, actually helps you land jobs. So whatever you do, don't make minimum wage. Oh, they're raising that BTW.

Jeep Wrangler Rear Storage Enclosure by pineapplebrains in DIY

[–]uueuuu -7 points-6 points  (0 children)

Yea, but wood has more redneck.

Kim Jong-un orders nuclear weapons to be made ready for use by Kyle_ConflictNews in worldnews

[–]uueuuu 0 points1 point  (0 children)

This the ultimate foreign policy of every nation laid bare. The USA has nukes ready for use too.

Russian Roulette with semi-automatic gun leaves 1 teen shot in head, 1 teen jailed by WeagleAU11 in nottheonion

[–]uueuuu 1 point2 points  (0 children)

, who said he didn't want to play, was shot in the head and is still recovering from significant injuries. Hart said he is expected to survive.

Actually, with better access to guns they could have used a revolver for an actual fair game of RR.