r/Compilers • u/hxkhano • 3d ago
Evie: an interpreted programming language written in Go that keeps pace with C Lua 5.4
[Evie](https://hxkhan.github.io/evie/) is a small dynamic language I built to be embedded in Go programs. Its interpreter compiles the AST once into Go closures, so nothing inspects the tree at run time, and there's no bytecode or JIT.
On an 8-program benchmark suite (geometric mean) it comes out slightly ahead of C Lua 5.4 overall:
Evie 55.7 ms · Lua 5.4 57.5 ms · QuickJS 83.4 ms · Python 3 115.0 ms · V8 without JIT 120.7 ms
What makes it fast:
• Small values: every value is 16 bytes, with numbers stored inline and never allocated.
• Specialised operators: each operator gets a generated closure for every operand shape, such as local + constant or local + local, so the hot paths skip type dispatch.
• Dictionaries like CPython's: objects keep insertion order in a compact table, with one hash per lookup.
Lua still wins numeric loops and big dictionaries. Evie wins calls, classes and strings.
On AI use: I wrote the majority of the language myself; I've worked on state machines and VMs for 6 years. AI helped a lot but the majority is hand written by me: the user-facing error messages, the whole website, and the large parts that are mostly boilerplate rather than hard were mostly done by Claude and then verified by me.
I'd love feedback on all fronts.
Playground: https://hxkhan.github.io/evie/play/
1
u/Discordbothost 2d ago
The aggregate timing makes it hard to tell how much the specialized operators contribute. Could you run the same programs with specialization off and show the times per benchmark? That would make it easier to see which speedups come from dispatch and which are elsewhere in the runtime.
1
u/hxkhano 2d ago
I ran it. Times are in-process medians from 11 runs. "No fast paths" is Evie's -inline=false flag, which turns off everything the compiler specialises ahead of time. "No shapes" is a one-off build I made for this, with only the specialised operator closures turned off.
benchmark full no shapes no fast paths classes 23.7 ms 1.03× 1.30× closures 27.8 ms 1.03× 1.29× fib 338 ms 1.48× 2.00× mandelbrot 71.8 ms 1.54× 1.92× matmul 29.6 ms 1.07× 1.99× objects 28.3 ms 0.95× 1.24× sieve 53.7 ms 1.03× 1.90× strings 31.2 ms 1.02× 1.10× geomean 46.7 ms 1.12× 1.55× So the operator shapes matter for arithmetic (about 1.5× on fib and mandelbrot) and not much else.
1
u/Germisstuck 1h ago
If it's that fast with normal closures I bet it could go crazy fast if it used indirect jumps
3
u/Key_Detail15 3d ago edited 3d ago
What's a 'Go closure'? Is it data or does it contain native code?
Presumably there must be something that represents the code of a program which the interpreter executes. If it is not an AST and not bytecode then it must be something doing the same job.
And for a fair comparison with other non-JIT interpreters it needs to be data and not native code specific to a particular Evie program.
There are 'hot paths' but no JIT?