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
-
@Lyniven javascript turns + + "a" into NaN (Not a Number) its not string concatenation, it is implicit type conversion (something most languages don't do)
-
Lyniven44533y@ItsNotMyFault but that's also something you won't ever write on your right mind. Just as the legendary memes of saying "gnagnagna but what about !![]?
-
Automatic type conversion in general is just like any other booby trap:
It waits for unsuspecting or unfocused coders to screw up their code in a hard to detect way - always going for the juicy runtime data corruption...
If you design a language, just make the devs write explicit casts when they really want them. Makes everyone's life so much easier and gives the interpreter/compiler a chance to actually detect that sort of bug before corruption happens. -
hjk10156963yFunny joke but not a rant. I don't like JS but bashing it for trowing weak type shit at any dynamic typed language and than complain about the assumptions it made is just stupid. Same issues with PHP, Python, Perl, Bash.
-
C0D4669023y@hjk101 not php it doesn't concat strings by overloading the + operator.
But your point still stands! -
hjk10156963y@C0D4 My point was not about the + operator (Perl also uses the dot for concatenation). But in all these languages you have the same type of shenanigans with weak comparison and implicit coercion. For php there is a famous case of password hash comparison for example: https://darkreading.com/vulnerabili...
-
@hjk101 type conversion in python is always explicit. 'Hello' + 5 throws: TypeError: can only concatenate str (not "int") to str
-
hjk10156963y@ItsNotMyFault yeah sorry python should not be in that list as it is strongly (but dynamically typed)
javascript be like :
"b" + "a" + +"a" + "a"; // -> 'baNaNa'
rant