A Taste of Elixir at Functional Kats Belfast

I recently gave a presentation to Functional Kats (Belfast) on the elixir language. It was a lot of fun!

The format of the event I totally love, it started with a couple of talks followed by a Kata hack where we all had a go at implementing the Luhn Credit Card algo in the functional programming language of our choice. At the end we all took turns to present our solutions.

The goal of my talk was to arm the folks with enough of the basics to implement the Kata in elixir.

Thinking Like an Erlanger

I found this video last night by Torben Hoffman, I recommend folks interested in Erlang or Elixir give it a watch and take it to heart. Torben does a good job of displaying how an “Erlanger” should think, in comparison to other programmers.

Torben recommends 2 books which have been added to my reading list:

Communicating Sequential Processes by C.A.R. Hoare. (Free digital Version)

Principles of Protocol Design by Robin Sharp.

Elixir, BEAM and OTP

As I plan to write and speak about Elixir on my blog and hopefully at some meet-ups soon, I though I would write a short post with handy descriptions of some of the key aspects that I can reference in one place…

What is Elixir?

Think Dave Thomas describes it best…

“The Elixir Programming Language wraps functional programming with immutable state and an actor-based approach to concurrency in a tidy modern syntax. And it runs on the industrial-strength, high-performance, distributed Erlang VM.”

It has very powerful meta-programming capabilities through compile time expansion of macros and the dynamic power of the language. A good example of the developer productivity that can be gained is their use in the routing system in the phoenix web framework. When learning about Elixir macros I found the ‘Understanding Elixir Macros Series’ by Saša Jurić to be very useful.

What is the Erlang VM & BEAM?

The “Erlang VM” is the name of the virtual machine where all Erlang code is executed. Every compiled Erlang file has the suffix .beam.

There is also an implementation of Erlang which runs on the JVM, called Erjang, but I guess the less said about that the better as the Erlang VM is really the awesome part if you ask me.

When you compile Elixir code it is converted to .beam format, which allows it to be executed on the Erlang VM.

What is OTP?

OTP is set of Erlang libraries and design principles providing middle-ware to develop these systems. It includes its own distributed database, applications to interface towards other languages, debugging and release handling tools.

The OTP libraries (and the associated best practices to an extent) are mature, battle hardened and hide much of the boilerplate code required to perform common patterns such as creating a server to store state, recover from failures through supervision trees and so much more.

I look forward to writing about this with examples in future as I learn more about OTP myself.

Where is OTP used?

egitsd – egitd is an Erlang git-daemon implementation that provides a more flexible, scalable, and loggable way to serve public git repositories. It is used by github.com.

RabbitMQ – An open source message broker (sometimes called message-oriented middleware) that implements the Advanced Message Queuing Protocol (AMQP).

More Projects using OTP…

Sources:

To Be Message Driven

@ToddMontgomery’s session on message passing and distributed systems at ReactConf.

.NET Open Sourced

Pretty cool that .NET got open sourced, even more cool is that it is MIT license with the Source Code on Github.

Also pretty funky that they are offering a fully featured version of Visual Studio for free and shipping supported Linux and OS X runtimes. Mono has give us this for a long time, but it is a nice that the gaps in Mono are going to be filled.

Lots of cool stuff coming in this area, such as the new Roslyn compiler (C# written in C# now not C++) which will open up some crazy compiler as a service meta-programming voodoo. Mono is a C# implementation of C# and has again been ahead of its time in this space, but Roslyn seems to be generating some crazy buzz around code introspection and IDE features.

Most interesting thing in .NET space for me though is not any of this but is simply the F# language, which itself is written in F#, and has been the most pioneering and exciting language in the .NET space for a number of years due to its ability to innovate a add new powerful features with relative ease.

I hope that C# and .NET keep pushing forward and we don’t see a Java-‘6-8’-esk stagnation period. Doesn’t look like it in week one anyway –> ‘One Week of Open Source’