ChowJS: An AOT JavaScript engine for game consoles
mp2.dk
mp2.dk
Is there a way to interface with the C API from JavaScript now? I am very familiar with QuickJS already so I know that providing functionality is very easy already, but I was wondering since you compile to machine code if it would make sense to allow doing it the other way too?
Another peculiar thing on my wishlist is the ability to have a leaky GC. That is, a GC that doesn't do anything at all. In my special environment there's a phase where the whole environment is run at the highest performance possible and then immediately dropped. What actually happens is the env is reset to an "initialized" state after processing ends.
Also, does it support Linux? I think that it does because many consoles are "based" on that these days, although perhaps that is abstracted away.
One thing I was hopeful about when I first read of Deno was ability to interop with native code by making FFI/bindings available in Rust, and then package to a native binary.
That didn't pan out, and I don't blame them, but I'm still hoping to be able to write native executables/shared libs in TypeScript and use C FFI.
> so long as it was done within a promise.
I don't see how it would help things to wrap it up with concurrency abstractions. That won't make the cost go away.
First off, unlike many AOT JS compilers that has gotten exposure in the past this one actually seems realistic. The performance numbers don't see overly fantastic so they actually DO seem to implement JS properly rather than some overly optimisic JS-alike thing (the fact that they have QuickJS as an underlying base is also a plus).
So for porting this is probably a pretty good choice and should produce something working, the bad part is that even if performance is better than a plain interpreter it'll suffer compared to what you can get with a proper JIT unless you tune your code heavily for the constraints of a compiler like this. I hope they have some seamless option for moving code to C/C++ (so you can run some perf critical stuff in C via WASM on the web and have an easy way to move the code to regular native code on the ported platform).
This code is often very static, its biggest performance hit is usually cold start before the JIT. And it’s increasingly common that the code is written in TypeScript, which has tons of static analysis potential.
It would make a ton of sense to have a generalized AOT compiler for these tools. And it would be good for the ecosystem, allowing higher build performance overall while preserving portability between underlying bundlers.
I know there’s a get in touch section (which I’ll avail myself of), but if the author’s reading I’d be curious if this is a use case you’re considering.
It's probably worth noting that TypeScript's type system is deliberately unsound in a couple of corners that make it hard for a compiler to rely on the type system for optimization purposes.
But an optimizing AOT compiler doesn’t need TS to be sound any more than a JS JIT does. It just needs to optimize the paths it has confidence in.
To the extent TS code hasn’t escaped type safety, a compiler can be aggressively strict and optimize wherever the types are unambiguous. And it can fall back to the dynamic compilation it already has otherwise.
Would be interested to see a performance comparison with V8 JIT (instead of V8 interpreter).
Like there must be a way to throw enough compute at the problem and get back faster code, I'm thinking with an AOT step code could be faster on cold executions and perhaps warm up faster too and/or have a bit lower memory usage? Perhaps TS types could be leveraged too. IMO that's an under explored area.
we also have the following constraints:
- The game is still being changed regularly.
- The game is huge and not written in a uniform way,
with many different styles and paradigms being used.
- The game uses many dynamic JavaScript features such
as monkeypatching and eval.
<shudder>Really, though, this sounds like very impressive tech. But woe to anyone who has to deal with that game code.
edit: I missed the section titled "Configurable optimizations" where it addresses this.
As such I'd guess that they have an initial pass that just looks for bad patterns (eval,etc) and totally ignores optimizing those, next up you look for other things (like writes to named properties, if nobody ever writes to a .log property it's probably fairly safe since the main task is AOT compiling code). There's probably a switch-es to enable a safer mode for various things where a fast-path is the default but fallbacks would work,etc.
JS should be erased from the earth, tho. ( Expecially for gaming :'D )
But your post is so low quality that I'm wondering that maybe we shouldn't be able to.
Try to actually write your point of view instead of just farting out words with your keyboards. Let's debate and talk JS, if that's what you want, but right now you're not setting things up for debate, your are trying to start a flame war.
I'm not criticising the article per se, that such work is cool (hence the "technically cool").
Peace and love.
Personally I'd say it has some frustrating quirks, but it's possible to write good quality code in JavaScript. Modern JavaScript has many good features, as its evolution has been managed well, but it's up to the programmer to avoid the (many) bad parts.
> I am deeply convinced that sooner or later it will be replaced by some interpreted language that is more consistent and less error prone
I agree that it's possible to build less error-prone languages. There are plenty of these already. There's no chance of web browsers adding native support for a JavaScript-killing language, though. Google tried this with Dart, and failed.
We already have the option of transpiling various languages to JavaScript and/or WASM. Dart and TypeScript both compile to JavaScript, for example. So far though, none of these languages have seriously threatened JavaScript's dominance.