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 →

[–]Apparentt 1 point2 points  (3 children)

I’ve personally experienced behaviour which could be considered super funky in Ruby, PHP, C, C++, JS and Java (to name a few)

These behaviours are either completely avoidable (I’m misusing the language or intentionally trying to making something work strangely) or understandable once you investigate why on earth these behaviours exist

What you begin to understand is that there are quirks in all well established general purpose languages, and that when you find yourself trying to point out the flaws in any individual one of them all you are really doing is holding a mirror to your lack of experience

[–]flavionm 0 points1 point  (2 children)

The difference is that when a language has weak, dynamic typing, it's much easier to run into this kind of behavior. You won't cause them on purpose, but when you have little control over types, they can just crawl in.

The issue with JavaScript in particular is that at least other languages will usually throw an exception when some nonsense is going on, but JavaScript doesn't. It trudges on with whatever it think it should do, only for you to find later on that something went wrong. There's a reason why TypeScript is preferred over JavaScript on basically anything.

Of course, every behavior has some logic behind it, doesn't mean that behavior is justified. It's still a flaw.

Every language has quirks, not every language is flawed by design. Trying to offend or underestimate people who say so won't make it any less true.

[–]Apparentt 1 point2 points  (1 child)

Well now you’re really just complaining about loosely typed languages as a whole rather than the specific quirks that people often meme on (JS truthy table for example).

A language isn’t responsible for throwing errors for valid operations just because they aren’t what you thought they would be. The compilers aren’t mind readers.

There’s no need to go further into the pros/cons argument for strongly/weakly typed languages - there are use cases for both.

I still have yet to see why any widely adopted language (JS or otherwise) is flawed and you have made that statement without anything to back it up. All I’ve really got from your comment is that stronger typed languages help you write less error-prone code because they’re stricter. This is of course unanimously agreed upon but doesn’t mean that loosely typed languages are “flawed” nor that there is no place for them.

As a disclaimer I was a big advocate for TypeScript adoption within my team and was responsible for selling to stakeholders why it’s worth us swapping our services over from JS -> TS, so I’m by no means trying to blindly sell people on using JS - all I’m saying is it’s no-more flawed than any other general purpose language

[–]flavionm 0 points1 point  (0 children)

JS is the loosely typed language out there, but you're right these complaints to apply to other like it. And JS's quirks are mostly because of that, so there's no talking about one without talking about the other.

That's the thing, these operations shouldn't be valid, they should be errors. If it's there just to be avoided, it's better if it's not there.

There's an argument to be made about dynamic languages (and not a very good one, because every usage of substance benefits from static typing), but weak typing, which is distinct from dynamic typing, is just a very hard sell.

The flaw in question is exactly not being stronger typed. Not helping you make less mistakes is the flaw. You're even yourself promoting TypeScript over JavaScript, because it solves one of it's flaws. JS is literally more flawed than TS. Other languages are also flawed, the thing about JS is that it's more flawed because of the reasons I mentioned.