5 ms·
I see this all the time. JS is slow because of the dom. No. JS is slow because JS is slow. Yes, I know V8 makes it faster than it used to be. Yes I know it is n
by drakaal 13y ago
I see this all the time. JS is slow because of the dom. No. JS is slow because JS is slow. Yes, I know V8 makes it faster than it used to be. Yes I know it is neck and neck for computation, but because of the way memory is handled it is slow for loading large dictionaries.
But I could forgive all of that.
JavaScript is not well designed for work in a team environment, nor is it well designed for Large Code Bases.
But I could forgive all of that.
All the best languages have a group of scientists that have chosen that language to be their defacto language. That is why we see Python, LISP, Fortran (yes still), MatLab, all living on long beyond the "trendy" languages.
JS only picked up steam because Flash died. Not because it was a great language. If it were a great language people would have started optimizing it 5 years ago. It isn't. So they didn't. The new optimizations are out of necessity. And because it lets front end pretend to be backend. That may sound snobby, and it is, but JS for backend is like writing in Visual Basic. These days you can do anything in it, it will be fast, but that doesn't make it the right choice.
- pmelendez 13y ago>"JS is slow." In comparison to what? JS is one of the faster script languages out there. V8 is way faster that Ruby and outperform python a lot of time as well. It's regex is blast fast as well.
- Mikeb85 13y agoIt outperforms Python at everything except where Python just calls a C function. Ruby (especially the recent releases) is on par with Python speed, if not faster. But neither is close to JS.
- oscargrouch 13y ago"My pet is fast because it can beat a turtle and a slug in a race"
- Mikeb85 13y agoLol. Seriously though, show me a dynamic language (other than Lisp) that's even half as fast as Javascript...
- oscargrouch 13y agoWithout Python, Ruby, Javascript and Lisp, we are sort of running out of dinamic languages options.. But the funny thing is the one that got left out, is the one that is faster than Javascript: Lua
- pmelendez 13y agoIs it really faster than Javascript though? http://benchmarksgame.alioth.debian.org/u32/benchmark.php?test=all&lang=v8&lang2=lua&data=u32 http://benchmarksgame.alioth.debian.org/u32/benchmark.php?te...
- oscargrouch 13y agoThis is for the lua interpreter. aka the PUC-Lua You should compare it to Luajit, wich is a proper JIT compiler as V8.. The benchmark game used to have Luajit, but they take it out for no reason.. You can download the scripts and run in you local machine against V8, using Luajit for real comparison.. http://luajit.org/ http://luajit.org/ Also this link compare a lot of language implementations in different benchmarks than the ones in shootout http://attractivechaos.github.io/plb/ http://attractivechaos.github.io/plb/ edit: also see this blog post about benchmarks; if i am not mistaken, this guy is behind V8 and Dart VM's implementations http://mrale.ph/blog/2011/05/12/dangers-of-cross-language-benchmark-games.html http://mrale.ph/blog/2011/05/12/dangers-of-cross-language-be...
- kalms 13y agoSome would argue that Flash's death was hastened by JavaScript, not the other way around. (And Steve, and..)
- mattmanser 13y agoThey did start 5 years ago. You obviously weren't around for IE6. Man that js engine was sloooowwwwwwwwwwwww. Like several orders of magnitude compared to modern ones.
- eknkc 13y agoWho says "JS is slow"? It might even be the single most heavily optimized scripting language ever. Given that Apple, Google, Microsoft and Mozilla work on high performance JS VMs (half of them open source) and in a public competition with benchmarks and claims for fastest browsing experience. Performance was one of the selling points of Node.JS for me.
- Mikeb85 13y ago> JS is slow because JS is slow. JS is the fastest dynamic language next to SBCL's Common Lisp implementation. > JavaScript is not well designed for work in a team environment, nor is it well designed for Large Code Bases. Why is this a problem? Most web problems don't need a large code base. A small, dynamic language is suited to web problems. And judging by the amount of things being built with Javascript, enough people have figured out its quirks. > All the best languages have a group of scientists that have chosen that language to be their defacto language. That is why we see Python, LISP, Fortran (yes still), MatLab, all living on long beyond the "trendy" languages. To a certain degree I agree, at least about LISP and Fortran. You should add Haskell to the list. One language has also lived long beyond most of the trendy languages: COBOL. Take that for what it's worth. > but JS for backend is like writing in Visual Basic. These days you can do anything in it, it will be fast, but that doesn't make it the right choice. Why this is even an issue is beyond me. Nodejs is good for people writing a small backend to interact with a single page app on the client side. If you're writing giant Nodejs apps you're doing it wrong. Besides, with pretty much every language having web frameworks and every language compiling to JS, you have plenty of choices. Despite all of JS' quirks, people still write amazing things in it. That should tell you something.
- dpratt 13y ago> Why is this a problem? Most web problems don't need a large code base. A small, dynamic language is suited to web problems. This is demonstrably false the second you start to use JS on the backend. Just because most of the problems you've seen require only tiny codebases does not mean that they all do.
- Mikeb85 13y agoThen use something else on the back end. Problem solved. I'm saying the places you need JS and only JS are small. Have a larger problem? Use a statically typed language on the back end, and compile to JS on the front...
- w0utert 13y ago>> JS only picked up steam because Flash died. Not because it was a great language. If it were a great language people would have started optimizing it 5 years ago. It isn't. So they didn't. The new optimizations are out of necessity. And because it lets front end pretend to be backend. That may sound snobby, and it is, but JS for backend is like writing in Visual Basic. These days you can do anything in it, it will be fast, but that doesn't make it the right choice. Very much ^this. I never cease to be amazed by the defensive attitude and excuses coming from JavaScript developers. Usually the premise is "I can get shit done in it, so it must be good", which isn't a particularly strong argument. If you would make up 20 completely different metrics to rank programming languages on, and score every popular language using each of them, JavaScript would be near the bottom of almost all of them, and near the top of none. It's not terrible in every way imaginable (it would score reasonably well on 'productivity' for example), but it's not great in any of them either, which frankly makes it a shit language that only exists as a historical accident.
- rmrfrmrf 13y agoI like JavaScript, and I don't really know what was wrong with Visual Basic either.