Saturday, 27 July 2013

Erlang Dev Environment

I have started a tutorial on how to setup a professional development environment for erlang coding.  The github page below has better formatting.

https://gist.github.com/andytill/6094931

Erlang Dev Environment

This tutorial is aimed at a Windows user looking to start with erlang, it will help you set up an effective development environment, without proper tooling erlang seems underpowered. After all you wouldn't write java code in notepad.

Install Ubuntu on VirtualBox

Save yourself some time early on and just use linux for erlang development. Erlang does work on windows but most testing of the SDK, open source libraries and tools gets done on linux so things just seem to go more smoothly in this environment.

Download VirtualBox and a supported version of Ubuntu. Install VirtualBox and create a new virtual machine using the Ubuntu ISO.

Install VirtualBox guest additions

Guest additons lets you full screen the virtualised Ubuntu and have it use shortcuts that currently get handled by windows like alt+tab. Click the Devices->Install Guest Additions VirtualBox menu. Once restarted the full screen and seamless menu itens should be enabled.

Install some tools

Just some tools no one should be without.

sudo apt-get install git vim htop

Making VirtualBox fly

Your VBox might still be slow. Try running htop from the terminal, if it only has one CPU bar then you may need to enable virtualisation in your BIOS, which is pretty easy. The tutorial here. Once that's done, add more cores in the VBox system CPU settings.

Install Erlang

Install erlang using the following command from askubuntu...

sudo apt-get install erlang erlang-doc

This may install an old version but it's super quick and will get you up and running. Check that the install was successful...

erl

Install rebar

rebar is the maven of the erlang world, it can handle dependencies and standardises projects.

cd /usr/bin
wget https://github.com/rebar/rebar/wiki/rebar

The rebar command is now on your path, try testing it from your home directory...

cd ~
rebar

Installing Gnome 3

Ubuntu defaults to the Unity interface. While I quite liked the aesthetics and the usability wasn't a problem I couldn't get hardware acceleration to work, this made the interface extremely slow and the text quite blurry. Instead use Gnome 3, text is crisp and the UI is relatively snappy. Once installed using the instructions below, remember to enable 3D acceleration in the VirtualBox settings...

http://www.filiwiese.com/installing-gnome-on-ubuntu-12-04-precise-pangolin/

Install sublime text 2

There is patchy support (my opinion only) in IDEs for erlang so don't expect anything like JDT tooling, although we can still use powerful tools. sublime text is just one editor with plugins to support erlang.

Installing-Sublime-Text-2-on-Linux

SublimErl

SublimErl is the sublime text plugin for erlang, have a look at the project page for the feature list.

In sublime text click on the Preferenced->Browse Packages menu, this opens up a file explorer window. Right click on the Pacages button and copy the path, then in a terminal type cd , paste the path and press enter. Then use the following command...

git clone https://github.com/ostinelli/SublimErl.git

sublime text will automatically find this new plugin. There are a few things to remember when using SublimErl...

  • It only handles projects in the rebar format. In sublime text the project is the directory in the left hand pane, add a directory using the menu Project->Add Folder to Project...
  • SublimErl looks for an ebin directory or rebar.config file to identify the root dir of the project so make sure to call rebar compile in the project so it can be identified.
  • sublime text 2 packages are not like eclipse plugins, they are entirely hackable. If you are curious, open the python code for the plugin and put some print "Hello World" statements in there, sublime text will see the change instantly and hot-load the new code. You can see the output in the console, look for console in the cammand palette ctrl+shift+P.

Saturday, 30 March 2013

South Park Software License


If you have ever watched the show South Park then you will have probably read the disclaimer that is flashed at the start.  Here is my software license tribute:

All specifications and documentation for
this software--even those required for
customer sign off--are entirely fictional.
All code is tested... poorly.
The following program contains leaky
abstractions and should not be reused by anyone.
view raw SPL hosted with ❤ by GitHub

Remember that software development can often be much like an episode of South Park; constant swearing, youthful naivety and surprise endings.

Friday, 22 March 2013

Memories of Visual Basic 6

In the UK it is typical to study for two years and then have a placement year where you actually get a job before the final fourth year of study.  In 2006 I took on several small projects over the placement  year and pushed VB6 to it's limits.  VB6 has so many quirks, it is impossible not to use hacks to get things done.  Here are some of mine.


One tool required a DSL for interacting with phones, it would read a list of phone numbers and a file containing commands and run them over each of the numbers.  For example it would make a call to the phone and configure it using DTMF* tones.  I had no idea at that time how a compiler could be properly implemented so the resulting code was a complete mess and the DSL was looked like assembly for telephones.  Despite the hideous code, the program saved a lot of time.  To do this manually would have taken days instead of a couple of hours and be impossibly error prone.  One key missing feature was error handling, which is problematic in telecommunications.  Inevitably one of the calls would go wrong and the program would crash, the operator would then have to delete the completed phones numbers from the list and run the program again.  No problems!

Another project provided a UI for editing INI file configuration.  The program was great, except that VB does not allow more than 256 controls on a single form.  My 'ingenious' solution was to put each INI section in a tab pane which also had its own window.  When the user clicked a new tab, it hid the current window and showed a new window for that tab. 

VB6 also comes with it's own TCP control which you must drag onto the UI to instantiate.  The problem is that it had almost the same API as a serial connection control, meaning it only dealt with 1 to 1 connections.  This meant it was impossible to write a TCP server.  That is, until I worked out that an array of TCP controls waiting for connections worked pretty much like a TCP server.  This is OK except that an array has a finite capacity, I was again limited by the number of controls so the server could only ever handle a certain number of connections.

I remember the year, the work and the company fondly and hope that some of my work is still in use.  Looking back, I don't know why I used VB6 for everything.  It's just so easy to get started and then keep typing, I was young and naive, that's all I can say...

* DTMF tones are those strange sounds you hear when you press a number on a phone key pad.  Pieces of hardware such as phones and switches can interpret a sequence of tones as commands.