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

Because "JS is the common language of the web" doesn't capture what the analogy is saying.

The key aspect of the analogy is that you have compilers emit or JIT to JS, rather than writing if yourself, and then have languages/DSLs that users write to, rather than JS.




You can do that with almost any language. The analogy holds in that you can't get underneath JS in a browser but if you were to design a browser language with this kind of usage in mind it seems you'd want something that was a lot easier to optimize than JS. JS clearly was a language that was designed to be written directly.


The analogy holds in that you can't get underneath JS in a browser

Yes. That's why JS is the target (and its ubiquity).

but if you were to design a browser language with this kind of usage in mind it seems you'd want something that was a lot easier to optimize than JS

JS isn't turning out to be too bad to optimize. Post-lower optimization already occurs in the browser. The part the compiler would do is optimization prior to emission to JS.


Knowing the ins and outs of the DOM API implementations can get a bit arcane but optimizing JS is mostly about work avoidance and making sure you know how to make the native-code-implemented methods work for you to avoid putting extra work on the JIT/interpreters. You have to maintain a knowledge-base to be strong at it, but it can be very rewarding to see how much more you can get out of your code with a little bit of thought and study. The analogy also holds in that JS is extremely flexible and denies you very little. You can design and code to most any paradigm you want although I suspect attempting to implement static typing would get a little silly where numbers are concerned.


You can do that with almost any language

What other language runs in all browsers?


None, I'm just saying that nothing in Javascript other than its ubiquity makes it particularly suitable for this.


Shouldn't Flash be the choice then? There are languages compiled to Flash file, such as Flex or ActionScript.


There's a reason why Flash has mostly been relegated to video, audio, and games, and it's not because Flash integrates so seemlessly smooth with websites. Javascript is in the bones of the web, Flash is just a layer on top.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: