The Programming Language Fan
Fan is a full blow programming language, it’s a superset of ocaml with Lisp-like macro’s features. It shares the same run-time with ocaml, so it’s 100% compatible with ocaml.
Why a new Programming Language?
We see that a lot of computer scientists are creating languages to target their domain, but creating a language is itself a domain, Fan is targeted at this domain. Yes, Fan is targeted to compiler domains. Fan aims to make creating a language easier.
There are some projects like Microsoft’s Rosyln which aims to make “Compiler as service”, but unlike Rosyln, we do not only expose the compiler API, but also we provide built-in language support to make those API easier to use instead, since for any non-trivial languages, the API is quite complex that average programmers will be frustrated ans move away.
Unfortunately, though Camlp4 is a very powerful tool to program OCaml Ast and Extending OCaml language, Camlp4 is a really complex beast, that lately it grows out of control. Fan adopts some good ideas of Camlp4 and merges some new ideas.
Fan is way more faster than Camlp4, generally 100 times faster! and Fan has a very robust bootstrapping system compared with Camlp4.
Fan has all the features that Camlp4 has, and much more!
Designing a non-toy language is not easy, though Fan is already very powerful right now, but I have a bunch of ideas which take some time to implement, so it’s not usable now(mostly because some API is unstable ).
Feel free to send me a pull request
Currently we depend on
ocamlfind, but the
dependency is quite loose, we will remove the dependency on them
What it mainly did
It will make
cold/Fan.bytefrom original syntax This is mainly for the cold start(compile from the original syntax code). Actually all work is done.
Using the generated binary to preprocess the revised syntax to verify
Fanreaches a fix point now.
If it reaches fix point, then it succeeds. You can also test
Fan.native for fun!
Everytime, you made some nontrival changes(change the grammar,
lexer), make sure to type
./hb Fan.byte or
./hb Fan.native to
verify it can be hot-bootstrapped.
./snapshot to snapshot your changes to cold.(This is for
If there’s no bugs in
src/Pprintast.ml, then it will work smoothly
The main dev strcuture
The mirror of src, for distribute purpose
the common practice is
./hb Fan.byte # verify ./snapshot # snapshot and verify again
It will be coming soon ;-)