Implementation of a Functional Programming Language Jason Koenig Computer Systems Lab TJHSST 2009-2010
Introduction Creation of a functional language Both design and implementation Working Parsing Simple Optimization Execution Ordered Evaluation Todo: Optimizations
What is a Functional Language? Two approaches: Imperative – like a recipe, or a how to. Declarative – like a mathematical formula. Functions are first class citizens Functions are like data
Design Goals Small and lightweight Core language highly portable Other functionality in standard library Easily embedded in other programs as scripting language Driven by implementation, rather than some external metric
Implementation File, Input Optimizer Executor Parser Program Output Characters Optimized Syntax Tree Lexical Analysis Syntax Tree Executor Tokens Characters Parser Program Output
Sample Programs let x = 5, y = 6 in x+y # out: 11 let in head.[x,y] # out: 25
Future Work Recursion G-machine compilation Language Tail Recursion G-machine compilation Language Standard Library Implementation: C for speed