3 ms·
This article has no substance. He complains about how Javascript is "messy to code with", but that's subjective and he provides no context. What does he mean by
by actsasbuffoon 14y ago
This article has no substance. He complains about how Javascript is "messy to code with", but that's subjective and he provides no context. What does he mean by messy? What features would make it less messy?
He also complains that it lacks modern features. JS has support for anonymous functions, closures, higher order functions, some very advanced meta programming, and loads of other modern features. In fact, it supports a lot of the stuff that makes Ruby feel very modern to me. I'd like some specifics. What features is it missing?
He also implies that test driven development with Javascript is a hassle, then admits that he's never actually tried it before. It was so absurd that I wondered if he was making some kind of very dry joke.
Don't get me wrong, I don't love Javascript and I agree with his closing statement. I would love to see browsers begin to switch over to bytecode interpreters, thus allowing developers to write in any language. Unfortunately we'll probably colonize Mars before JS is displaced from browsers.
Take a look at this list of languages that compile to JS: https://github.com/jashkenas/coffee-script/wiki/List-of-languages-that-compile-to-JS https://github.com/jashkenas/coffee-script/wiki/List-of-lang...
There are tons. I haven't counted, but it looks like there are in excess of a hundred languages there. That suggests that a lot of people really feel the need to replace Javascript. I can't say that I blame them.
Variables are global by default. Think about that for a minute. What deranged fiend decided that variables should be global unless prefixed with a keyword? This is one of the weirdest and most unforgivable things I have witnessed in any language, and I'm embarrassed to admit that I briefly programmed COBOL professionally (I was young and I needed the money).
The fact that == has implicit type coercion is a huge pain. I know === resolves that, but it's a hassle to try to remember that when I'm programming in 2 or 3 languages at once. I can only think of one other major language that does automatic coercion on equality checks, which is PHP. Say what you will about the pros and cons of PHP, but I think most people would agree that you shouldn't look to it for advice on language design.
While the prototype based inheritance system offers some nifty meta programming opportunities, it makes it really hard to debug. Things don't have classes, they just have prototypes. Virtually everything in JS comes out as [object Object]. That's a really handy message when I'm trying to debug a thorny issue!
While I appreciate the elegance of making object constructors from regular functions, that makes it possible to run a constructor without putting "new" in front of it. That runs the code from the constructor, but "this" refers to window instead of your new instance. In "Javascript: The Good Parts", Douglas Crockford recommends writing some boilerplate at the top of every constructor to catch this and recall the constructor with new in front of it. That's a clever hack, but I not a fan writing boilerplate at the top of every constructor.
Don't even get me started on how callbacks mess with the value of "this". There are some nifty meta programming tricks I can accomplish with that, but 99.9% of the time I want "this" to refer to the object I'm in!
Speaking of which, "apply" is pretty nifty (I love T combinators), but I hate that I can't use it on constructors. The hoops I have to jump through to convert an array into arguments for a variadic constructor in JS are absurd.
There, rant over.
This is what I consider substance. Please list specific grievances and make suggestions when possible. Vague statements about messiness and modernity tell me nothing. In fact, they sound like FUD which is just going to agitate me.