Live data from Hacker News

Porffor: A from-scratch experimental ahead-of-time JS engine

porffor.dev

121–130 of 148 posts

Re: Porffor: A from-scratch experimental ahead-of-time JS engine

#121

Earlier quoted context omitted.

> there's quite a lot that can be improved in JS during compile time I wonder how much performance gain you expect to achieve. For simple CPU-bounded tasks, C/Rust/etc is roughly three times as fast as v8 and Julia, which compiles full scripts and has good type analysis, is about twice as fast. There is not much room left. C/Rust/etc can be much faster with SIMD, multi-threading and fine control of memory layout but…

Honestly, I’m fine with only some speed up compared to V8, it’s already pretty fast… My issue with desktop/mobile apps using web tech (JS) is mostly the install size and RAM hunger.

The "node" binary on my laptop is 45MB in size. I guess the browser component may take more disk space than JS runtime. Similarly, I am not sure whether JS runtime or webpage rendering takes more RAM. If it is the latter, an AOT compiler won't help much.

Re: Porffor: A from-scratch experimental ahead-of-time JS engine

#122

Earlier quoted context omitted.

Also funded the Ladybird browser recently. Seems to like his web.

Not familiar with this stuff at all, is Porffor a js engine that Ladybird could end up using? Or are they still writing their own?

Since js is dynamic you can't compile all ahead of time, so you need an interpreter

Re: Porffor: A from-scratch experimental ahead-of-time JS engine

#123

Earlier quoted context omitted.

Also funded the Ladybird browser recently. Seems to like his web.

Not familiar with this stuff at all, is Porffor a js engine that Ladybird could end up using? Or are they still writing their own?

I thought ladybird used WebKit?

Re: Porffor: A from-scratch experimental ahead-of-time JS engine

#124
post #49
post #32

Earlier 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…

Here's a simpler repro:

    type Bird = { id: number };
    type Human = { swim?: () => void; id: number };

    function move(animal: Bird | Human) {
        onlyForHumans(animal); 
    }

    function onlyForHumans(swimmer: Human) {
      if (swimmer.swim) {
        swimmer.swim();
      }
    }

    const someObj = { id: 1, swim: "not-callable" };
    move(someObj);
`someObj` gets casted as `Bird`, then `animal` gets casted as `Human`. Unfortunately unions here are indeed unsound.

As as workaround you could add a property `type` (either `"bird"` or `"human"`) to both `Bird` and `Human`, then TypeScript would be able to catch it.

Re: Porffor: A from-scratch experimental ahead-of-time JS engine

#125

Earlier 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.

*not necessarily bad, d’oh

Re: Porffor: A from-scratch experimental ahead-of-time JS engine

#126

Earlier quoted context omitted.

Not familiar with this stuff at all, is Porffor a js engine that Ladybird could end up using? Or are they still writing their own?

Porffor compiles the JS to WASM, so it would be kind of a waste. Though there might be no reason the two projects cannot share some logic, like parsing the JS and such. I kind of doubt this is why its being funded. It sounds like a useful project.

It can also compile to Native

Re: Porffor: A from-scratch experimental ahead-of-time JS engine

#127

Earlier quoted context omitted.

Not familiar with this stuff at all, is Porffor a js engine that Ladybird could end up using? Or are they still writing their own?

I thought ladybird used WebKit?

No. Completely green field. Well, it _was_. I believe they’ve recently accepted that third party libraries will be allowed in the non-Serenity OS version.

Re: Porffor: A from-scratch experimental ahead-of-time JS engine

#128
post #20

Earlier quoted context omitted.

Presumably the idea is that any work that causes Test262 regressions is temporary, takes place in a separate branch, and is only merged to main once the branch also contains all the necessary fixes to make the regressions go away again. A new version number would only be used once that merge happens.

Exactly. The versioning system is definitely unique and controversial, but I think it fits for a fast moving project like this, so I don't have to really consider versioning which could slow development. When it becomes more stable, I'll likely move to a more traditional semver scheme from 1.0.

What happens if there’s a regression in coverage, maybe due to a large sweeping change, and you go from 0.40 -> 0.35 ?

Re: Porffor: A from-scratch experimental ahead-of-time JS engine

#130

Earlier quoted context omitted.

> I think the even bigger elephant in the room is that TypeScript's type system is unsound. Can you name a single language that is used for high-performance software and whose type system is sound? To speed up the process, note that none of the obvious candidates have sound type systems.

Java, C#, Scala, Haskell, and Dart are all sound as far as I know. Soundness in all of those languages involves a mixture of compile-time and runtime checks. Most of the safety comes from the static checking, but there are a few places where the compiler defers checking to runtime and inserts checks to ensure that it's not possible to have an expression of type T successfully evaluate to a value that isn't an T. Type…

All of these have, at the very least, escape hatches that makes the type system unsound overall. And probably other issues https://counterexamples.org/ I can find a few in there for at least scala and haskell. Perhaps this is not a satisfying answer to you, an "unsound type system" is a technical, precise notion, and this is what people who parrot "typescript is unsound" are referring to. You cannot just reply "well there are a few runtime checks so it's all good."
Post reply on HN