Skip to content
An implementation of the Logo (turtle graphics) language in ocaml
OCaml JavaScript HTML Makefile Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

A Logo Interperter in Ocaml (and Javascript)

A tree created in Logo

Try the interperter in your browser


See this page for sample programs and their graphical output.


The following directions describe how to install the dependencies for running the code locally.

Install OCAML

Use the Real World OCAML installation instructions

On Linux

$ sudo add-apt-repository ppa:avsm/ppa
$ sudo apt-get update
$ sudo apt-get install curl build-essential m4 ocaml opam

Then do

opam init
eval `opam config env`

On Mac

Install Homebrew

brew install ocaml
brew install opam

Then do

opam init
eval `opam config env`

Install ocamlfind

opam install ocamlfind

Install the Cairo Ocaml bindings

opam install cairo2

Install Dependencies

opam install core
opam install menhir
opam install lwt

Install js_of_ocaml

opam install js_of_ocaml
opam install js_of_ocaml-camlp4

Building the Logo Interperter

There are two different builds of the interperter:

  • A interpreter that runs from the command-line and uses Cairo as backend to output .png files from Logo programs

  • A interpreter that runs from Javascript and uses a Canvas backend to output graphics from Logo programs in the browser

Building the Command-line Interpreter

Issuing the following command to build both.


will build and run a program called logo.native. It creates a file named tree.png that should contain a tree.

To clean up do

make clean

Building the Javascript Interpreter

Issuing the following command

make logoweb.js

will build a Javascript library containing the interpreter. The file index.html shows how this library may be used from Javascript via the interpetLOGO command.

Logo Grammar

I made my own up. But there is one here

You can’t perform that action at this time.