Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Why? null is completely valid when a variable still doesn't have a value. What do you prefer? 0?
-
@c3r38r170 yes, 0
or better, treat the variable as not initialized and throw a compile time error if you try to use it before you initialize it
the problem is that it's an integer, a type that shouldnt really be on the heap unless you actually want it there, and the boxing just makes things unnecessarily slow -
@LotsOfCaffeine 0 may mean something.
Sometimes you need the variable outside certain scope to be able to access it from somewhere else, but it gets its value at runtime. That's the most common use of =null. -
Yeah, C++ has that issue too. Now they have nullptr to avoid problems with 0 being confused with NULL in code.
-
@c3r38r170 "unless you actually want it there, and the boxing just makes things unnecessarily slow"
that's specifically the case, where you would actually do that. But only when you need it and not all the time and slow down performance -
@Demolishun well that's an old C remnant I believe, since NULL is just a synonym for 0.
-
@Oktokolo I mean undefined is just the weird brother of null
I assume that Dart went this way because besides compiling it, you can also interpret it and transpile to javascript -
p100sch14464yAll values areto be populated with 0 when defined. Null values are pointers with value 0. There you go.
An error for trying to dereference null pointers and voila, no values that are secretly a null value. -
p100sch14464y@LotsOfCaffeine I agree, I should have added that pointers should be seperat values that need to be deliberately created or dereference instead of implied. If you need a pointer you define the parameter as a pointer.
-
Tri value logic makes sense.
It's the representation that leaves a lot to be desired I guess...
Ina programming language I definitely like Optionals more than plain NULL.
Related Rants
-
rostopira23Kotlin: I don't have ternary operator, it's bad for readability Swift: I removed ++ and --, cause they are old...
-
t4ils10>writing app >everything works >commits to gitlab >writes some extra stuff >everything breaks >why.jpeg >head_...
-
d02d33pak16Made my FIRST APP using Flutter. How's it? Fetches 'Random Rants' from devRant. Should I put the code on G...
I hate the fact that this is a valid line of Dart code
int val = null;
rant
dart