DEV Community

Erdinc Daskin
Erdinc Daskin

Posted on

From Esolang to Numeric Script: Building Formin in Fortran

Most programming languages begin with a clear intention. Formin didn’t.

It started as a strange little esolang experiment built around an unusual flow-based command syntax, mostly for fun. Over time, though, something unexpected emerged: the structure turned out to be surprisingly good for concise numeric scripts and predictable control flow. That realization turned Formin from an esoteric toy into a small compiled language with a Fortran-based toolchain and a focus on math-heavy scripting.

This post walks through the journey, the architecture, and some of the lessons learned while building a compiler and VM in Fortran.

Origins: An Esolang With a Weird Syntax
Formin’s syntax is built around commands that look like this:

create#/greeting|'Hello!'/#
color#/bright_green/#
spew#/greeting|'World!/#
Enter fullscreen mode Exit fullscreen mode

It’s compact, rigid, and easy for an interpreter to read, which was the entire point in the early days. But as more commands were added, the structure started to feel usable, not just "quirky haha so random".

Flow control evolved into this:

create#/x|0/#
mark#/loop/#
add#/x|x|1/#
ifgo#/x|isnt|10|loop|_/#
bye
Enter fullscreen mode Exit fullscreen mode

Compilation
Although Formin looks like a scripting language, it’s not interpreted directly. Well, it used to be, but I recently made it compiled.

It compiles to bytecode (.fbc) through forminc, a compiler written in modernized Fortran 95. The bytecode is then executed by forminvm, a virtual machine also written in Fortran.

The pipeline looks like this:

main.fmn + forminc -> main.fmn.fbc + forminvm -> result
Enter fullscreen mode Exit fullscreen mode

Why this design?
I wanted to make a vm in fortran.
Also, I'm not talented enough to make it compile to a native binary.

Why did I choose Fortran?
I just really like the language

Architecture Overview

Formin’s core consists of three main components:

  1. Parser

A deterministic tokenizer and parser convert the flow-based syntax into a structured AST.

  1. Compiler (forminc)

The compiler lowers the AST into bytecode, performing:

basic optimizations

constant folding

label resolution

opcode packing

The bytecode format is intentionally simple: fixed-size instructions, clear operand encoding, and numeric values stored in a predictable binary format.

  1. Virtual Machine (forminvm)

The VM executes bytecode instructions, handling:

arithmetic

control flow

variable storage

file I/O

list operations

system commands

Since it’s Fortran-based, numeric operations are fast and consistent across platforms.

Source

The project is open source, including both the compiler and VM:

github.com/CapinolDev/Formin

Issues, suggestions, and feedback are welcome - especially around compiler structure, VM design, or numeric type handling, I won't get butthurt :).

Closing Thoughts

Formin is still young, but building a compiled language in Fortran has been an enlightening path. The combination of simple flow-based syntax, numeric predictability, and a compact bytecode VM makes it an interesting platform to iterate on.

If you enjoy language design, Fortran programming, VM architectures, or experimental numeric tools, feel free to check it out or follow along with development.

Top comments (0)