Fantom

Login | Register

Three year history of Fan Blog

brian
2 Sep 2008

Today is a good day for my inaugural blog entry, because three years ago today on 2 Sept 2005 I started coding up Fan. The first bit of code was the original compiler written in Java.

In 1996 I was one of the founders of a company called Tridium. We built a Java framework for various markets including building automation, industrial automation, telematics, medical devices, aerospace, etc - basically anything that required smart networked devices. Recently this space has been coined M2M or Machine-to-Machine. At Tridium we used Java to build all of our technology, but over and over again we'd run into potential customers and OEMs who were Microsoft shops. Often this meant that they just weren't interested in Java technology. Even if they were, they were stuck with a huge legacy of .NET code which didn't play well with Java. Sometimes you can get away integration via a wire protocol, but that doesn't work for UIs or embedded devices.

In the summer of 2005, it became clear that Honeywell was going to acquire Tridium (which they did in November). I'm not really cutout for big companies, so I knew I'd be moving on eventually and started thinking about what the future might hold. My first order of business was that I wasn't going to pick the Java camp over the .NET camp (or any other camp). I didn't want to be developing technology that was tied to a particular platform, so the idea of Fan was born. Also having spent a decade debugging nasty race conditions and dead-locks that only occur on customer sites, I really wanted to move to saner concurrency model.

Its always hard to start a project without a name, so I picked "Fan" which is the neighboorhood where I live and because it was short. That was not intended to be the final name. But when I filled in my brother Andy on the project, he thought we should just stick with Fan. It certainly isn't the best of names, and sucks for Googling - but it is what it is. Sidewalk, the project name we gave to the discussion group running fandev.org, is a pub in the Fan where I spent many a night in my premarital days.

So from the very beginning Fan was trying to solve portability between Java and .NET. The first few months of a project like Fan are always really interesting, because you really don't have a clue what you are doing. The original design was more akin to multiple embedded languages. Here is a snippet of what Str looked like in Nov 2005:

/// Str is the built-in type used to store a sequence of Unicode characters.
class Str
  jalias: java.lang.String
  nalias: System.String
{  
  /// Get the length of the string
  int size()
    jalias: length();
    nalias: get_Length();

At the start I was attempting to avoid boxing objects like Str with a Fan wrapper - instead Fan types were aliased to the Java/.NET counterparts and we had direct support for primitives. There were also jblock and nblock constructs for embedding platform specific code. In Dec 2005 two big things happened. We launched fandev.org, originally written by Andy in PHP, to start tracking discussions (although we kept it to ourselves). The other big change was that I reworked the code to use the pure OO type system in place today - everything was boxed in a Fan specific wrapper including numbers. Getting rid of primitives and aliased classes drastically simplified of the compiler - although it was probably the hardest decision I've made in Fan due to the performance tradeoff.

In early 2006, the compiler had two back-ends: one for Java bytecode and another for .NET IL. In order to make this work, the compiler itself was written in Java such that we could use J# to run inside .NET and access their emit APIs. But there was a couple problems. This approach required shipping a Fan module in two formats: as Java bytecode and as a .NET assembly. So although we got source portability, we didn't have deployment portability. Also tying ourselves to J# for .NET support didn't seem like a very safe move. So in Feb 2006, I undertook a major redesign to use intermediary fcode. The compiler backend was rewritten to generate fcode and pod files. I refactored the Java runtime to load fcode and emit bytecode at runtime. Andy started rewriting the .NET runtime in C#. So by the spring of 2006, the architecture was pretty much as you see it today.

My main goal for spring and summer of 2006 was to implement the language features needed to rewrite the compiler in Fan itself. At this point the bootstrap compiler was still written in Java, and any compiler code I wrote was wasted work because I would have to do it again. In July of 2006 I started rewriting the compiler in Fan itself and by Aug I could do basic compiling end-to-end from source to fcode. By Oct 2006 the compiler could compile itself - a pretty monumental milestone. By the end of the year, I had a simple Fan script build system and development had switched over to the Fan version of the compiler.

From 2007 onward, Andy and I were shooting for a milestone we called Thompson (named after the western most street in the Fan area). Thompson had two main objectives: getting .NET to run the full test suite and getting fandev.org up and running using Fan. We wanted enough documentation and functionality that newcomers could actually play around with Fan rather than coming to the site and finding vaporware.

It took well over a year to get the language and runtime mature enough to deploy a production site like fandev.org. In April 2008, we finally reached the Thompson milestone, and posted publically in a couple places. Since then a fledgling community has started participating in various Fan language debates which have been remarkably of a very high caliber.

And that is the not so brief of history of how we got to where we are today.

JohnDG
4 Sep 2008

Thanks for the history. Quite an interesting read. Should be immortalized somewhere in the Fan documentation.

curtcox
16 Nov 2008

Can you tell us how fan development is funded?

brian
16 Nov 2008

Can you tell us how fan development is funded?

Like many open source projects, what you see today is the result of work done in our spare time. So there hasn't been any explicit funding. Things will be shaking up in a couple weeks, and we'll start to work on Fan more or less full-time. I'll be blogging about that in Dec.

Login or Register to Reply

Back | All Topics