Installing and compiling Elixir and the Dynamo web framework on Windows
People following me on twitter noticed I got entangled in yet another new language for the Erlang/BEAM VM:
Elixir could be easily described as "ruby for the BEAM/Erlang VM". In previous posts, I mentioned why people should learn Erlang, but in fact, I think most people might be better off when they skip Erlang and opt directly for Elixir. It has all the advantages of Erlang, but offers a Ruby-like syntax, macros, polymorphism and more.
As someone else made a perfect blog post on why you should learn Elixir, I will not elaborate further on it in this post. Read his post; the info is all there.
As usual, you can find more info about Elixir on Wikipedia , or on the Elixir site.
In this post, I will show you how to get started with Elixir and generate a template website using the Dynamo web framework.
Installing Elixir is simple, but because one of the Dynamo web framework dependencies requires the make tool, you need to do some extra work. If anybody finds a better/simpler way to do this, please let me know in the comments.
In order to get started with Elixir on windows, you need several apps installed:
- git: I use msysgit (installed with Chocolatey: cinst git.install)
- erlang: You need at least Erlang R16B, so you can not use chocolatey here.
- Elixir: you need a precompiled package that is not realeased yet, 0.9.1 crashes on windows, but José Valim quickly built a hotfix - Thanks José !-. Older versions will not work on Windows. You can download it here; I unzipped it in "c:\program files\elixir".
- Minimal system from Minimalist GNU for Windows (also installed with Chocolatey: cinst mingw ) - make sure you install the mingw developer toolkit - see screenshot:
Next you need to make sure that "erlang/bin", "elixir/bin" and "MinGW\bin" are in your path, and we will verify that everything works; we will also need to copy the file "c:\mingw\bin\mingw32-make.exe" to "c:\mingw\bin\make.exe". Next we can test whether everything works:
Getting and building the web framework for Elixir: Dynamo
Dynamo is a web framework tailored specificly to the Elixir language. As it is written on top of the Erlang Cowboy/Ranch stack, it uses proven technology to accelerate web development.
It might be nice to know that José Valim (the creator of the Elixir language and the Dynamo web framework) is one of the main contributors to the Ruby On Rails engine, so you can assume he knows a thing or two about web frameworks.
Anyway, enough background; let us get started with the installation...
First we need to clone the dynamo repo(which is a web framework that has a workflow comparable to Ruby on Rails) and build it. You can get it using the following command: "git clone https://github.com/elixir-lang/dynamo.git".
Because building the dependency Cowboy requires the make.exe tool (the reason we needed to install MinGW MSys), we need to do this in an msys shell. You can find the msys shell under "c:\mingw\msys\1.0\msys.bat".
Open up the shell, clone the repo and get/build the dependencies from dynamo using the mix tool : "mix deps.get".
You will get an error in the end, but that is not really a problem; the compilation should be succesful. Now you need to compile the dynamo app: "mix compile"
Generate a web app with dynamo: blah
You can now test whether dynamo works. You can now use dynamo to generate a web app: "mix dynamo [path of app]"
This has created a web-app in the blah folder. We go to the blah folder, and run once again "mix deps.get" and "mix compile". Then we should be able to start the server by typing "mix server".
Open up a browser on https://localhost:4000 and you can see the labor of your work.
Now you can start working on your app, but that is the subject for another blog post. You can find more information about the dynamo web framework here.
Happy Elixiring !