= Koi Koi is a small programming language that is designed to be easy to use, easy to understand and easy to implement. Koi is an imperative, dynamic, weakly-typed language with first-class functions. Koi's syntax is influenced by JavaScript, Lua and Ruby, but works very hard to be unambiguous so that it is easy to write parsers for (in stark contrast with Ruby). === Example This is an old-school 'Blast Off!' program written in Koi: countdown = function( count ) print( to_string( count )) print( ", " ) if( count == 0 ) return() end count = count - 1 call( countdown, count ) end call( countdown, 10 ) print( "Blast Off!" ) #=> 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, Blast Off! === Installation For ease of installation the default installation of Koi is packaged as a RubyGem. Providing you have Ruby and RubyGems installed installing Koi is as easy as entering the following command in a terminal: gem install koi-lang Mac OS X and most Unix/Linux distributions come with an installation of Ruby and RubyGems. If you do not have Ruby and RubyGems installed please check the {Ruby website for instructions}[http://www.ruby-lang.org/en/downloads/]. === Usage After Koi is installed you can run a program by typing the following on the command line: koi /path/to/program == Koi Fundamentals === Data types Koi features a full set of basic and compound data types including: * Nil * Boolean * Integer * Float * String * Hash * Function === Flow control Koi currently only implements a minimal set of flow control operators: if( expression ) call( do_work ) endif unless( expression ) call( do_other_work ) endunless === Built-in functions print( string ):: Writes a string to STDOUT. gets():: Fetches a newline delimited string from STDIN. call( identifier [, parameter]):: Calls the function that is stored in 'identifier'. tailcall( identifier[, parameter]):: Performs a 'tailcall' to the function stored in 'identifier'. This type of call is used when recursing heavily to improve performance and to facilitate the use of functions as iterators. return( [value] ):: Return a value from a function. to_string( value/identifier ):: Converts the given value to a representative string. type_of( value ):: Returns a string representing the type of the value given, eg: "integer". === Reserved words if, unless, function, end, call, tailcall, print, gets, return, to_string, type_of, nil, true, false === Components The default installation of Koi consists of the following discrete components: * The reference parser: {koi-reference-parser}[http://github.com/aarongough/koi-reference-parser] * The reference compiler: {koi-reference-compiler}[http://github.com/aarongough/koi-reference-compiler] * The standard Virtual Machine: {koi-vm-ruby}[http://github.com/aarongough/koi-vm-ruby] Each of these components are completely stand-alone and are specifically designed to be as simple as possible. I strongly encourage pulling them apart to see how they tick, and changing them if you see fit! Just make sure if to contribute any improvements back to the main repository! ==== Hope you enjoy Koi! === Author & Credits Author:: {Aaron Gough}[mailto:aaron@aarongough.com] Copyright (c) 2010 {Aaron Gough}[http://thingsaaronmade.com/] ({thingsaaronmade.com}[http://thingsaaronmade.com/]), released under the MIT license