Live data from Hacker News

Null References: The Billion Dollar Mistake (2009) [video]

infoq.com

31–40 of 130 posts

Re: Null References: The Billion Dollar Mistake (2009) [video]

#31
post #19

Nah. The billion dollar mistake is actually C arrays decaying to pointers, enabling buffer overflows, the #1 cause of bugs and malware injection in shipped C programs. https://www.digitalmars.com/articles/C-biggest-mistake.html It's simple to fix this in C, too.

Nothing is decaying. It is an implicit conversion. To say something "decays" implies something else is lost, the array is still there.

Something is lost - the array length. "Decays" is the correct word.

Re: Null References: The Billion Dollar Mistake (2009) [video]

#32
Besides the approach taken by some FP languages, others like Eiffel already fixed it in the 1990's, while having nullable types, by making it a compiler error to access reference types without checking for null, unless the types are declared a non nullable.

So it just took some time to get mainstream.

Re: Null References: The Billion Dollar Mistake (2009) [video]

#33

Earlier quoted context omitted.

I think this is actually an artifact of the 'check the single return value for errors' that requires that the return domain contain at least one error code point. how else you might structure errors without changing much of the rest of C left for an exercise

just require the programmer to check errno after every function call? /s

omg. I forgot about that. the one thing even worse than overloading the return domain.

Re: Null References: The Billion Dollar Mistake (2009) [video]

#34
post #17
post #9

Earlier quoted context omitted.

I think golang's slices are a better solution than the linked article. https://go.dev/ref/spec#Slice_types Slices can still be nil (null), but it isn't an unsafe memory access operation, just another type of potentially useful or potentially errant invocation to handle.

Zig and Rust also support array slices. But they can’t be null, because that’s - as the article says - a mistake. https://ziglang.org/documentation/master/#Slices https://doc.rust-lang.org/book/ch04-03-slices.html

Other languages avoid the mistake by preventing direct access unless either there is a null check or they are declared as non nullable.

Re: Null References: The Billion Dollar Mistake (2009) [video]

#35
post #26
post #5

Earlier quoted context omitted.

Which would all be a rounding area if C gets to take credit for everything produced using it.

This is what C/C++ haters, anti x86/amd64 snobs, and Rust elitists always forget: what works, works. Sure, it could be a local maximum, hopefully there will be better, but who knows? To quote Sean Connery in The Rock: Losers always whine about their best. Winners go home and fuck the prom queen! https://m.youtube.com/watch?v=gXDSxgDUv-c

Some of us are old enough to be coding when C was only relevant for university departments privileged to have UNIX boxes.

So we know there are other ways, we used systems with zero lines of C into them.

The prom queen came naked offering herself to everyone and the party was done for the other folks.

Re: Null References: The Billion Dollar Mistake (2009) [video]

#36
post #25

The compiler should check for null reference before deferencing here.

At the cost of basically all performance or incredible compiler complexity. A better solution: Implement a different language with a better type system instead. Or pick one of the hundreds that already exist and can represent the concept of a tagged union without having to implement it manually.

As proven by languages like Eiffel or Kotlin, it is quite alright.

Re: Null References: The Billion Dollar Mistake (2009) [video]

#38
post #35
post #26

Earlier quoted context omitted.

This is what C/C++ haters, anti x86/amd64 snobs, and Rust elitists always forget: what works, works. Sure, it could be a local maximum, hopefully there will be better, but who knows? To quote Sean Connery in The Rock: Losers always whine about their best. Winners go home and fuck the prom queen! https://m.youtube.com/watch?v=gXDSxgDUv-c

Some of us are old enough to be coding when C was only relevant for university departments privileged to have UNIX boxes. So we know there are other ways, we used systems with zero lines of C into them. The prom queen came naked offering herself to everyone and the party was done for the other folks.

That excuse sounds like the guy in highschool who would have treated the girl so much better, but she was into assholes.

If you are old enough to remember those days, then you remember COBOL, Algol, Fortran, Pascal, BASIC, Ada, Oberon, Lisp/Scheme, Forth, O’Caml etc. They’re all great languages, some still have their uses. There’s a reason all of the major operating systems have cores written in C/C++. It’s entirely because they’re pragmatic and “work”, and not some conspiracy.

Edit: although now that I write it, what if C/C++ was planted on earth by an alien intelligence in order to slow down the development of the human race.

Re: Null References: The Billion Dollar Mistake (2009) [video]

#39

Earlier quoted context omitted.

I think this is actually an artifact of the 'check the single return value for errors' that requires that the return domain contain at least one error code point. how else you might structure errors without changing much of the rest of C left for an exercise

just require the programmer to check errno after every function call? /s

Strange but true you can create functions where you pass a pointer to an error variable.

  error_t oops;
  int x = foo(10, &oops);
  if(oops)
    goto whoops;

  int x = foo(10, 0);  // yolo!

Re: Null References: The Billion Dollar Mistake (2009) [video]

#40
post #26
post #5

Earlier quoted context omitted.

Which would all be a rounding area if C gets to take credit for everything produced using it.

This is what C/C++ haters, anti x86/amd64 snobs, and Rust elitists always forget: what works, works. Sure, it could be a local maximum, hopefully there will be better, but who knows? To quote Sean Connery in The Rock: Losers always whine about their best. Winners go home and fuck the prom queen! https://m.youtube.com/watch?v=gXDSxgDUv-c

It doesn't even have to be a local maximum, just higher up some hillside will do (maybe it's even on a different hillside to the one you're on at the moment).
Post reply on HN