Hacker News new | ask | show | jobs
by tfar 3446 days ago
That is not a sign of the quality of the language though. It is more a sign of how much money went into making a poor quality language perform well. Compare the speed of JS JIT VMs to Lua JIT VMs considering the investment respectively for example.
2 comments

M$ and Google tried to undermine JS with their own languages (VisualBasic and Dart) but failed. Why such rich companies cannot make a better language?
It's not about language quality, it's about barriers to entry. You not only have to be "better" than JS (which I guess means some combination of performant and pleasing to code), but you have to do so to such a degree that it's worth losing access to/reimplementing the existing libraries, not to mention getting multiple browsers to implement AND getting everyone to install the newer versions of said browsers (not as bad as it was, but still an issue).

I currently do JS for a living, and I don't hate it, but most of the reasons to DO javascript coding have nothing to do with quality of language and instead have to do with how unlikely a viable competitor is to come about anytime soon.

I don't hate JS, but I do find it a bit taxing to write JavaScript that might have bugs due to unexpected behavior in the language. I'm in the process of rounding out my self-taught programming mojo with some intro to CS courses, and the professor started talking about syntactically correct code. He gave the example of something like `3 + "hi"` being syntactically incorrect, saying it wouldn't run (in Python). My first thought on seeing that example was "JavaScript will run that!", and I didn't mean that as a compliment.
Of course, I know that. But companies are rich. They both have their own major browsers. They can just pay to Mozilla and Apple (two remaining major browsers) to support their language(s). Libraries are not a problem for .Net, Go, Swift, Rust.

So why M$ and Google cannot beat poor javascript?

What's money going to do? Unless you're suggesting they bribe millions of developers to switch.

Some things can't be solved by throwing money at them.

All four companies have success with their own programming languages, which is not an easy task to do. Some of them are also succeed with their own OSes too, which is even harder. They CAN replace JS if they push a language strong enough. They cannot do that because replacement languages are worse than JS.
It is a sign of the quality of the language. No amount of money can make a square peg fit into a round hole.

Lua is better optimized because it is smaller. It's been the right decision to keep Lua small given where it specializes. Given where JavaScript specializes it's been the right decision to not keep it small but to evolve it. JavaScript is big because it can be big; it has the resources to make it so.

You're wrong.

> It is a sign of the quality of the language. No amount of money can make a square peg fit into a round hole.

I think this is fundamentally wrong. I think you're confusing the language itself with how the language has been implemented.

Speed is entirely separate from the language. It's possible to write two different JS interpreters: one very fast and one very slow, both of which meet the language standard set by ECMA.

These days JS generally gets JIT compiled and a tremendous amount of work has gone into improving the popular compilers. Lots of tricks are involved. These tricks are quite clever (though sometimes inelegant) and result in significant speedups. But they have nothing to do with the language itself.

Speed is entirely separate from the language. It's possible to write two different JS interpreters: one very fast and one very slow, both of which meet the language standard set by ECMA.

If so, you're basically agreeing with parent, in parent's disagreement with this from further upthread:

JS semantics are garbage... for optimizations

Yeah, in retrospect I responded without thinking.

Of course the semantics of a language can impact how easy/hard it is to write a fast implementation for that language. And as far as I know, there isn't anything special about the ECMA specification that makes it any harder to speed up compared to other languages in the same space (dynamic languages, whose specifications were written with an interpreter approach in mind).

Still, in my mind, speeding up any sufficiently dynamic languages with eval and metaprogramming without straying at all from the language spec is like "fitting a square peg inside a round hole." And I think that has been done successfully with JS, at the cost of making it harder to reason about how the compiler is going to treat my code.

Most code isn't using eval. It's okay if that part is slow. But even the most basic operations in javascript have all sorts of weird hooks that slow down evaluation. Most of it is little to no benefit to the programmer while a huge pain to the implementation.