Cake - the programming language.
Cake is a minimalistic, dynamically typed, imperative language with lexical
scope and nested, higher order functions.
It is garbage collected and can
be used in a protoype-based object oriented programming style.
The primary design rule of Cake was simplicity - both in language
features and implementation.
I wrote Cake simply because I wanted to learn how to write a compiler
and runtime system, and play around with
some language ideas. In its current state (0.1.1) it would probably be unwise to use in a production system...
The compiler generates C code from the Cake source. It is intended that
the generated C code be understandable to humans.
The compiler itself is very minimal and doesn't make any attempt at optimisation.
Most of the 'intelligence' is shunted off to the runtime system.
If the code
is syntactically correct, the compiler will build a syntax tree. C output
code is then generated directly from the syntax tree.
The generated C code must then be compiled and linked with
which provides the runtime system and API.
The Runtime System
The runtime system is responsible for
- mapping of names to slots (variables and functions)
- managing lexical scope
- choosing the right operator for each type
- memory management, garbage collection
Each time a function is entered, the runtime system creates a dictionary
to hold its scope. All variables (generally known as 'slots' in cake) defined
inside that scope are stored in the dictionary. Slot names are searched
for first in the current scope, and then in any parent scopes, until a match
Because Cake supports higher order functions, it cannot simply discard
the scope when the function returns. Instead it is left up to the garbage
collector to dispose of. As you can imaginine, this isn't very efficient...
The garbage collector must be run explicitly by calling the
The API provided with this version of cake is *very* minimal.
The 'core' api of cake consists of some functions for creating, cloning,
getting the size, and listing the keys of dictionaries; testing the type of
a variable, some print() and readln() functions, and a
These all live in
If you were to use Cake as an scripting or extension language you would
need to add your own application specific functions and objects to
This should be reasonably straightforward if you follow the examples in
Builds on linux but will require Makefile tweaking,
at the very least, to work with your setup
Cake is free software, and can be used for any purpose subject to the
terms of this very laid-back licence.
Justin Armstrong <ja at badpint.org>
Last updated Thu Jun 27 21:49:04 IST 2002