Hacker News new | ask | show | jobs
by jorgec 3269 days ago
Fine but its dangerous. Javascript/Ecmascript, is a poor designed language, the scope of the variables is broken. Instead, PHP is well defined in this aspect.
3 comments

This seems like an obvious troll comment.

But I'd like to point out that "the scope of the variables is broken" doesn't make any sense: prior to ES6 JavaScript only had function scope -- which is not broken but also not what most people are used to. ES6 added let/const which are block scoped (and thus more familiar). Neither of the two is broken, nor did the addition break anything.

The only oddity I can think of that would provoke such criticism would be a misunderstanding of non-strict-mode JS's behaviour with regard to implicit globals, e.g. what happens outside strict-mode when variables are used without being declared or what the "with" statement does (which is heavily discouraged). But that's like saying PHP is stupid because its array literals look weird.

> obvious troll comment

Honestly, how can you tell? I feel like that's something someone could say if they are under the misunderstanding you (very aptly) describe.

Clue 1: it praises PHP. Even PHP apologists usually restrict themselves to simply defending PHP rather than praising it.

Clue 2: it calls JS "dangerous" and "poor designed" (sic). This is vague but provocative enough to invite emotional responses rather than factual discussion.

Clue 3: it explicitly calls out "the scope of variables" as "broken". Again this is vague enough to be ambiguous but strongly worded enough to seem insulting. This is especially confusing if contrasted with PHP, which isn't exactly known for being intuitive and simple in that regard: http://php.net/manual/en/language.variables.variable.php

But you're right, which is why I said it seems like an obvious troll comment rather than insisting that it can only be that. It might just be a poorly worded expression of frustration stemming from an incomplete understanding. Hence my attempt at a factual response.

Any sufficiently advanced troll is indistinguishable from a real looney.

https://en.wikipedia.org/wiki/Poe%27s_law

The scope of variables isn't "broken", just different. Functional scope is a perfectly valid way to scope variables.

Luckily ES2015 introduced blocked scoped variables (const and let), so this is no longer an issue.

I don't really think anyome ought to be starting flame wars over whether PHP or JS is a poorly designed language. It's like watching Hitler fight Stalin.