It's awesome to see how more JS runtimes try to approach Wasm. This project reminds me to Static Hermes (the JS engine from Facebook to improve the speed of React Native projects on iOS and Android). I've spent a bit of time trying to review each, so hopefully this analysis will be useful for some readers. What are the main commonalities and differences between Static Hermes and Porffor? * They both aim for JS test26…
For the record, Static Hermes fully supports compiling JS to WASM. We get it basically for free, because it is an existing LLVM backend. See https://x.com/tmikov/status/1706138872412074204 for example. Admittedly, it is not our focus, we are focusing mainly on React Native, where WASM doesn't make sense. The most important feature of Static Hermes is our type checker, which guarantees runtime soundness. Porffor is ve…
Porffor: A from-scratch experimental ahead-of-time JS engine
111–120 of 148 posts
Re: Porffor: A from-scratch experimental ahead-of-time JS engine
#112Porffor can compile to real native binaries without just packaging a runtime like existing solutions. Any language that allows generating and interpreting its own code at runtime will have the "eval problem". From some other comments here, it sounds like Porffor's solution is to simply ignore it.
Re: Porffor: A from-scratch experimental ahead-of-time JS engine
#113Earlier quoted context omitted.
Since Porffor can compile itself (you can run the compiler inside of Porffor), any calls to eval could be compiled to Wasm (via executing the Porffor compiler in Porffor JS engine) and executed performantly on the same JS context * *or at least, in theory
That wouldn't work: The Wasm spec does not allow for modifying an already running program (e.g. JIT). AFAIK the only option is to include an interpreter.
I'd recommend checking the work on making SpiderMonkey emit Wasm as a backend
Re: Porffor: A from-scratch experimental ahead-of-time JS engine
#114I have thought about doing this and I just can't get around the fact that you can't get much better performance in JS. The best you could probably do is transpile the JS into V8 C++ calls. The really cool optimizations come from compiling TypeScript, or something close to it. You could use types to get enormous gains. Anything without typing gets the default slow JS calls. Interfaces can get reduced to vtables or may…
Somewhat related to this idea is AssemblyScript https://www.assemblyscript.org
Re: Porffor: A from-scratch experimental ahead-of-time JS engine
#115Earlier quoted context omitted.
If it’s interested in behaving as though “the ECMAScript host is a web browser”, of course it does, it’s part of the spec: https://tc39.es/ecma262/multipage/additional-ecmascript-feat... . And given how trivial it is (function() { return " " + this + " "; }), it makes a fair amount of sense to implement it even if the ECMAScript host is not a web browser, in which case it’s optional (see the top of the linked documen…
The reason I would argue that it does imply a sense of humor is that on any web browser that supports WASM, the tag itself has been deprecated and non-functional for ages. In fact, it doesn't even have an entry on MDN, only an indirect reference through String.blink() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Re: Porffor: A from-scratch experimental ahead-of-time JS engine
#116Earlier quoted context omitted.
I'm a little behind times on Haskell (haven't used it for some years) – there always were extensions that made it unsound, but the core language was pretty solid.
Look at the last example in there: https://counterexamples.org/polymorphic-references.html
Re: Porffor: A from-scratch experimental ahead-of-time JS engine
#117Earlier quoted context omitted.
Maybe OCaml, but I haven't studied it much.
I doubt it's been proved to be sound. It shows up a lot on https://counterexamples.org/ , although if I skim the issues seem to have been fixed since then.
Re: Porffor: A from-scratch experimental ahead-of-time JS engine
#118Earlier quoted context omitted.
So - I know this in theory, but avoided mentioning it because I couldn’t immediately think of any persuasive examples (whereas subtype polymorphism is a core, widely used, wholly unrestricted property of the language) that didn’t involve casts or any/unknown or other things that people might make excuses for. Do you have any examples off the top of your head?
Here's an example I constructed after reading the TS docs [1] about flow-based type inference and thinking "that can't be right...". It yields no warnings or errors at compile stage but gives runtime error based on a wrong flow-based type inference. The crux of it is that something can be a Bird (with "fly" function) but can also have any other members, like "swim" because of structural typing (flying is the minimum…
Re: Porffor: A from-scratch experimental ahead-of-time JS engine
#119I unironically appreciate that it supports String.blink. It's always a good sign if the developer has a sense of humor and playfulness.
Re: Porffor: A from-scratch experimental ahead-of-time JS engine
#120Earlier quoted context omitted.
> A TypeScript designed to aid static compilation likely would have that distinction. AssemblyScript ( https://www.assemblyscript.org/ ) is a TypeScript dialect with that distinction
It’s advertised as that, and it’s a cool project, but while it’s definitely a statically typed language that reuses TypeScript syntax, it’s not clear to me just what subset of the actual TypeScript type system is supported. That’s necessarily bad—TypeScript itself is very unclear about what its type system actually is. I just think the tagline is misleading.