9 ms·
And yet JS is faster than most other dynamic languages. Pretty good garbage if you ask me.
by Touche 10y ago
And yet JS is faster than most other dynamic languages. Pretty good garbage if you ask me.
- tfar 10y agoThat 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.
- Touche 10y agoIt 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.
- tps5 10y ago> 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.
- jessaustin 10y agoSpeed 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
- tps5 10y agoYeah, 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.
- Dylan16807 10y agoMost 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.
- lisivka 10y agoM$ and Google tried to undermine JS with their own languages (VisualBasic and Dart) but failed. Why such rich companies cannot make a better language?
- ergothus 10y agoIt'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.
- lisivka 10y agoOf 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?
- Dylan16807 10y agoWhat'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.
- lisivka 10y agoAll 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.
- rubber_duck 10y ago>And yet JS is faster than most other dynamic languages Those languages chose slower semantics to give better programming experience - it's a design trade-off - JS has the worst of both worlds.
- Touche 10y agoNot according to the millions of people who use and like JavaScript.
- rubber_duck 10y agoThe quality of JS ecosystem speaks for itself.
- untog 10y agoThe breadth of the JS ecosystem speaks for itself, too.
- rubber_duck 10y agoAbsolutely - multiple halfassed re-implementations of the same thing found in most languages std lib is a huge reason why the language is bad (remember the left pad fiasco ?), but the semantics of the language make it fundamentally flawed without breaking backcompat. JS ecosystem is actually quite bad when it comes to functionality - but they do have 10 versions of same thing for stuff they do have and each of those works only in specific scenario it was written in but nobody bothers to extend it and writes their own instead when they need to solve something similar because reading other's people JS is a nightmare. If anything the kind of breadth JS ecosystem has shows just how hard to maintain other people code is.
- rpedela 10y agoWhat a gross over-generalization. Yes there are crap libraries just like any popular language. There are also great libraries just like any popular language. If there are multiple for the same purpose, it is usually obvious which is the best one. Since you brought up the left pad thing, yes there is a small minority within the JS community that takes the Unix philosophy of "only do one thing and do it well" to an absolute extreme. But that isn't indicative of the JS ecosystem as a whole.
- tomatsu 10y agoDart is just as fast, but getting there was significantly less work. Dart's semantics are more straightforward and the language was create with performance in mind. The amount of work that went into today's JS engines is just insane.
- deleted 10y ago[deleted]
- shakna 10y agoYet slower than many Scheme implementations, such as picrin, slower than Lua's most famous JIT, Dart is faster than Node... Which dynamic languages are slower than Node? (Other than Python which is incredibly slow) How is it 'most'? I'm not looking for a language war. I'm a polyglot who will always gladly use the right tool for the right job. But Node has a ways to go before being one of the fastest JITs around. Ion, jsc, and v8 are in similar boats.
- reissbaker 10y agoGrabbing a few of the popular dynamic languages from the TIOBE index: Perl, PHP, and Ruby are also generally slower than JS. FWIW, neither Scheme nor Lua appear in the top 20 of the index, and of the dynamic languages in the top 10 — JS, Python, Perl, and PHP — JS is the fastest. I think "most" is a fair description, even though dynamic languages that have faster implementations than JS do exist.