When you're building a language, it doesn't live in a vacuum. There's not only the "host" language, the language the compiler is initially written in – there's also the eventual execution platform to consider.

If you have a transpiler, you might even have multiple execution environments to worry about! For example, the language you compile to might be compiled to something else...and so on.

Not gonna lie, this can be confusing.

You have to ask yourself, which platform does your language target? Is it a desktop app programming language? Does it have to run on embedded systems? What's the use case?

In this case, Foxie aims to be a web-based engine. That just gives us a few options in terms of target...two, actually, to be specific: Javascript or Web Assembly.


At first, with a Javascript-based game engine in mind, with a web-based platform the eventual dream, it seems like Javascript would be a no brainer as the execution target, as well as the host language. Right?

I've got a good ending for this post, so I've got that going for me, which is nice.

As you might've guessed from my previous posts, Javascript is less than ideal as an execution environment, for a few reasons:

  • Numbers are a mess (everything's a float, even ints).
  • Support for types has been bolted on after the fact – it would be more work.
  • The module system is still solidifying.
  • Some APIs like the Date object are completely backwards
Me after badmouthing the almighty JS. Praise be unto V8! 🙇‍♂️

And that's just scratching the surface. This post isn't bashing JS – it's how I make my living – but it is saying it's not suitable for this particular compiler project.

Even though we're targeting the web for this project, we don't have to write the compiler itself in JS, nor do we need to compile to JS. Instead, let's write the compiler in my (current) favorite language, Rust!

As for the target: we'll generate Web Assembly code that runs alongside the engine, hooking into pre-defined parts.

I'm still figuring out the WASM-related stuff at this point, and how WASM is generated in Rust, but I'm getting there. More importantly, I'm studying how to implement our parser in Rust using "nom", which looks to be an excellent library for parser combinators.

Alright, alright. Jeez. No need to yell.

I suppose I should get back to it. For now, a classic 90s song about keeping your git upstream up to date.