Finch: Welcome

Welcome | Expressions

Welcome and thanks for coming. You're here because, for some reason, you're interested in Finch, a little programming language of mine. Finch is still very early in development so the only people likely to be interested in it are language nerds. Thus, the docs here will tend to assume you're one of those.

What is Finch?

Finch is a simple bytecode interpreted, purely object-oriented, prototype-based, dynamically-typed programming language. It's mostly inspired by Smalltalk, Self, and Javascript.

It is written in C++ with a hand-written lexer and parser. It has minimal dependencies. I want Finch to be:

A Taste of the Language

Here's a little example to get you going. This little program doesn't draw, but it will tell you what turns to make to draw a dragon curve:

' create a single global Dragon object
Dragon <- Object copy

' add a main "trace:" method for outputting the series of left and right 
' turns needed to draw a dragon curve.
Dragon :: trace: depth {
  self traceDepth: depth turn: "R"
  writeLine: "" ' end the line
}

' add the main recursive method
Dragon :: traceDepth: n turn: turn {
  if: n > 0 then: {
    self traceDepth: n - 1 turn: "R"
    write: turn
    self traceDepth: n - 1 turn: "L"
  }
}

' now lets try it
Dragon trace: 5

This doesn't really give you the OOP flavor of the language, but it gives you the idea of the general look.

Getting Started

Finch lives on bitbucket here: http://bitbucket.org/munificent/finch

To play around with it, sync it down. There is both an XCode project and a makefile. Use whichever you prefer. I don't have anything set up for Windows yet, but I'm keen if someone wants to throw a VS solution at me.

Building on Mac OS X with XCode

I mostly work on it in XCode. If you like that, here's how to get going:

  1. Open the XCode project at: src/finch.xcodeproject
  2. Build and run. Ta-da!

Building with make

Thanks to Steve Folta, there is also a makefile for *nix users:

  1. cd to the root finch directory.
  2. make
  3. ./finch

Running Finch

Once you've got it built and running, you'll be at the main interpreter prompt. Finch is a command-line app. If you run it without any arguments, it drops you into a REPL, an interactive session. You can type in chunks of code and it will interpret them immediately. (If you run it with a single argument, it expects that to be a path to a .fin script, and it will load and run that script.)

Once you're in the REPL, you can load and execute a script using load:. The path must be relative to where the executable is. If you've built from XCode, you can run the tests like this:

>> load: "../../test/test.fin"

If you built from a makefile, it's:

>> load: "test/test.fin"

Where to Go from Here

You should be good to start hacking some Finch code now. The other docs here can help get you started. The sample scripts and the tests will give you some ideas, along with the Finch-related posts on my blog.

If you have any questions or comments, holler at me.