• This repository has been archived on 02/Dec/2020
  • Stars
    star
    242
  • Rank 167,048 (Top 4 %)
  • Language
    C++
  • License
    Other
  • Created over 14 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The Finch programming language

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:

  • Syntactically expressive yet minimal. Your code should look beautiful and do what you want.

  • An example of a small, clean C++ codebase for an interpreter. If you can read C++ and want to learn more about programming languages, I hope Finch's code will be a good primer.

  • A language in the Smalltalk family that's friendly to people coming from a text file and curly brace background.

  • A minimal prototype-based dynamic language. I think prototypes are a really cool paradigm, but Self goes too far, and Javascript doesn't go far enough.

  • Easily embeddable in other applications. I don't know if Finch ever will have real use, but if it does, it will likely be as a configuration or scripting language within a larger application, much like Lua.

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 an object and put it in a variable "dragon"
dragon <- [
  // define a "trace:" method for outputting the series of left and
  // right turns needed to draw a dragon curve.
  trace: depth {
    self traceDepth: depth turn: "R"
    writeLine: "" // end the line
  }

  // the main recursive method
  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

Getting Started

Finch lives on github here: https://github.com/munificent/finch

To play around with it, sync it down. Finch uses GYP to generate projects or makefiles for your platform, which you then build to get an executable.

  1. Download GYP from: http://code.google.com/p/gyp/
  2. Clone the finch repo from github.
  3. In a terminal/command prompt, navigate to the root finch/ directory.
  4. Run GYP on this file: <path to gyp>/gyp --depth=1 Where <path to gyp> is wherever you downloaded GYP to in step 1. This should spit out a project/makefile in the root directory for your platform.
  5. Open that project in XCode or VS and build, or build the makefile.
  6. Ta-da! You should now have a Finch executable under a build/ directory.

Let me know if you run into any problems.

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 right now (lame!). You can run the tests like this:

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

Where to Go from Here

You should be good to start hacking some Finch code now. There is some documentation here:

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

More Repositories

1

craftinginterpreters

Repository for the book "Crafting Interpreters"
HTML
8,949
star
2

game-programming-patterns

Source repo for the book
HTML
4,134
star
3

vigil

Vigil, the eternal morally vigilant programming language
Python
2,900
star
4

hauberk

A web-based roguelike written in Dart.
Dart
2,009
star
5

mark-sweep

A simple mark-sweep garbage collector in C
C
722
star
6

magpie

The Magpie programming language
Python
360
star
7

bantam

A simple demo app for Pratt parsing
Java
312
star
8

jasic

A complete interpreter for a dialect of BASIC in one Java sourcefile
Java
150
star
9

rooms-and-mazes

Animated demo code for a random dungeon generator
Dart
137
star
10

ui-as-code

Design work on improving Dart's syntax for UI code
Dart
121
star
11

amaranth

An open source roguelike written in C#
C#
120
star
12

journal

My blog, in all its statically-generated glory.
HTML
101
star
13

malison

A little terminal emulation package for Dart.
Dart
74
star
14

lark

The Lark programming language.
Java
59
star
15

piecemeal

Basic data structures your 2D Dart game may need.
Dart
52
star
16

wrenalyzer

Static analyzer for the Wren programming language
44
star
17

lisp2-gc

A simple implementation of the LISP2 mark-compact GC algorithm
C
38
star
18

malison-dotnet

A terminal emulation library in C#
C#
36
star
19

a-turn-based-game-loop

Demo code for http://journal.stuffwithstuff.com/2014/07/15/a-turn-based-game-loop/
Dart
28
star
20

markymark

A tiny static web server for previewing Markdown files
Dart
25
star
21

fov

Demo code for a blog post about field-of-view calculation
Dart
21
star
22

bulfinch

Just a little toy language to learn about register-based VMs.
Java
20
star
23

pattern_matching

A simple ML-like pattern-matching library in C#.
C#
18
star
24

bramble-dotnet

A set of utility classes and extension methods in C#
C#
17
star
25

bits

Tiny web page for converting between binary, decimal, hex and UTF-8
HTML
9
star
26

dep-external-libraries

Proposal for handling platform-specific code in Dart
Dart
8
star
27

temp_primary_constructors

Temporary repo for trying out a proposed Dart language feature
Dart
7
star
28

wren-sublime

A Sublime Package for the Wren programming language
6
star
29

multipleinheritance.js

A little hack to get multiple inheritance working in JavaScript.
JavaScript
6
star
30

settings

My personal settings, configurations, and dotfiles.
Shell
5
star
31

wren-atom

Atom package for Wren
CoffeeScript
4
star
32

linkedlist

Reversing a linked list
Go
4
star
33

magpie-csharp

The old C#-based Magpie programming language
C#
3
star
34

magpie-optionally-typed

The old single-dispatch optionally-typed flavor of the Magpie programming language.
C#
3
star
35

temp-flutter-examples

Temporary repo looking at some Flutter examples
Dart
2
star
36

dep-interface-libraries

DEP for configuration-specific code in Dart
2
star
37

gallery-constructors

Temporary repo to test out some potential changes around constructors in Dart
Dart
1
star
38

format-flutter

Temporary repo to apply an experimental dart format style to Flutter.
Dart
1
star
39

module_scrape

Temporary code for investigating a module system for Dart
Dart
1
star
40

temp_flutter_format

Temporary repo to experiment with some formatting styles in the Flutter repo
Dart
1
star
41

support

My personal repository for support files: things like color schemes, preferences, and other settings files that it's handy to have centrally accessible.
1
star