#2249 Fantom's Architecture and Design

Hertz Sun 30 Mar 2014

Hi,

I am really enjoying the Fantom language and I think it is something that is really going to change the way people write software. I know Fantom is still in its early stages. I was wondering if their was a document that I could use to learn more about Fantom Language Architecture ( Like a language spec ). Also maybe a document that explains Fantom's Compiler Design and Architecture and How it works? Thanks.

brian Mon 31 Mar 2014

Hi Hertz,

Welcome to Fantom - hope you enjoy programming in it!

There isn't really a formal language spec per se, but the docLang does specify how each feature works.

The compiler is designed as a pipeline which makes the code pretty easy to read. Start with Compiler.frontend/backend methods and you will see its just a series of steps. Then if you look at the specific step classes the header tells you exactly what transformations occur in that step. I'd be happy to answer to questions you have.

Hertz Mon 31 Mar 2014

Im confused,

So does the compiled fcode is what gets inputed into the JVM or does that fcode get converted into Java bytecode?

SlimerDude Tue 1 Apr 2014

The fcode is converted into Java bytecode.

brian Tue 1 Apr 2014

The Deployment chapter and diagram shows how it works.

The compiler generates an intermediate format called fcode which is a bit higher level than Javabyte, but similar in that is a stack based bytecode. This is essentially the purpose of the compiler pod.

The Java runtime then compiles the fcode into bytecode at runtime. That design has the nice advantage that mixins don't suffer from the fragile base class problem. This code is in sys.jar under the fanx.fcode and fanx.emit package.

The JavaScript compiler is a bit different though. It compiles straight from Fantom source to JS source.

Login or Signup to reply.