Image of Aaron Gough, Software Developer

Introducing Koi - A language that teaches the basics of language implementation

Several months ago I started on a quest to learn more about how programming languages work internally. Today I am releasing my first programming language: Koi.

Koi is designed, above all else, to be a language whose implementation demonstrates the basics of how to build a language in a straight-forward way.

Most programming language implementations are written in low-level languages like C in order to maximize performance, and this generally makes them very opaque and difficult to follow.

In order to avoid this problem Koi is written from the ground up in Ruby to make sure that the implementation language never gets in the way of the intent of the code. Koi will likely never be suitable for use as a production language, but that was never one of its goals.

Koi is an imperative, dynamic, weakly-typed language with first-class functions. Koi’s syntax and features were influenced by Lua, JavaScript and Ruby. Additionally Koi makes a special point of working very hard to be unambigous in its syntax so that it is easy to write parsers for.

Code example:

An old-school ‘Blast Off!’ example in Koi:

 1 countdown = function( count )
 2   print( to_string( count ))
 3   print( ", " )
 4   if( count == 0 )
 5     return()
 6   end
 7   count = count - 1
 8   call( countdown, count )
 9 end
11 call( countdown, 10 )
13 print( "Blast Off!" )
15 #=> 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, Blast Off!

More code example are available at the Koi GitHub repository


For ease of use Koi is packaged as a RubyGem and will automatically install its dependencies. OSX and most flavors of Linux come with Ruby and RubyGems pre-installed so you should just be able to type:

1 gem install koi-lang

If you need to install Ruby please check the Ruby website for instructions


To run a Koi program simply type:

1 koi /path/to/program


The default toolchain for Koi is made up of several components, for more information on each of them you can read the simple documentation at their respective GitHub pages:

Digging deeper:

The overall system is designed to be simple at all costs and because of this reading through and comprehending the entire system should take no more than a day or two for a moderately experienced programmer.

The easiest way to read through the source code is to browse it online at GitHub

More info:

For more info please check the documentation links listed above or feel free to contact me at: