News for hackers. Stuff that matters.
Re:Common Misconceptions about Compilers by baziotis on Tuesday December 10, 2024 @01:47AM (#42374432)
Well, the truth is there's a lot more to JITing than what I wrote in the article, just because JITing didn't fit the vibe of the rest of the article that well.

Anyway, yes theoretically you can. Recently folks creating Codon (https://github.com/exaloop/codon) did it for Python using a cool form of type inference.

That said, I don't think any mainstream JS VMs do it. Most recent work I know in AOT compilation for JS seems to use some profile-guided optimization and not static type inference. For example, look at the architecture at 6:38 and also discussion about types here: https://youtu.be/pVhcyKf3efM?t=469). Something similar seems to be true for the project described here: https://www.youtube.com/watch?v=_T3s6-C38JI

The story seems to be a bit different for hopc: https://www.youtube.com/watch?v=iY1EXHQ6IeQ The video starts by giving good examples of why it is very hard to have good type inference for JS (which agrees with my intuition) but continues to talk about using type inference. However, the benchmark in this talk and in their paper are not super convincing.

All that said, JS is not my expertise so I would be interested to know more about what mainstream VMs do in practice and any latest research.

Re:Common Misconceptions about Compilers by eru on Tuesday December 10, 2024 @02:43AM (#42374723)
Thanks!

I'm friends with someone working on the 'Faster CPython' project. There's lots of interesting stuff happening there. Both in what makes it into CPython, and even more that they are experimenting with.

Re:Common Misconceptions about Compilers by baziotis on Tuesday December 10, 2024 @03:02AM (#42374829)
Oh, that's cool! I think these are the folks that made the Specializing Adaptive Interpreter which does type specialization at runtime. If these folks have any thoughts on ahead-of-time type inference and/or Codon, please let us know! :)