Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Let's first start with a few corrections:</p> <ul> <li>It's not a Java compiler, it's a compiler for a small <em>subset</em> of Java.</li> <li>It doesn't say anywhere that the compiler will be <em>written</em> in the time, only that it will be <em>explained</em>.</li> <li>In fact, it doesn't even say that, it says, it will be <em>presented</em>. Heck, I can present GCC in 3 minutes. It's not gonna be a very <em>useful</em> presentation, but it's gonna be a presentation.</li> </ul> <p>That said, explaining a well-structured, simple compiler for a simple language implemented in a language which is well-suited for writing compilers within an hour is definitely feasible.</p> <p>F# is a member of the ML family of languages (specifically, a close cousin of OCaml), and those are indeed well-suited for writing compilers. In fact, the <em>reason</em> why Robin Milner chose the name ML (meta language) for his language, was because it is <em>specifically designed</em> for writing compilers. A compiler is basically a big function (thus making it very natural to implement in a functional language) that detects patterns (thus making it very natural to implement in a language with pattern matching) and executes a little bit of code for each pattern it detects (thus making it very natural to implement in a language with first-class functions). And whaddayaknow? F# is a functional language with very sophisticated pattern matching facilities. Another nice feature is an expressive type system with algebraic data types and discriminated unions which makes it very easy to represent Abstract Syntax Trees.</p> <p>At the Lang.NET Symposium Jason Olson gave <a href="http://LangNETSymposium.Com/2009/talks/24-JasonOlson-FSharp.html" rel="noreferrer">a talk on F#</a>, during which he showed some pieces of an interpreter that he is currently working on that demonstrate these features very well.</p> <p>Fredrik Holmström is currently working on <a href="http://IronJS.Com/" rel="noreferrer">IronJS</a>, an ECMAScript 3 implementation for the Dynamic Language Runtime. Take a look at the <a href="https://GitHub.Com/FHolm/IronJS/" rel="noreferrer">code</a>, specifically the <a href="https://GitHub.Com/FHolm/IronJS/blob/master/Src/IronJS/Ast.Types.fs" rel="noreferrer">AST types</a> and some of the <a href="https://GitHub.Com/FHolm/IronJS/blob/master/Src/IronJS/Ast.Analyzer.fs" rel="noreferrer">analysis</a> and <a href="https://GitHub.Com/FHolm/IronJS/blob/master/Src/IronJS/Ast.fs" rel="noreferrer">parsing</a> code.</p> <p><a href="http://Jonathan.Tang.Name/files/scheme_in_48/tutorial/overview.html" rel="noreferrer">Jonathan Tang's Write Yourself a Scheme in 48 Hours</a> is another good example of writing an interpreter, this time in Haskell which shares many features with F#.</p> <p><a href="http://WWW.IRO.UMontreal.Ca/~boucherd/mslug/meetings/20041020/minutes-en" rel="noreferrer">The 90 Minute Scheme to C compiler by Marc Feeley</a> is a presentation about a Scheme compiler written in Scheme.</p> <p>In <a href="http://SkillsMatter.Com/podcast/ajax-ria/implementing-scheme-in-ruby/" rel="noreferrer">Implementing Scheme in Ruby</a>, James Coglan teaches the audience Scheme, live-codes and explains a Scheme interpreter in Ruby and writes a couple of sample Scheme programs, all in 15 minutes.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload