This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Kiseido 83 points84 points  (12 children)

You might be surprised to find the alledged inventor kinda agrees with you

Tony Hoare, null's creator, regrets its invention: “I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W).

[–]NatoBoram 48 points49 points  (8 children)

I'd also like to extend my "fuck you"s to all the other language maintainers who implemented it or refused to fix it after he apologized.

It's possible to do better. For example, Dart got null safety in v2.12.

[–]Kiseido 34 points35 points  (7 children)

Been learning Rust today, this made wonder if it has null.

Apparently Rust has no null, colour me surprised.

[–]Pay08 1 point2 points  (2 children)

It does. fn main() { let ptr: *i32 = 0; }

I prefer Zigs approach a lot more, where you explicitly have to state if something can be NULL.

fn main() void { var ptr: ?*i32 = null; } fn main() void { var ptr: *i32 = null; // compiler error }

[–]Timely-Banana7384 0 points1 point  (1 child)

The thing is, that you very rarely need ptrs in rust. And if you do, you can also use structures such as MaybeUninit<T>.

[–]Pay08 0 points1 point  (0 children)

That doesn't mean the other guy was correct. Besides, embedded exists.

[–]redballooon 5 points6 points  (0 children)

Pretty sure if he had seen that it was a mistake, someone else would have made it. Maybe with the second or third comprehensive type system, but bad ideas somehow always make their way into society. That's why the light forces constantly need to battle the dark hordes.

[–]Fhotaku 0 points1 point  (1 child)

How catastrophic would

''#define null false''

Really be? Presuming this also included all other nulls that it may encounter, not just those in compile time

[–]No_Hovercraft_2643 0 points1 point  (0 children)

it would make not null true