Have you ever dreamed of creating your own programming language? I did — and I followed through with it.
It’s called Soplang, and it’s a language designed with simplicity, education, and the Somali language in mind. But building a programming language isn't as mysterious as it seems — and you don't need to start from raw machine code.
In this post, I’ll walk you through:
- What a programming language really is,
- How they’re built (step by step),
- Why most languages are built on top of others,
- And the lessons I learned building Soplang — especially the pain of designing grammar in Somali.
What Is a Programming Language?
At its core, a programming language is just a way to give instructions to a computer. But computers only understand machine code — binary ones and zeros. So we create human-friendly languages that get translated into something the machine can actually execute.
A typical language has:
- Syntax: the rules of how code is written (like grammar in English).
- Semantics: the meaning of that code (what it does).
- A compiler or interpreter: a program that translates your code into something executable.
- Standard library: built-in functionality like math, file access, networking, etc.
How Are Programming Languages Built?
Let’s break it down into the essential building blocks:
1. Lexing & Parsing
You take the raw code (door x = 5
) and turn it into tokens: words like door
, x
, =
, 5
.
Then, you parse those tokens into an Abstract Syntax Tree (AST) — a tree structure that represents what the code means.
2. Interpreting or Compiling
Once you have the AST, you can either:
- Interpret it: directly execute it line by line (like Python does),
- Or Compile it: translate the whole thing into another language or machine code (like Rust or C++).
3. Runtime / Standard Library
This is the toolbox for your language: math functions, file I/O, networking, etc. Without this, the language can’t do much.
4. Tooling
Once your language works, you still need:
- A REPL (interactive shell),
- A CLI tool to run code,
- An editor plugin (e.g. VS Code extension),
- A debugger, linter, formatter — the whole ecosystem.
For Soplang, the first version includes a Python-based interpreter, an extended standard library, and we’re building a Rust-based compiler and a browser version (sopScript
) next.
Every Language Stands on the Shoulders of Another
Almost every major language you know was built using another language.
- Python was written in C.
- JavaScript (V8 engine) is written in C++.
- Rust was first prototyped in OCaml, then rewritten in Rust.
- Go was bootstrapped with C.
- TypeScript compiles to JavaScript.
- Even C came from B, which came from BCPL.
So when I started Soplang, I used Python to build the first interpreter. It let me move fast, prototype quickly, and focus on language design. Later, we’re switching to a Rust-based compiler for better performance and safety.
Using another language to build your own isn’t cheating — it’s the standard.
Lessons From Designing Soplang’s Grammar (It Was Painful)
One of the most surprising challenges I faced was choosing the right grammar and keywords — especially because Soplang is designed with Somali in mind.
At first, I used keyd
for variables — it means “storage.” Technically correct, but it didn’t feel natural.
After some testing and feedback, I changed it to door
, a short form of doorsoome, meaning “something that changes.” That captured the real purpose of a variable better, and it was shorter and cleaner.
But that process repeated for every keyword:
- What should
if
,while
,print
,function
be in Somali? - Should the syntax look more like Python or something completely new?
- Should I favor readability or brevity?
Language design isn’t just technical — it’s cultural and linguistic too.
The Future of Soplang
Soplang is still evolving. Here’s what’s coming in Soplang 2.0:
- A new, clean grammar specification.
- A Python interpreter and a Rust-based compiler.
- A CLI tool (
sop
) to run and manage packages. -
sopScript
: Soplang running in the browser. - A full standard library: math, file I/O, networking, date/time.
- A VS Code extension with auto-completion, syntax highlighting, and inline docs.
- A new website and documentation.
Final Thoughts
Building a programming language is like creating your own universe. You define the rules, the words, the behaviors. It’s hard — but deeply rewarding.
You don’t need to be a compiler expert to start. You just need a goal, a little curiosity, and the patience to make a lot of design decisions.
Whether you're thinking about building your own language or just curious how it’s done — I hope Soplang inspires you.
Mr Sharafdin.