In January I posted that I was diving into Linux full-time for my Erlang work. Erlang itself runs great on Windows, Linux and Mac. I made the shift because most Erlang developers work in Linux and I felt I was probably missing something with my Windows-centric approach. This turned out to be a very valuable exercise. I tried out ErlIDE (Eclipse), a tricked out gedit, Vim, and Emacs. In the end, the best-paved and most productive path for Erlang development appears to be Emacs tricked-out with Erlang goodies and a console standing by for running Rebar and Git commands.
Here’s what my Erlang rig consists of:
- Emacs 23.3
- Erlang mode : Provides syntax highlighting,
- Flymake: shows warnings and errors on the fly as you type like visual studio
- IDO: Adds a good way to browse directories and open files
- color-theme: adds pretty colors and fonts
- Distel: theoretically provides auto-completion, step through debugging and other goodies.
- Key mappings: Adds the key bindings for Cut,Copy,Paste,Alt-F4, Ctrl-Tab that a red-blooded Windows expects.
A few months in, I realized all of these things should work just fine on Windows. Today I have the same Erlang development rig on both Windows and Linux. This makes me very happy. Why? I’ve mentioned this in previous posts, but I believe C# and Erlang are great complements. Even in a Windows-only .NET shop with no appetite for introducing Linux, there’s no reason to take Erlang off the table. Having a proper Windows tool-chain for Erlang development moves the discussion away from an OS holy war and back to a cost-benefit analysis of Erlang itself. That’s a good place to be.
Each time I’ve done my “Intro to Erlang for C# Developers” talk, folks see my Windows Emacs rig in action and ask “What’s involved in getting that to work?” For anyone who is interested here are the steps:
Get Erlang R14B03
- Download Erlang from here.
- Run the otp_win32_R14B03.exe setup file. By default the installer wants to put Erlang here “C:\Program Files\erl5.8.4″ but change that to “C:\erlang\erl5.8.4\”. OK, but why? Most of the tools and scripts you will use for Erlang development on Windows were crafted over on Linux and the authors may not have tested for spaces in the path (e.g. “Program Files”). Remove that risk.
- Add “C:\erlang\erl5.8.4\bin” to your PATH.
Get Emacs 23.3
- Download Emacs 23.3 from here.
- Right click the zip and “Unblock” it.
- Extract it to a sensible location such as “C:\utility\emacs-23.3″. Again avoid spaces in the path to avoid unnecessary pain.
- Add “C:\utility\emacs-23.3\bin” to your PATH.
- Add an environment variable named “HOME” and give it the value of your home directory (for me this is “C:\Users\bryanhunter”)
- Run Emacs. When it loads it should have a white background, a homely font, and the most hideous splash screen you’ve ever seen.
- Close Emacs.
Pull down my Emacs configuration files [updated 8/27/2011]
- Visit my GitHub repository named ErlangRigEmacsConfig
- Read the readme file
- Download the zip of the repository. This repository contains the “.el” (Emacs Lisp) files that turn plain old Emacs into something pretty nice for Erlang development.
- Right click the zip and unblock it
- Extract it into your home directory (for me this is “C:\Users\bryanhunter”). Note: this needs to match what you put in the HOME environment variable under the Emacs steps.
- Edit your “~/.emacs” file to something like this:
If all went well, when you open Emacs it will show a nice black background screen. If you (or I) missed something, you will see the hideous default Emacs splash screen.
Extra credit #1: Use a prettier font
- Download the lovely “DejaVu” font family from here.
- Unblock the zip and extract it somewhere.
- Open up the “dejavu-fonts-ttf-2.33\ttf\” directory.
- Select all the TTF files and drag them into your “C:\Windows\Fonts” directory.
- Open the “my-config.el” file (it’s in your fancy new Emacs configuration directory).
- Find the line that reads “:family “Consolas”" and replace “Consolas” with “DejaVu Sans”.
- Open the “my-config.el” file (it’s in your shiny new Emacs configuration directory).
- Read it top-to-bottom.
- Tinker, save your changes, reload Emacs.
- Read the “Programming in Emacs Lisp” guide (here) to get smarter.
- GOTO 3
[Note: this post will be in flux until it is correct and complete. Please comment to help me get it there.]