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
-
I love those little language idiosyncrasies.
My favorite is Python dangerous defaults.
Def func(arg=[]):
Return Arg.append(1)
Print(Func())
Print(Func())
This will print [1], then [1, 1] -
Lyniven44543yBasically saying you don't understand shit about what you're doing and you're incompetent
-
it kinda does make sense tho. concatenating as a string makes sense if you're using +, but not if you're using -
the best interpretation for - is subtraction.
it's just a matter of understanding that this is not supposed to happen, cause you'd wanna parse that shit before using it. javascript seems to be doing its best at parsing -
Just don't add numbers to strings to begin with and you'll get along with JS just fine.
Also, true / false = Infinity,
don't @ me -
@Zysce well, that's just how floating point numbers work. in _every_ language.
https://floating-point-gui.de/ learn your basics ;) -
@darksideofyay it makes sense as to *why* it behaves that way.
it doesn't make sense *that* it behaves that way. -
@lungdart what the hell. how?
isn't the argument scoped out and thus destroyed when the function ends, as it should be? why not? -
@localpost "just don't add numbers to strings"
sure, of cou... oh, wait... JS doesn't have a proper type system. what a surprise. -
@Midnight-shcode yeah that's what you would think. But that's not how Python does default arguments, objects, or garbage collection.
At function declaration time a new list object is created, and the default points to that object if no argument is given.
Since append modifies the object, and the object is the same every call, it grows the list.
Cleanup can't happen until the function definition falls out of scope, which is basically never. -
@Midnight-shcode but context is everything, specially when the language is trying to fix a mistake the programmer made
-
@localpost oh yes, TS, everything wrong with JS, EXCEPT with all the two good parts of JS that enable fast work in it, plastered over by a shittily done excuse for a type system.
nothanks. the only thing worse than JS is TS.
Related Rants
it makes total sense
joke/meme
bad design
js