Re:Why the New V8 Is So Damn Fast
by enitihas on Monday July 30, 2018 @11:08PM
(#17650250)
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.
[ Parent
| on HN ]
For 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.
Yes for speed purposes. And yes some people may not like types, that's why I said completely optional. Anyways the optimizer tries to figure out the types on it's own, so give it a non blank slate to start with. You are correct in noting that js is already fast enough, but the problem is the sort of performance gotchas(order of keys in objects) as mentioned in the post aren't really obvious during development time. Types may help level the unpredictability.
Python totally ignores them at runtime, PHP has this but it actually slows down the code a bit.
It does make catching bugs easier.
That's basically what asm.js was, just less friendly to human readers.
Re:Why the New V8 Is So Damn Fast
by lifthrasiir on Tuesday July 31, 2018 @02:41AM
(#17651037)
asm.js put a type information to every single expression node, something you would never do even in the most statically typed languages.