Samuel Williams Thursday, 14 October 2010

Kai (会 in Japanese) is an experimental interpreter that provides a highly extensible runtime environment and explicit control over the compilation process.

Programs are defined using nested symbolic expressions, which are all parsed into first-class values with minimal intrinsic semantics. Kai can generate optimised code at run-time (using Low Level Virtual Machine) in order to exploit the nature of the underlying hardware and to integrate with external software libraries. It is a unique exploration into world of dynamic code compilation, and the interaction between high level and low level semantics.

# Create a function to calculate greatest common divisor
[(this) set `gcd
	# It takes two arguments a and b,
	(lambda (list a b) `{
		(if [b == 0]
			(return a)
			(return (gcd b [a % b]))
		)
	})
]

You can try the online demo. Source code is available at GitHub.

The Moment of Kai

The Japanese character 会 generally translates into 'meeting'. There are many ways in which this is significant. In this particular instance its usage can be considered in terms of 弓道, which roughly translates into 'Way of the Bow' (Archery). The highest goals in 弓道 are truth 真, goodness 善 and beauty 美. Truth is the pursuit of the correct technique and to grasp the truth of things; Goodness represents inner calm and balance; beauty is to maintain a clear structure and composition. There are many formal steps in 弓道; Kai 会 is the moment before the arrow is released, when the energy of the bow and the body of the archer are in balance.

Goals

Further Reading

I developed Kai over several years to learn more about computer programming. Thanks to Tadao Takaoka for his supervision and support.

Comments

Leave a comment

Please note, comments must be formatted using Markdown. Links can be enclosed in angle brackets, e.g. <www.codeotaku.com>.