16 ms·
Why the New V8 Is So Damn Fast
- feliciameyes 8y agoI finally got a real hacker with a very good reputation and integrity. He turned my life around with an excellent work. I told him about my low credit score and the negative reports on my card which took him two days to tidy up despite his busy schedule just like he told me. Truth be told, I paid little for a whole lot of service, telling the world about him is a way to balance up. You can reach him via DARKWEBZZ@NULL.NET
- jerhinesmith 8y agoAs an internet user, I really enjoy reading about all these performance improvements in V8 / javascript. As a ruby developer, I'm insanely jealous.
- sbjs 8y agoJust use Express.js or Sails.js, they're 1:1 to Sinatra or Rails. Join us!
- out_of_protocol 8y agoNot true unfortunately. Rails quality unreachable for current js frameworks. Well, i hope situation will change in the future
- skunkworker 8y agoWith 2.6 JIT Ruby should be much quicker this fall. It'll be interesting to come back around once they have method inlining.
- sbjs 8y agoDoes that mean there's still room in the JS ecosystem for a Rails-alike? Maybe one that could become very popular? Because I am looking for a major open source project to create and spearhead, something that could get hundreds of thousands of active users and a thriving subcommunity, but I've been holding off until I find just the right project.
- savanaly 8y agoThere's definitely the need for this in JS. It would be extremely difficult to do, though.
- vinceguidry 8y agoPersonally, having developed in both Rails and Node, I now believe that trying to recreate Rails in JS is a foolish effort. Rails is a huge project with a ton of weight behind it and unless you can generate a massive amount of corporate investment, you won't ever be able to really catch up. I'm not saying that there's no room in the JS ecosystem for another web framework, what I'm saying is that if your design goal is re-implementing Rails, you're already setting yourself up for failure. Sequelize has tried to be ActiveRecord for how long? The only thing it makes me do is want to go back to Ruby and Rails. No, what you have to figure out if you want to do a JavaScript web framework is how to get me to actually want to use JavaScript to program a website. How can prototypical inheritance actually contribute to a workflow as opposed to a more conventional inheritance scheme. But honestly, quite frankly, I can't tell what anyone would want to use JavaScript on the server at all for.
- tlrobinson 8y agoApparently Steve Yegge ported much of Rails to JavaScript (on Rhino, at the time) back in 2007 at Google, but it was never open sourced AFAIK: https://steve-yegge.blogspot.com/2007/06/rhino-on-rails.html https://steve-yegge.blogspot.com/2007/06/rhino-on-rails.html For comparison, (according to `find . -name "*.rb" | xargs wc -l`) Rails back then was about 66K LOC (plus 38K LOC of tests) and is now 137K LOC (plus 216K LOC of tests). However, Steve says he only ported "essentially all of ActionView, ActionController and Railties, plus a teeny bit of ActiveRecord", so maybe half of the total.
- tlrobinson 8y agoAs for the second half of your comment, it sounds like you haven't used JavaScript in awhile. ES6 introduced syntax for classical inheritance, and a bunch of other nice features.
- kowdermeister 8y agoWhat Rails features do you miss from which framework?
- nicoburns 8y agoUnfortunately Sails is nowhere near as good as Rails. Which is kind of strange given the size of the JavaScript community, and the fact that PHP has Laravel and Python has Django, both of which are comparable to Rails. Amusingly given all the PHP hate, if you want a faster rails-like framework, Laravel might be your best bet.
- pmontra 8y agoI don't know anything about Laravel but I've been working with Rails since 2006 and with Django since 2016. Django has little to do with Rails. It's much more similar to Java Struts from 2005 (when I left it for Rails), form objects and template tags among the other nuisances. No XML thanks god, but a weak deployment story (no Capistrano or Mina, I built my own tool). I'd pick Django over Struts without thinking (I don't do Java anymore, even with morr modern frameworks), but I pick Rails over Django any time customers give me the choice. Django (and Struts) are optimized for large projects at the cost of developer time but very few projects grow even to medium sized. Django has a decent admin tool. That's the only advantage I can think it has over Rails for the typical project I do. I also worked with Phoenix (Elixir) in the last 12 months. It's kind of midway between Rails and Django in terms of framework and language complexity.
- mikermcneil 8y agoHave you tried Sails 1.0? (There’s always more to do, but we’re working to improve the framework a little more every day.)
- sbjs 8y agoAwesome to see the creator of Sails here! And awesome that you have such a positive and constructive response to criticisms! I see that Sails is also a company and not just an open source project, are you a full time company living off of using your open source work? If so can you give any advice to someone who is trying to learn how to make a living with open source? I am full of energy and passion for software and want to put that towards open source, but it would be much nicer to also get paid while doing so!
- axlee 8y agoHow is Express even remotely close to Rails? Express is a glorified router.
- thomasfoster96 8y agoI think the parent comment was comparing Express to Sinatra and Sails.js to Rails respectively, not altogether.
- iammiles 8y agoI believe parent's intention was to say that Express is like Sinatra and Sails is like Rails. To which I agree with the Express / Sinatra similarity.
- EduardoBautista 8y agoExpress -> Sinatra Sails -> Rails
- nielsbot 8y agoYou might be interested in TruffleRuby: https://github.com/oracle/truffleruby https://github.com/oracle/truffleruby "A high performance implementation of the Ruby programming language. Built on the GraalVM by Oracle Labs."
- askaboutit 8y agoI researched this yesterday against Crystal. Seems people won’t touch it because of oracle. Which is a real shame. Truffle is a 9x improvement in speed over Ruby. But because Oracle is a patent nightmare and a dying organization. People aren’t interested.
- yxhuvud 8y agoUh, how is oracle a dying organization?
- willio58 8y agoI went to go look for evidence of oracle dying and actually came up empty handed. I was also under this impression. I think it has waned significantly in popularity in the developer community over the years, but their stock isn’t bad at all and they seem to have diversified quite a bit in the time they’ve existed.
- repolfx 8y agoOracle doesn't even seem that patent happy these days. They seem to have got burned by their experience with the Java patents (all useless, case revolves now around copyright). Financially Oracle is doing very well indeed.
- Twirrim 8y agoThere's also JRuby, Ruby running on the JVM. Which can be insanely fast for anything longer running than your typical CLI use case.
- lovelle 8y agoI would insanely choose ruby rather than javascript for the major advantages that has to offer. Performance in most of cases is not a real needed over consistency. Also Ruby 2.6 has jit, would be great to see some bench tests. :P
- abhorrence 8y ago2.6’s JIT is entirely at the method level currently, and unfortunately for certain types of workloads (e.g. Rails) this means the performance benefit is largely outweighed by the call counters and deoptimization checks on every method invocation. There’s definitely room for improvement, and the inclusion of JIT infrastructure is awesome, it’s just not making much of a performance impact. Yet.
- munificent 8y agoV8 is also a method-based JIT as far as I know.
- jashmatthews 8y agoThe overheads from the call counters and deoptimization checks are tiny. The real problem is that right now MJIT doesn't allow much optimization beyond generating native code equivalent to simply executing the instructions. It's ridiculously simple compared to V8.
- windows_tips 8y agoIsn't there a Ruby->JS transpiler?
- ukz 8y agoOpal: https://github.com/opal/opal https://github.com/opal/opal
- tlrobinson 8y agoOut of curiosity, what are the major advantages Ruby has to offer over JavaScript?
- earenndil 8y agoWhat about jruby or oracle's java+ruby thing?
- Sohcahtoa82 8y agoReplace Ruby with Python and I have the same feelings.
- wongma 8y agoDon't be too jealous. My main concern with Node and its ecosystem is maturity and security. It loses hands down on both those points compared Ruby / Rails especially in the area of dependencies. This keeps me happily in Rubyland.
- chupasaurus 8y ago> security ... Rails One bad default setting and [0]BOOM! [0]https://github.com/rails/rails/commit/b83965785db1eec019edf1fc272b1aa393e6dc57 https://github.com/rails/rails/commit/b83965785db1eec019edf1...
- skrebbel 8y agoYou say "Ruby developer" as if you were born like that and stuck with it. There's an entire world out there!
- tinco 8y agoIf the alternative is JavaScript, I think most Ruby programmers are fine where they are ;)
- reitanqild 8y ago> As an internet user, I really enjoy reading about all these performance improvements in V8 / javascript. As an Internet user whos has been reading for years about how fast the various js engines are it annoys me that the web still feels slow :-]
- konart 8y agoAnd here I am just happy I don't have to touch js.
- konart 8y agoI'm being downvoted because I can't be happy?
- eksemplar 8y agoYou’re probably being downvoted because your comment doesn’t contribute anything to the thread. And rightly so, unless you want HN to be as useless as /r/programming. Your comment is also borderline rude, as it implies that anyone using JavaScript are unfortunate. I mean, what did you really want to achieve by posting that comment?
- konart 8y agoHow my comment is different from this one - https://news.ycombinator.com/item?id=17650823 https://news.ycombinator.com/item?id=17650823 for example? >Your comment is also borderline rude, as it implies that anyone using JavaScript are unfortunate No, it does not, that's just your interpretation. I never used word 'fortunate' or anything similar. I'm happy not to work with it as in "I'm happy not to use public transport today, because I like walking". Surely this can't be rude to anyone except those people who see everything as way to offence them somehow. Inferiority complex maybe? No idea. > I mean, what did you really want to achieve by posting that comment? Just wanted to express myself. As it turns out that's a wrong thing to do unless you have some sort of clear goal in mind. Noted.
- zawerf 8y agoWhy can't V8 deduce that the order of keys doesn't matter? It's pretty nuts that just rearranging the keys from { x, y, z } to { y, x, z } would cause a slowdown.
- gsnedders 8y agoYou can't deduce that; you'd need to show that the object is never passed to for..in or Object.keys or similar to be able to avoid storing the insertion order. They could change the representation to not be insertion order dependent, and store insertion order in a separate data structure, but that has its own trade-offs.
- chrisseaton 8y agoYou don't need to prove it, you just need to guess it successfully. If you're wrong you can deoptimise and fix-up to the same base-line performance.
- chii 8y ago> If you're wrong you can deoptimise and fix-up to the same base-line performance. but how do you know it's wrong (if the iteration order of a .keys() call isnt the same)?
- fasquoika 8y agoThe original code didn't have a call to .keys(), and that's the case where this should be optimized. If you do the unordered optimization, then encounter an operation that needs an ordered iteration, you'd have to fall back to an ordered representation (which could be slower than not doing the optimization at all)
- MikeHolman 8y agoThat requires extra bookkeeping for ordering, but it isn't really that common where people will have object literals with the same properties initialized in a different order. But a much more common case is that properties added after object creating will be added in an inconsistent order, for example: o = {}; o.x = 1; o.y = 2; o.z = 3; p = {}; p.y = 4; p.x = 5; p.z = 6; When executing p.y = 4 you don't know that the object will eventually evolve to have the same properties as o.
- barbegal 8y agoI used to believe that javascript was slow, C was fast and that there was no way to change this because of the way that javascript is interpreted and not compiled. But the more I've learnt about the benefits of "on the fly" / "just in time" optimising compilers, the more I'm convinced this is the future of computing. Being able to use multiple threads and hence multiple cores simultaneously to optimise what is actually a single threaded piece of code is quite amazing. And then being able to write code that is insanely portable and optimised on any platform is great.You can take advantage of SIMD, hyperthreading, multicore, large caches... without knowing if they're available ahead of time. Sure, you won't beat C for low memory devices or hardware that you have complete control over but for 90% of use cases javascript actually makes sense and can be the most performant.
- saagarjha 8y agoThe key being that the code you're writing needs to be performant. If you write O(n!) code, it's going to be slow whether it's C or JavaScript.
- stochastic_monk 8y agoAlgorithms take you far. Optimized code takes you the rest of the way. If you’re after performance you’ll do both, of course. I’ve found that the only subfield of which I know in which mathematicians still write their own C or C++ is concise/efficient data structures and algorithms.
- wolf550e 8y agoWelcome to 1995 and the wonderful world of Java. Except in Java you can use threads to use multiprocessing, so you can have efficient shared data structures but also hard to debug bugs.
- stochastic_monk 8y agoC++ also does this. A variety of projects, such as MXNet, use JIT compilation. Native compilation gets you far, but there are times where dynamic compilation gets you farther.
- pspeter3 8y agoI have often wondered if frameworks like React which offer polymorphic methods (eg React.createElement) cause deoptimizations. The common functions also seem to be on the critical path since they will be called 100s-1000s of times per render.
- hajile 8y agoI'm not sure about React, but a fairly common pattern is to dispatch to optimize. The parent function takes several different data types, but it is a very small pass-through that calls a variety of monomorphic functions to do the heavy lifting. It's not technically as fast, but as the amount of processing in the monomorphic functions increases, the cost of the small polymorphic function fades into the noise.
- pspeter3 8y agoThat's a good practical tip
- wcr3 8y agobecause it isn't built in js saved you a click.
- AzzieElbab 8y agoWhy hasn't node replaced PHP yet?
- dcwca 8y agoWhy haven’t electric cars replaced gasoline?
- 2trill2spill 8y agowhy would or should it?
- AzzieElbab 8y agoOne can argue that PHP is the least suitable language to write web servers in, no standard async or multithreading, tones of leaks, and so on. Node asynchronous model is quirky but given js world's "isomorphism" it should have squeezed PHP out of existence by now
- notamy 8y ago> One can argue that PHP is the least suitable language to write web servers in Of course, because you don't write a web server in PHP. You put it behind nginx or apache and those can fork off PHP processes (or you use FPM, or etc.) to do everything for you.
- AzzieElbab 8y agoOh sure, and the only reason one would do this is to keep Aws bills up to Amazon shareholders expectations
- bpicolo 8y agoPHP is roughly the hardest language to experience the effects of memory leaks in because of it's one process per request model.
- goatlover 8y agoYou don't write web servers in JS, either. You use Node.
- hatcherdogg 8y agoFor some reason I was expecting an internal combustion engine.
- mingabunga 8y agosame ha ha. Interested either way
- ShroudedNight 8y ago> In some extreme cases, developers had to write assembly code by hand for the four supported architectures. Maybe I'm tainted from my experience building / debugging J9 / OpenJ9 but... Why is this considered extreme? If one strays one iota from the standard platform ABI, which is basically a necessity for producing a performant runtime (PICs being an easy example), this is where one ends up.
- mwsherman 8y agoI speculated recently that TypeScript might _de facto_ help V8 optimizations, and the post seems to confirm that. https://clipperhouse.com/does-typescript-make-for-more-performant-javascript/ https://clipperhouse.com/does-typescript-make-for-more-perfo...
- askmike 8y agoIMO The problem as it stands now is that when developing typescript you have a compiler running on your machine doing the typechecking. It will error out and simply not compile when you try to pass a string to a fn expecting a number. What if there is a bug (or even a misconfiguration in your project)? Or typescript changes over time (and now there are different versions all needed to be supported)? Or what if the types from typescript (designed for programmers) are not always inline with V8 internal representation of objects?) Or what if people push typescript through V8 with compile time errors? (The compiler should have prevented this from happening - but you can pump whatever you want into V8, including things considered broken by typescript). You only really get any improvement in runtime if your compiler guarantees anything (and bakes it into whatever it is compiling). As of now there are little guarantees with the javascript language (which is what comes out of your typescript compiler). AFAIK typescript is designed to help programmers find common bugs. Not saying it's not possible, but more work is needed into bridging the two.
- enitihas 8y agoWouldn't it be good if JavaScript also starts supporting python like type annotations (completely optional, but unlike python used to guide the optimizer. Given that some non trivial amount of JS is already generated after type checking (typescript, flow, and all the statically typed languages compiling to JS), all this compile time type info could be made available to the optimizer.
- askmike 8y agoFor speed purposes? This post is for example already talking about how fast JS is getting without types. I'd say it would be a lot easier to simply focus on the WebAssembly format, you can write your code in a number of (typed) languages and compile into wasm which is designed to be fast. Javascript already comes with a few decades of bagage, and things are already changing really fast (ES6 and newer versions). Not everyone likes types and the people who do can use typescript (or flow). And the people who need insane performance (games, etc) can use WebAssembly.
- safgasCVS 8y agoCatfished. I thought this was going to be about cars.
- antoaravinth 8y agoDoes anyone used Chakara core? How does it compares itself with V8?
- classics2 8y agoYou have social icons floating over he text.
- jacksmith21006 8y agoWould be curious to see how much faster Dart is over using JS with V8?