Optimizing an old interpreted language: where to begin?

This page summarizes the projects mentioned and recommended in the original post on /r/Compilers

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • toaststunt

    Mostly experimental additions to the LambdaMOO-Stunt server, embarrassing mistakes and all. (by sorressean)

  • Hi all, I've been interested in compiler design and optimization for a long time now, and want to start learning as I work on this language. The language's grammar is defined using Bison, and from there an AST is created. the AST is passed to the codegen system that creates bytecodes from it, which the VM then runs. When I look up optimization Gcc and Clang seem to be the first primary options people look toward for learning, but I have a few issues with that. First, picking out a path forward to begin working on this seems daunting because I'm not sure where to start, and secondly there are so many things those compilers do that I don't actually need to do. I'm looking for some advice on how I can begin learning to make this system better, maybe some resources or just some starting points. The code is here: https://github.com/sorressean/toaststunt

  • stunt

    LambdaMOO with multiple inheritance, anonymous objects, HTTP, JSON <-> MOO translation, better crypto, a map datatype and a RESTful interface.

  • However, improving the interpreter is going to be very tricky as the bytecode is dynamically typed, so you can't tell at compile time whether a+b is going to do an integer addition, float addition, string concatenation, etc --- you have to test the object types at run time. See the implementation here: https://github.com/toddsundsted/stunt/blob/a4158f5835f1beb9d754c92fd5b3a137e459aabf/execute.cc#L1272 This means that unless you're willing to do sophisticated run-time analysis inside the interpreter, a JIT is going to be very hard.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • Som

    Parser, code model, navigable browser and VM for the SOM Smalltalk dialect (by rochus-keller)

  • One option is to leverage someone else's JIT: you could, for example, rewrite the interpreter to transpile to Lua source, which is then run in LuaJIT. There's a Smalltalk dialect which does this successfully; the Lua version runs in 1/12th the time of the C interpreted version. https://github.com/rochus-keller/Som You can use LuaJIT's FFI to call back into the Stunt server, or else just rewrite it completely in Lua --- large parts of the Stunt server will just go away in a native Lua implementation (e.g. the object database is just a table). Javascript would be another candidate for this.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts