Formin stands apart in the world of programming languages, not born from a grand, pre-defined vision, but rather from an intriguing experiment. What began as a quirky esoteric language (esolang) centered around an unusual flow-based command syntax, purely for fun, gradually revealed an unexpected truth: its unique structure was remarkably well-suited for crafting concise numeric scripts and achieving highly predictable control flow. This pivotal realization transformed Formin from an academic curiosity into a small, yet powerful, compiled language, firmly anchored by a Fortran-based toolchain and dedicated to math-intensive scripting.

This article delves into the fascinating evolution of Formin, exploring its distinctive architecture and the valuable lessons gleaned from constructing both a compiler and a virtual machine entirely in Fortran.

Origins: A Syntax That Defies Convention

Formin’s syntax is undeniably unique, built upon a flow-based command structure. Imagine commands that look like create#/variable|value/# or ifgo#/condition|target_label|else_label/#. This compact, rigid format was initially designed for ease of interpretation. However, as the language grew, this seemingly “quirky” structure proved to be surprisingly intuitive and efficient, moving beyond mere novelty to genuinely usable. Its control flow, for instance, offers a direct and clear path for managing program execution, ideal for iterative and conditional logic.

The Fortran Core: Compilation and Execution

Despite its scripting-like appearance, Formin is not interpreted directly in its current iteration. It compiles to a bytecode format (.fbc) through forminc, its compiler, which is written in modern Fortran 95. This bytecode is then brought to life by forminvm, a virtual machine, also crafted in Fortran.

This Fortran-centric design wasn’t arbitrary. The creator’s affection for the language and the ambition to build a VM in Fortran were key drivers. While the ability to compile to a native binary remains a future aspiration, the current Fortran-based compilation pipeline offers a robust and functional approach.

Deconstructing Formin: An Architectural Overview

Formin’s operational heart comprises three primary components:

  1. Parser: This component acts as Formin’s linguistic interpreter, converting its distinct flow-based syntax into a structured Abstract Syntax Tree (AST) through a deterministic tokenization and parsing process.
  2. Compiler (forminc): The compiler takes the AST and translates it into bytecode. During this phase, forminc performs essential optimizations such as constant folding and label resolution, finally packing these operations into a simple, fixed-size instruction set with clear operand encoding and predictable binary storage for numeric values.
  3. Virtual Machine (forminvm): The VM is the execution engine, interpreting the bytecode instructions. It adeptly handles a wide array of operations including arithmetic calculations, intricate control flow, variable management, file input/output, list manipulations, and system commands. A significant advantage of its Fortran foundation is the inherent speed and cross-platform consistency of its numeric operations.

Get Involved with Formin

The Formin project, including both its compiler and virtual machine, is open-source and readily available on GitHub (github.com/CapinolDev/Formin). The developer actively encourages issues, suggestions, and feedback, especially concerning compiler structure, VM design, or numeric type handling, welcoming collaborative input.

Concluding Thoughts

Formin, though still in its nascent stages, represents an enlightening journey into language design. The fusion of its straightforward flow-based syntax, the reliability of numeric operations, and a compact Fortran-powered bytecode VM creates a compelling platform for ongoing innovation. For anyone passionate about language development, Fortran programming, virtual machine architectures, or experimental numeric tools, Formin offers a unique and engaging project to explore and contribute to.

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed