5 ms·
it seems equality operator in javascript is good for nothing but being a source of confusion and a target of jokes. does it not make sense to just remove it fr
by keymone 8y ago
it seems equality operator in javascript is good for nothing but being a source of confusion and a target of jokes.
does it not make sense to just remove it from the language completely? who is deciding that?
- slikts 8y agoYou can't remove JavaScript features without breaking websites. The one exception was when the strict mode pragma was added, but that was a one-off, and there's too much resistance now to add more pragmas (they tried that with "strong mode"). The best solution currently is to have linter rules enforcing ===.
- Nimelrian 8y ago> it seems equality operator in javascript is good for nothing but being a source of confusion and a target of jokes. if (someValue != null) { // someValue is neither null nor undefined } > does it not make sense to just remove it from the language completely? No, because you'd wreck quite a bit of the internet with that. > who is deciding that? ECMA TC39
- paradite 8y ago> it seems equality operator in javascript is good for nothing but being a source of confusion and a target of jokes. I would say that's the defining characteristics of JavaScript. It makes it fun to write JavaScript with its quirkiness and "dynamic" nature. And once you master it you become a ninja. Compare it to Java or Golang where you are restricted by the language syntax and anything slightly creative and fun is either not supported or not idiomatic.
- keymone 8y ago> It makes it fun to write JavaScript with its quirkiness and "dynamic" nature. nope. none of that. there are plenty of fun, dynamic languages that aren't the horrible pile of shit that is raw javascript. > And once you master it you become a ninja. wait, was this sarcasm? hard to tell..
- simias 8y agoYou'll have to show me one inventive and useful "ninja" trick revolving around the use of '=='. Sounds to me like the classic "my programming language is perfect and if you don't like it you're just too dumb to get it". This is pretty common among C developers in my experience but I didn't expect that from JS enthusiasts. What's next, PHP ninjas?
- paradite 8y ago>You'll have to show me one inventive and useful "ninja" trick revolving around the use of '=='. 1. I was making a generalized statement around JS, not specifically '=='. That's a misinterpretation of my statement. >"my programming language is perfect" 2. I did not say JavaScript is perfect. That's a misinterpretation of my statement. >"if you don't like it you're just too dumb to get it" 3. I did not say "if you don't like you're just too dumb." That's a misinterpretation of my statement.
- thebuzzsaw 8y agoDid you stop to consider that maybe you conveyed these ideas regardless of whether you meant to? JavaScript really _isn't_ all that expressive.
- paradite 8y agoI tried my best, but I can't control how other people interpret it. That's what comments are for after all, to deal with information asymmetry like this. I just don't get it. What's wrong with expressing my love for a language that I love? I am not even asking for anyone to switch to JS, just expressing my feel.
- keymone 8y agowhat's wrong with people disagreeing with you? isn't that what comments are (partly) for?
- 8y ago
- matthewmacleod 8y agoHonestly… The last thing I want in most of my code is "creativity" and "fun".
- paradite 8y agoWell then, your life, your choice.
- matthewmacleod 8y agoSure, until I end up working on someone else’s codebase, and have to clean up the “fun” and “creative” code they thought would be a better idea than “simple,” “idiomatic,” and “explicit”!
- flavio81 8y ago>It makes it fun to write JavaScript with its quirkiness and "dynamic" nature. And once you master it you become a ninja. Yes, a ninja of the "undefined is not a function" wars.
- Sohcahtoa82 8y ago> slightly creative and fun In my experience, code that is "slightly creative and fun" is unreadable and not actually useful for creating working products as a part of a team.
- paradite 8y agoDo you mean you prefer to just follow instructions given by product managers as a robot rather than exercising your creativity and enjoy coding? Or am I reading your statement wrongly? That sounds like a terrible job to have.
- Sohcahtoa82 8y agoI'm interpreting "creative and fun" as either synonymous with "overly clever" (which is hard to read, hard to debug, and hard to maintain [0][1]), or written a non-standard way just for the sake of being different. For example, here's a collection of FizzBuzz solutions[2]. Most of these are incredibly unreadable. [0]https://www.simplethread.com/dont-be-clever/ https://www.simplethread.com/dont-be-clever/ [1]http://www.delabs.io/clever-code-is-bad-code/ http://www.delabs.io/clever-code-is-bad-code/ [2]https://ditam.github.io/posts/fizzbuzz/ https://ditam.github.io/posts/fizzbuzz/
- ghrifter 8y agoT. I don't understand static vs dynamic typing
- simias 8y agoI'm actually surprised that it doesn't give you at least a warning when you "use strict;". That being said plenty of JS linters will yell at you if you use '=='.
- alangpierce 8y ago> does it not make sense to just remove it from the language completely? The way syntax is "removed from the language" in JS is by introducing commonly-used lint rules that disallow them, and that has already happened with `==`: https://eslint.org/docs/rules/eqeqeq https://eslint.org/docs/rules/eqeqeq . As long as the community makes it so a standard project setup has a linter with good defaults, `==` can effectively be removed from JavaScript without having to break nearly every website in existence (which is what would happen if browsers decided to start crashing on `==`).