Live data from Hacker News

JavaScript is Dead. Long Live JavaScript

peter.michaux.ca

1–10 of 69 posts

Re: JavaScript is Dead. Long Live JavaScript

#2
Great and thorough article. Here's a TLDR:

* Javascript has some warts, and here are some examples.

* It's going to take way too long to get these fixed to the point that we can actually start using new versions of Javascript because of slow browser adoption.

* To get around this problem, people are treating Javascript as a compilation target for other languages, the most prominent example being CoffeeScript.

* Discussion follows of features that would make Javascript better serve its increasing role as a compilation target.

* There is discussion of Harmony throughout.

Sometimes offering a TLDR indicates that the article isn't worth reading "so here are the author's points so you can skip it". That's not the case here. For example, I learned about "Tennet's Correspondence Principle", which helps to give a name to the different ways procs/blocks and methods/lambdas behave in Ruby, as explained in this article[1].

[1] http://www.robertsosinski.com/2008/12/21/understanding-ruby-...

Re: JavaScript is Dead. Long Live JavaScript

#4
He calls inheritance in Javascript a wart. It's one of its major strengths, IMO: the fact that you can directly override methods for a single object. Class inheritance, as he'd like to see, is not all it's cracked up to be. Just look at Java with its anonymous inner classes, for one incredibly ugly construct...

BTW an easy way to produce traditional class inheritance in Javascript is to have a single instance from the class you're trying to inherit from, as the prototype. (To work properly that object should be "abstract": have no ties to any physical resources, like a browser widget, a database handle or a file handle.)

Re: JavaScript is Dead. Long Live JavaScript

#6
> If your application uses the let idiom, wouldn’t it be nice to have new syntax for it?

Mozilla introduced this back in Firefox 2, and you can replace var with it, so TFAA's

    for (var i=0, ilen=elements.length; i
becomes:

    for (let i=0, ilen=elements.length; i
Of course, since this does not quite seem to be a tight loop you should be using Array.prototype.forEach instead:

    elements.forEach(function (element, i) {
        LIB_addEventListener(element, function(event) {
            alert('I was originally number ' + i);
        });
    });
> The JavaScript idiom that potentially spans the most lines of your program may be the inheritance idiom.

That's not an idiom. And there are numerous implementations of classes on top of prototypes out there, if there's one javascript "problem" which does not need new syntax it's that one.

Re: JavaScript is Dead. Long Live JavaScript

#8
post #4

He calls inheritance in Javascript a wart. It's one of its major strengths, IMO: the fact that you can directly override methods for a single object. Class inheritance, as he'd like to see, is not all it's cracked up to be. Just look at Java with its anonymous inner classes, for one incredibly ugly construct... BTW an easy way to produce traditional class inheritance in Javascript is to have a single instance from th…

> Class inheritance, as he'd like to see, is not all it's cracked up to be. Just look at Java with its anonymous inner classes, for one incredibly ugly construct...

I'm not sure why you're implying java's anonymous inner classes have much relation with class inheritance.

The vast majority of class-based languages do not have (or need) anonymous inner classes (though some languages allow for creating unnamed classes on the fly by instantiating metaclasses).

Re: JavaScript is Dead. Long Live JavaScript

#9
post #2

Great and thorough article. Here's a TLDR: * Javascript has some warts, and here are some examples. * It's going to take way too long to get these fixed to the point that we can actually start using new versions of Javascript because of slow browser adoption. * To get around this problem, people are treating Javascript as a compilation target for other languages, the most prominent example being CoffeeScript. * Discu…

"It's going to take way too long to get these fixed to the point that we can actually start using new versions of Javascript because of slow browser adoption."

Which isn't true, because you could compile newer versions of javascript to older versions. I see languages like coffeescript as interesting experiments in how the language can evolve, but eventually it needs to come back home to javascript and get deployed natively in browsers.

Post reply on HN