Earlier quoted context omitted.
IMO 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 ty…
Wouldn'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.
Why the New V8 Is So Damn Fast
171–180 of 237 posts
Re: Why the New V8 Is So Damn Fast
#172Earlier quoted context omitted.
IMO 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 ty…
I quite disagree. Look at JVM performance, there’s been huge improvements over time and a Java program compiled 20 years ago will get the same improvements as one compiled today. Not only that but you can expect to get better performance from the JIT than AOT because the JIT can perform optimisations which are impossible for the compiler.
Re: Why the New V8 Is So Damn Fast
#173I 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-perfo...
Yeah, I've always wondered this too. It would be cool to be able to extract typings in a separate file, like source maps, and send over the wire along with the JavaScript bundle (for compatibility). It would definitely help moving sections of the code up the tier ladder, not unlike Web Assembly. I even predict that future typescript versions would include stricter typings optimized for an browser to solve problems li…
Re: Why the New V8 Is So Damn Fast
#174Earlier quoted context omitted.
I agree that this is unexpected for most of us, but if you read this section in my v8-perf repo ( https://github.com/thlorenz/v8-perf/blob/master/data-types.m... ) you'll understand better why that is. However it doesn't necessarily cause a large slowdown, just makes your function polymorphic and the resulting optimized code larger and a bit slower. To avoid this entirely I recommend using a JavaScript `class` when p…
Why does it have to be that the order of members matters? shouldn't both {x,y,z} and {z,x,y} compile down to {x,y,z}?
Re: Why the New V8 Is So Damn Fast
#175Earlier quoted context omitted.
The compiler can also perform optimizations that are impossible for a JIT because they're too expensive. JITs have to balance execution speed with compilation time. It's not so clear cut which approach in theoretically superior. I also don't know any languages where a JIT and an AOT compiler have gotten equivalent amounts of engineering hours so that we could have a fair comparison.
Graal can run in dynamic and aot compilation mode. If you feed profiles into aot from a test run you can get pretty close to dynamic compilation peak performance.
Re: Why the New V8 Is So Damn Fast
#176Earlier quoted context omitted.
I quite disagree. Look at JVM performance, there’s been huge improvements over time and a Java program compiled 20 years ago will get the same improvements as one compiled today. Not only that but you can expect to get better performance from the JIT than AOT because the JIT can perform optimisations which are impossible for the compiler.
> Not only that but you can expect to get better performance from the JIT than AOT because the JIT can perform optimisations which are impossible for the compiler. I can’t help myself, but the JVM performs at par with managed AOT languages (Go, Haskell, OCaml, etc) and strictly slower than the unmanaged AOT languages (C, C++, Rust). The JVM does outperform various AOT Java compilers, but that’s probably an artifact o…
JVM vs C++ depends very much on the code shapes and what the code is doing. C++ that's very heavy on virtual function calls can be faster written as Java. On the other hand if you use a lot of SIMD intrinsics and things like that, C++ can be a lot faster.
W.R.T. AOT vs JIT, as others are pointing out, Graal is a compiler that can execute in both modes, i.e. it's a comparable compiler. JITC is about a 20% win for relatively static languages like Java and can be massively larger (like 4000%+) for other languages like JavaScript or Ruby. In fact the nature of very dynamic languages like Ruby or Python or JavaScript mean there's little point trying to AOT compile them at all because there'd be almost no optimisations you could safely do ahead of time.
Re: Why the New V8 Is So Damn Fast
#177Earlier quoted context omitted.
> javascript actually makes sense and can be the most performant. Thanks to V8 you can definitely achieve good enough performance with JavaScript for most applications, and the ergonomics are pretty great. But it’s not true that performance rivals or beats C in the general case. The ‘sufficiently advanced compiler’ rainbow is something that Java has spent decades chasing. I think it’s fair to say at this point that h…
You make some interesting points about cases where JS will always be difficult to be optimized automatically. I wonder if compiler hints can help in that regard? For example, if performance is important then you could annotate the 'x+=x' line to tell the compiler to not check for overflow.
Re: Why the New V8 Is So Damn Fast
#178Earlier quoted context omitted.
Uh, how is oracle a dying organization?
I 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.
Financially Oracle is doing very well indeed.
Re: Why the New V8 Is So Damn Fast
#179Earlier quoted context omitted.
There's also JRuby, Ruby running on the JVM. Which can be insanely fast for anything longer running than your typical CLI use case.
I believe Truffle was 3-4x+ faster than Jruby. This is what Ruby needs. But Oracle will ruin it.
But you know Oracle acquired Java long ago and other than Google, I'm unaware of Oracle causing problems for any other users. And Google is a rather special case - they reimplemented an incompatible version of Java without licensing it. You're not going to be doing that.
Re: Why the New V8 Is So Damn Fast
#180Earlier quoted context omitted.
I don’t think this is a property of dynamic languages. This groovy example is almost certainly the best case for the JVM (arithmetic, few allocations or polymorphism, etc). In other words, probably not taking advantage of the dynamism. Dynamic languages can be fast by being well designed and simple (Wren) or highly optimized (JS) or both (LuaJIT). There’s also the experimental GraalVM, but this is definitely the exce…
> VM languages like Java and C# and native languages like Go. Oh well this VM meme is getting old, https://www.ptc.com/en/products/developer-tools/perc https://www.excelsiorjet.com/ https://docs.microsoft.com/en-us/dotnet/framework/net-native... https://docs.microsoft.com/en-us/xamarin/mac/internals/aot https://docs.unity3d.com/Manual/IL2CPP-HowItWorks.html