Hacker News new | past | comments | ask | show | jobs | submit login

Javascript is off-handedly derided because it's got so many basic things wrong that never got fixed. If they'd have iterated fast with it by now it would be fine, but it's stuck in the glacial committees. And personally I think they needed to abandon prototypical behaviour which is just confusing and too verbose.

The object declaration is painful, it has variable hoisting and doesn't have proper block scope leading to all sorts of weird bugs, it doesn't have simple namespacing, it didn't have a foreach, it didn't have get/setters until recently and even now the syntax is bad because they wanted to maintain backward compatibility.

Oh and everything's a bloody function. A function is a function. A class is a function. An anonymous method is a function. It can get really hard to read and pick out what a bit of code is actually doing on first pass.

And that's just the big, really simple but important, every day stuff that a normal coder needs to do their job in even the slightest complexity scenario.

I sometimes wonder if the 'other' language that netscape was going to use was really as frustrating as javascript is when you start working on more complex code.

What it did have which most languages didn't have is treating functions as first-class objects and closures. They're brilliant.

Unfortunately almost all other modern languages now have these and javascript still doesn't have all the other goodies so that's one of the many reasons it gets so much hate.

So now compared to any other language it looks so dated and archaic.

I really enjoy writing javascript at times, but as the code gets complex I despise it. And I hate coming back to my old javascript code.




I find some of these thoughts to be be a bit off in their basic premise. For example, "A function is a function. A class is a function. An anonymous method is a function."

Well There are no classes in javascript at all. A constructor is a function in most OO languages. The difference here is the underlying OO implementation.

Anonymous methods are by nature functions as well. Could there be a more succinct syntax for them? Perhaps, but of all of the complaints about javascript this is a relatively minor one.

I would never say that there are not things about JS that don't drive me nuts. But the relatively simplicity of thinking of just about everything being treated equally from a language standpoint gives you a flexibility to work that can be really refreshing.


The relative simplicity is what I mean about really enjoying writing javascript.

The everything is a function is because at least in other languages it's clear what a constructor is, what a function is and what an anonymous method is. They all look distinctly different and have different keywords or declaration syntax. Generally speaking something like:

    class Thing
        Thing() { } //constructor

    function Thing() {} //function

    (p) => {} //anonymous method
Visually they are very different. In javascript they all look pretty much the same and have exactly the same syntax.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: