2 ms·
For fun, I tried porting the Wren interpreter from C to Go and it was about 3x slower. There are a couple of issues: - Giant switch statements are not optimize
by skybrian 8y ago
For fun, I tried porting the Wren interpreter from C to Go and it was about 3x slower. There are a couple of issues:
- Giant switch statements are not optimized as well as C.
- In C you can do tricks like NaN encoding to create a union between floats and pointers. In Go, this doesn't work and you have to use an interface.
There might be a garbage-collected language that lets you write efficient interpreters (perhaps Julia?) but I don't think you can take this for granted.
- jashmatthews 8y agoJava. JRuby is a great example of our performing a C based implementation.
- skybrian 8y agoVery true, but that's also not a pure interpreter anymore. In languages that support eval() or generating and loading bytecode, it's leveraging the JIT compiler and effectively generating native code.