Yes, my very own. It’s my third try at the problem and I don’t really know why this one worked. I guess I just wasn’t ready before.

But why ?

There already exist a plethora of perfectly fine language with extensive tools, guides and libraries. So why build my own ?

For fun, i’m building this because it’s fun and a good opportunity to learn.

How do you build your language ?

There are multiple ways to create your own language. I choose the easy way. Not the easiest way but I didn’t build a gcc-like compiler with optimizer and assembly generation.

I choose Ocaml for it’s parsing library Menhir and it’s beautiful type system.

The easy way out

Making a compiler is difficult. Generating assembly is a pain. First of all, you have to decide what king of assembly you want to generate: x86. x64, ARM ? There’s a lot of choice and each one comes with different encoding and building blocks.

A lot of amateur languages use a simple trick. Compile to C and use GCC or Clang to compile down to machine code.

I took and even easier alternative: compile to scheme. Scheme is a lisp language. There are a few implementation that come with a scheme to C compiler. I use the fact that the my internal representation of Planck is similar to lisp to use it as an easy compile target. I can then use the existing compiler infrastructure to lower my code all the way down to machine code.

Planck source code -> compile to scheme -> compile to C -> compile to native code.

The GC situation

I didn’t mention the memory management solution used in my language and there’s a good reason for it. It’s beacause it’s managed by the runtime. Conveniently for me, I didn’t have to write one because Scheme already includes it.

some code in here