We came to conclusion that no matter how perfect your libraries are, the comfort and ease come mostly from development tools. Everything got started when Vladimir Kirillov decided to replace Rusty’s sync beam reloader. As you know sync uses filesystem polling which is neither energy-efficient nor elegant. Also sync is only able to recompile separate modules, while common use-case in N2O is to recompile DTL templates and LESS/SCSS stylesheets. That is why we need to recompile the whole project. That’s the story how active emerged. Under the hood active is a client subscriber of fs library, native filesystem listener for Linux, Windows and Mac.
De-facto standard in Erlang world is rebar. We love rebar interface despite its implementation. First we plugged rebar into active and then decided to drop its support, it was slow, especially in cold recompilation. Rebar was designed to be a stand-alone tool, so it has some glitches while using as embedded library. Later we switched to Makefile-based build tool otp.mk.
The idea to build rebar replacement was up in the air for a long time. The best minimal approach was picked up by Sina Samavati, who implemented the first prototype called ’mad’. Initially mad was able to compile DTL templates, YECC files, escript (like bundled in gproc), and it also had support for caching with side-effects.
We were trying to make something minimalistic that fits out Web Stack. Besides we wanted to use our knowledge of other build tools like lein, sbt etc. Also for sure we tried sinan, ebt, Makefile-based scripts.
Synrc mad has a simple interface as follows:
It seems to us more natural, you can specify random command sets with different specifiers (options).
The key feature of mad is ability to create single-file bundled web sites. Thus making dream to boot simpler than Node.js come true. This target escript is ready for run on Windows, Linux and Mac.
To make this possible we implemented a zip filesytem inside escript. mad packages priv directories along with ebin and configs. You can redefine each file in zip fs inside target escript by creating the copy with the same path locally near escript. After launch all files are copied to ETS. N2O also comes with custom cowboy static handler that is able to read static files from this cached ETS filesystem. Also bundles are compatible with active online realoading and recompilation.
mad also comes with N2O templates. So you can bootstrap an N2O-based site just having a single copy of mad binary.
After that you can just run escript web_app under Windows, Linux and Mac and open http://localhost:8000.
mad is also supposed to be a deploy tool with ability to deploy not only to our resources like Erlang on Xen, Voxoz (LXC/Xen) but also to Heroku and others.
mad supports rebar umbrella project structure. Specifically two kinds of directory layouts:
As you may know, you can create OTP releases with reltool (rebar generate) or systools (relx). mad currently creates releases with relx but is going to do it independently soon. Now it can only order applications.
And the good part about mad is it’s size: