5 ms·
Theory: Javascript is bad not because of its syntax but because front-end/back-end is a new way of coding on the web and we have to redesign a lot of things (Js
by inputcoffee 10y ago
Theory: Javascript is bad not because of its syntax but because front-end/back-end is a new way of coding on the web and we have to redesign a lot of things (Json format, API, etc) in order to figure out the best way for it to work.
I am not saying I don't hate the syntax as much as the next person, but syntax is only so annoying.
The real issues come up with, for instance, execution contexts, callbacks etc because they are created for this new environment we find ourselves in.
(For those who say: hey, we have had client-servers for years, and we didn't face these issues, I think we have to start pointing to actual code, the problems, and the attempted solutions.)
- smt88 10y agoI actually like JS syntax. It's pretty bland and, with const/let block scoping + await/async, it's easy to understand. What sucks about JS is its lack of a type system, type coercion, and lack of a standard library. And those things really, really suck (and lead to terrible code). There's a reason MS, Google, and FB have all moved to static-typed JS (TypeScript, TypeScript, and Flow, respectively).
- inputcoffee 10y agoWell, the syntax has this one issue that I just cannot forgive: multiple exceptions to rules. Like why should a beginner have to figure out when the semi-colon is optional, required, and to be avoided? For anyone who says it is easy and then launches into an explanation, please compare your explanation to that in, say, Java and realize the error of your ways.
- maw 10y agoWhen are semicolons to be avoided in JS? I assume daft styleguides pushed by people desperate to show how smart they are don't count. I agree with your broader point, of course; certainly making them optional hasn't helped matters.
- sli 10y agoI don't know of a single instance where it's advised to omit a semicolon, nor one where a semicolon is strictly required. They are always optional. About all I've seen is Standard's guideline to put a semicolon before your entry point closure: ;(function() { // .. snip })() And even that isn't required, it's just a function of another guideline: "Never start a line with (, [, or `." But still, that is only relevant to Standard, not to Javascript in general. It's completely self-enforced by deciding to use Standard if you want. I can't remember ever needing to put one of those characters at the start of a line outside that particular instance, anyway.
- maw 10y agoI think the reason was to work around too simplistic minifiers and concatenators.
- smt88 10y ago> daft styleguides Daft is correct, but some of them are being pushed by large companies and (frustratingly) seem to be somewhat adopted.
- taco_emoji 10y agoMy thesis is that Javascript is bad because it was written in 10 days and got way too popular way too fast for Brendan Eich to have the leeway to fix anything with it.
- inputcoffee 10y agoI am not going to defend JS here. But I will say, take your favorite language (which I assume is either Python, Ruby or Java) and imagine it is running in a browser. It sends a message to the server, and then it has to continue and then interrupt what it is doing when the server responds. How would you handle it? I think you will, very quickly, reproduce the "bad" features of Javascript.
- taco_emoji 10y agoPromises and/or async/await from day 0 would've helped a lot of people not code themselves into "callback hell". But I really think the features that people consider bad have much more to do with the syntax: Lack of block scoping, lack of const, parseInt("072") === 58, eval, existence of the new() operator [0], semicolon insertion, function hoisting, == vs. ===, with statement. [0] causes inexperienced devs to think JS is object-oriented when it is not