3 ms·
When I went through these books (https://interpreterbook.com/ https://interpreterbook.com/ and its sequel https://compilerbook.com/ https://compilerbook.com/),
by xavdid 4y ago
When I went through these books (https://interpreterbook.com/ https://interpreterbook.com/ and its sequel https://compilerbook.com/ https://compilerbook.com/), I did them in Typescript, which was a great exercise. I felt like this is the sort of program that really gives TS its time to shine.
Ironically, I didn't get _any_ speed up using the interpreter vs the compiler in my TS implementations. I'm not sure if that's because I wasn't careful enough with memory allocation in the compiler or V8 had already sped up the interpreter as fast as it was going to go. It's been on my list to dig in and try to fix that, but I've since moved onto other projects.
- ufo 4y agoI guess that most likely it is not due to v8 magic optimizing the interpreter as much as it can be. The end result of v8 optimizing an AST interpreter is not the same as the end result of v8 optimizing a bytecode interpreter.
- xavdid 4y agoThat makes sense, but I thought it was odd that the two implementations had _identical_ timing results. I should really dig more into it, I just haven't. I linked the benchmarking script and results in this comment if you're curious: https://news.ycombinator.com/item?id=31643006 https://news.ycombinator.com/item?id=31643006
- eatonphil 4y ago> Ironically, I didn't get _any_ speed up using the interpreter vs the compiler in my TS implementations. I'm not sure if that's because I wasn't careful enough with memory allocation in the compiler or V8 had already sped up the interpreter as fast as it was going to go. It's been on my list to dig in and try to fix that, but I've since moved onto other projects. What were your benchmark programs?
- xavdid 4y agoI used the recursive fibonacci implementation from the book. You can see the whole bookmarking script here: https://github.com/xavdid/monkey-ts/blob/a3d1789cbb80e33316abda23186b0acf4968e31f/src/benchmark.ts https://github.com/xavdid/monkey-ts/blob/a3d1789cbb80e33316a... I've also got the node profiler results here: https://github.com/xavdid/monkey-ts/tree/a3d1789cbb80e33316abda23186b0acf4968e31f/profiling https://github.com/xavdid/monkey-ts/tree/a3d1789cbb80e33316a...