Making your own programming language is easier than you think (but also harder)

· coding · Source ↗

TLDR

  • A developer built pslang, a low-level statically-typed language, primarily to solve sandboxable, ECS-friendly modding for a simulation-heavy game.

Key Takeaways

  • Lua sandboxing requires manually deleting IO functions via prelude scripts; C/C++ native mods make sandboxing impossible and bundle heavy toolchains.
  • pslang targets seamless C interop, small compiler footprint, fast compilation, and easy sandboxing – constraints that ruled out Lua, Lua JIT, and native C++.
  • Language features: indentation scoping, 13 primitive types (i8-i64, u8-u64, f16-f32-f64, bool, unit), two’s complement integer overflow with no UB, first-class fixed-size arrays.
  • A working 1,000-line Monte Carlo path tracer was written in pslang, demonstrating practical low-level capability before the project paused.
  • Compiler design consciously avoids recreating C++ but author admits heavy C++ influence persisted anyway.

Hacker News Comment Review

  • One commenter suggested libriscv as an alternative embedding strategy for game modding, noting its creator also uses it in a game context – a concrete alternative not evaluated in the post.
  • Python-as-ideal-language joke dominated the short thread; no substantive technical critique of the design decisions or compiler architecture appeared.

Original | Discuss on HN