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
-
kamen69886yVanilla JavaScript allows you to do idiotic stuff if you really intend to, yes, but I'd argue that doing math with anything other than numbers and expecting sensible results is even more idiotic.
Good thing that there's Flow, TypeScript and whatnot. -
These are funny lines of JS, but if you're actually writing some of these in your code, WTF.
Which is very different from some nonsense PHP has for over a decade and you can't really run away from, but it's getting better. -
feroza9776y@lucaspar Can you explain some non-sense PHP to me? Since I've doing this for 5 years and haven't seen much myself. Last time I checked PHP doesn't allow you to do any of the weird shit JS does.
-
I don't know what is so idiotic about this. This is how JavaScript works.
All of the above are reasonable once you know how js works. One can't expect a language to work in the way he/she wants it to work.
Yes JS has its quirks but it is blown out of the proportion, because we don't tend to read the hows and whys of it and blame the language.
Classic case of PEBCAK. -
endor57516yBut no, you see, you just haven't read the docs, you just haven't learned how JS works! If you understood how JS works, you'd fully expect this stuff! How dare you criticize JS!
(/s, if that wasn't clear)
Edit: LOL, ninja'd by @ineptCoder by 30 seconds, as if on cue. Can't even make this shit up -
endor57516y@ineptCoder just because that's how things were designed to work in JS, doesn't mean those were sensible design choices.
It's like arguing that bogosort is just as good as quicksort, because it could potentially sort your items in a single iteration, and it will always give you a valid result (eventually).
> One can't expect a language to work the way he/she wants it to work
Yes, you can. It's called consistency and logic. You have to break out of this stockholm syndrome and understand there are better ways to do things.
I'm sure JS has many great features, but this basic inconsistency in handling the base types is just a bug waiting to happen. The fact that you can work your way around it does not make it good. -
Look at these obscure unexpected results that happen when I try to use obscure, unexpected edge syntax!!! Haha fuck JavaScript am I right??? Give me my upvotes!!!
/s
If you hate JS so much, don't use it. No one's forcing you to use it. You only REALLY have to use it is on static frontend web, and if this is what your code looks like you should stick to backend.
Before hating on any lang that behaves unexpectedly in unexpected circumstances, just remember that a lot of hard work went into it and that if you actually sat down and tried to make your own lang, you'd learn very quickly how difficult it is to make it sustainable, grow it over time and increase adoption while balancing an international and cross-platform community. JS has come very far in the last few years, ES6+ is awesome and there's TypeScript if you want strong typing. Perhaps it had to do something _right_ to grow the largest community of any programming language. -
kjdion843086yCoulda just used parseInt on those string numbers.......also PHP automatically casts types and it is awesome at it, but you can strictly declare them if you want. Go back to Java if strongly typed variables are a super huge issue to you. Nobody else gives a fuck.
-
scroach13436yImho the main problem with JavaScript is that it's so easy to make those mistakes. It just doesn't behave like people think it would very often...
And telling people stupid that code such things is stupid too cause nobody would write it that way. People add and subtract variables and expect them to be of a certain type but may be aren't...
Yes there is always a solution but with some languages it's just harder and more brainfucky -
Simply because you are forced to it if you are creating a (interactive) web app. Sure you have transpilers, but in the end it is still JavaScript.
Can't wait until web assembly is a common thing -
Plus accepts strings as the first argument, minus doesn't
Strings are converted to numbers if needed
Extra +- change sign of the number
var x * 3; is probably a syntax error
Just guessing, I don't know JS. -
@woodworks i am with you bro. But not a lot of work was put into its design :P it was made in 10 days!!
-
To be fair, for everything in a language that people see as wrong(like in the image) I see a loooot of things that any sane developer would NEVER do. We don't build strings in JS by using the + sign(we do concatenate regions which is differenr) and in the event of having to deal with numbers we never use strings and let the interpreter fuck around with whatever it needs.
The one thing I would like to now is the situation in which one would:
'Foo' + + 'foo';
I see no situation in which that would happen. Actually, most of these things I see no reason for it to happen. Php and JS(as well as Java) are the languages that I normally defend. I really like all languages and have worked with some that people normally tend to hate like php, vbscript and Visual Basic as well as Delphi.
Sometimes I believe trend plays a big roll whereas with me it is all about the money. Of course I have preferences! Like everyone else of course, but I never let that get in the way of a good paycheck -
@feroza ofc, I will refer this article to you:
https://whydoesitsuck.com/why-does-...
I don't agree with everything on it (like the judgemental title), but it still has very good points. The thing that annoys me more often when coding is the complete lack of naming conventions, a side effect of how the language grew in a spaghetti fashion.
So, while JS is predictable when you learn how things work, PHP is still that spaghetti mess in many points. Some of these have been fixed / minimized with PHP 7 though. -
This actually only matters if you are even too dumb to turn on a computer. 🤔
-
Astatos2666yI can only say: get your types right and stop doing stupid shit.
I mean...
"foo" + + "foo"
What are you even trying to achieve? Trying to cast a string containing only letters into a number and expecting a valid output is stupid. -
for-Each5396yShit like this Infuriates me.
Do stupid shit that has no real world application and then complain about the fucking stupid result.
For the sake of humanity if you're using JS and you're making a comparison use === problem fucking solved.
As for the 2 + "2" = 22, what the actual fuck do you expect to happen when the language operates on a truthy falsey basis.
Swear to god if I see another one of these ima skull fuck a boiled kettle.
Why do people say that PHP sucks and at the same time use Javascript? I call that being a hypocrite.
rant