An interview with Evan Miller about Chicago Boss

February 11, 2013 Leave a comment

Hello everybody! Thanks to Erlang Solutions I have been able to interview Evan Miller,  one of the speakers you can meet at the upcoming Erlang Factory which will be held in San Francisco (21-22 March) .  Evan is mostly known as the author of Chicago Boss. Let’s know him better with this interview! Hope you will enjoy it!

Meet the boss!

Paolo – Hi Evan, it’s really nice to have you here. Can you briefly introduce yourself to our readers?

Evan - It’s great to be here, and I’m glad to do it. I’m a graduate student in economics living in Chicago who has a passion for programming. People in the Erlang world know me as the creator of Chicago Boss, the
maintainer of ErlyDTL, and a loudmouthed defender of unpopular language features. Before grad school I briefly worked as an ops guy for Amazon.com and as a developer for IMVU, both out in Silicon Valley.

Paolo – How come a person with a degree in physics gets in touch with Erlang? Was it “love at first sight” or did you take a while in order to grasp it?

Evan - I stumbled across Erlang in a rather roundabout way. While I was involved in search operations at Amazon.com, I discovered that the source of almost all pain and suffering in the ops world can be traced
directly to blocking, threaded socket code. This led me to tinker with Nginx — a non-blocking server — but although I love programming in C (really!), I couldn’t stand the callback-based API. Shortly thereafter, a friend of mine at IMVU introduced me to Erlang, which is non-blocking… but without the callbacks! I instantly saw through Erlang’s syntax warts and fell in love with “what’s on the inside” – the absolute best VM for doing any kind of network programming.

As for the physics connection, I agree with Joe Armstrong — the creator of Erlang and who incidentally is an ex-physics person — when he says that Erlang’s process model comes naturally to anyone who has
studied relativity. Each process is its own “frame of reference”, in a manner of speaking — no process knows what’s on the inside of other processes, and heck, process clocks may be out of sync, but that’s OK!
You learn how to program around it and end up with much more reliable systems than ones that assume there is a “true frame of reference” of some sort. There can’t be, because you have to assume that *any*
server might fail or become unreachable in a networked environment.

Paolo – You are going to be one of the speakers at the next Erlang Factory held in San Francisco Bay area on March, what will be topic of your talk?

Evan - I am! The topic’s title is “Chicago Boss: a Web Framework Built For Comfort (And Speed)”. I’ll be giving a high-level overview of my pet framework and talk about some down and dirty details of why it’s designed the way it is.

Paolo – Who should attend your talk? Do they need to be expert Erlang or Web programmers?

Evan - Everyone should attend! I’ll try to make it interesting for both experts and novices. For example, I’ll explain why Chicago Boss is so darned good at fast server-side template rendering, which is something
that most languages have a lot of trouble with. I’ll also show some code samples to make things concrete.

Paolo – As the author of Chicago Boss would you like to introduce it briefly to our users?

Evan - Sure thing. Chicago Boss is a web framework that basically attempts to steal all of the good ideas from Ruby on Rails, and fix everything that’s broken: namely, slowwwwww templates, rampant RAM usage, lack of real-time messaging (WebSockets), and all this DevOps nonsense. So Chicago Boss combines fast templates with a clean API and a sophisticated “ORM”. I put that last bit in quotation marks because Erlang doesn’t really have objects, so we use a sort of fake object called a parameterized module that everyone on the Erlang mailing list hates with a passion, but which we love because it’s perfect for modeling data.

Anyway the framework is still in beta, but a lot of people are using it in production and we’re hoping to have a stable release soon!

Paolo – In your opinion, what are the main reasons that should make a web programmer switch from other platforms written in different languages as Rails, Symfony or Django to Chigago Boss?

Evan - Well, the first advantage is getting to work with a nice functional language like Erlang, even if CB sprinkles in some OO-style conventions here and there. Once you get the hang of it — which may take a while! — it’s generally easier to write correct code in Erlang than in non-functional languages.

But I think the real benefit actually comes down to operational costs — Chicago Boss runs smoothly on relatively little hardware and doesn’t need to be constantly restarted like most Ruby and Python servers. Erlang truly has a first-rate VM that is perfect for serving web pages. We’re really excited about running CB applications on ARM-based servers, which could really up-end the economics of server applications in the next few years.

Paolo – Chicago Boss in not the only option when talking about Erlang and web applications, what are the strength of Boss with respect to the others? Is there any feature you would like to “steal” from them?

Evan - CB is more of a full-stack framework than the others out there — in particular, it’s the only one that ships with any kind of database abstraction, letting you write your code first and choose from one of
six SQL and NoSQL database options later. There’s also an email server baked in, and an internationalization system — we’ve really tried to provide a complete package, whereas most of the other Erlang servers tend to be more bare-bones toolkits.

Don’t tell my mother, but I never hesitate to steal! But most of what I’ve stolen has actually come from the world outside Erlang. For example, the default template language is a tag-for-tag reimplementation of Django’s template language, and there’s now experimental support for the Jade template language.

Paolo – What kind of data storage support may we have with Chicago Boss? Do you recommend any of them, and if so why?

Evan - As I mentioned there are many options — in the SQL camp there’s PostgreSQL and MySQL; in the NoSQL camp there’s MongoDB, Riak, and Tokyo Tyrant, and then there’s an Mnesia adapter which isn’t SQL per se but it is schema’d. I don’t want to start a religious war, so I’ll stay quiet about my own preferences — but it’s really easy to add support for more databases — usually just requires a couple hundred lines of code.

Paolo – At the beginning Boss was implemented around Misultin, but later you moved to Cowboy. Was it difficult to switch the architecture? How many code did you rewrite in that sense?

Evan - For a long time, Chicago Boss supported only Mochiweb and Misultin; as we were pondering how to support Cowboy’s alien-looking API, someone had the brilliant idea to write a Mochiweb-compatible wrapper around Cowboy! It’s called “mochicow” and lets us adapt CB to use Cowboy in rather short order. Anyway, most of the hard work here is actually done by the folks over at Nitrogen who created SimpleBridge, which is an abstraction layer over I think six different web servers. It’s really a nice little library and we’ve contributed code back to it.

Paolo – One strength of Chicago Boss consists in my opinion in the good amount and quality of its documentation. Would you like to address your favourite online resources to a developer willing to learn more about Chicago Boss? Is there any “real” book about Chicago Boss?

Evan - As much as I love killing trees, there’s no book yet! The closest thing to it is a PDF tutorial on the website, and people are always adding new code samples to the Wiki hosted on GitHub. The best way to get started is to work through the tutorial, peruse the API documents, and hop on the mailing list. It’s an active, friendly place where we welcome in newcomers all the time.

My impressions about Learn You Some Erlang as a real book

February 10, 2013 Leave a comment

Thanks to Fred Hébert and No Starch Press I had the chance to get a review copy of “Learn You Some Erlang for Great Good!” so I guess that somehow it is my duty to write in this Erlang blog my opinion about it.

When I started with Erlang some years ago it was not easy. I am a huge Erlang fan (I guess you noticed that) but for a guy coming from Java and C++ with no knowledge at all about functional programming, the beginning was not trivial. After reading a couple of good books (some of them are on the right panel of this page) I felt better: my Erlang coding improved but I still felt that something was missing…then I found *it*.

I remember the first time I landed to “Learn You Some Erlang”: I was desperate with some strange behaviour with supervisors and asking online I got a really good answer that pointed me to a new free online book about Erlang, so I gave it a try and clicked the link. I must admit that at the beginning I expected a totally different book…I mean, most of the free books you find online are usually incomplete and boring, so I guess you can understand how I felt when I saw the magnificent work Fred did.

For me, it was such a pleasure to read his work about supervisors that I switched back to the introduction and read in a few hours all the previous  chapters…if you had the chance to get through Fred’s work you know what I am saying: the book is technical (of course!), but in it you can find not only the usual explanation of the language, you can find much more! The book contains a bunch of useful real life examples, a lot of theory that can be applied to any distributed systems and a thousand funny pictures that make me smile and enjoy the reading even more. You may think that since the book is available for free online (and for this I guess we should thank No Starch Press) there is no reason to buy the solid book for $49.95: well, you couldn’t be more wrong about it. 

I can’t describe what I felt opening the envelope and turning page after page looking for my favourite parts of the book….it just felt good, like meeting an old friend I haven’t seen for a while. The book layout has slightly changed and a set of small arrangement have been done to Fred’s book, so the visual impact is even better and the reading is actually easier.

“Learn You Some Erlang” comes as paperback, but keeping it in your hands you can feel that it is built in a good way so that you don’t have to worry about chasing in the future some flying pages. You shouldn’t be afraid of its size as well: even though the book has more or less 600 pages, it is
light enough and you can keep it easily in one hand. Some random guy over there could say the images in the book are in grey level and not coloured as in the online version. They could also say that nowadays books are prehistory (I don’t agree) and that almost every developer has a tablet; the latter could be true but you should know that the book comes with a free Ebook version (with the solid book) that has colours, so if you want you can have it in your PC, tablet of smartphone.

Now, about the contents of the book there is much to say!

In its first chapters Fred helps you with the first steps in the Erlang world as for example its syntax and the basic principles of functional development. Further in the book, more interesting topics are covered, here you will learn about Erlang concurrency easyness and you will start understand why Erlang is so good for distributed and fault tolerant systems. But Fred’s work is not only for Erlang beginners: diving more into the book you will see that that are a lot of topics which are interesting also for experienced Erlang programmers as Releases, Common Tests and Distributed OTP Applications.

I guess I made myself clear within this posts: “Learn You Some Erlang” is a must-read-book every developer out there should add to his Erlang shelf. I recommend it without any doubt and I take this post as good chance to thank Fred Hébert once more for his great job and for the help he gave me without even knowing. I would also like to thank Fred and No Starch press for giving me the chance to review this amazing book.

So what are you waiting? Click here and buy your own “Learn You Some Erlang for Great Good” copy!

Talking again about Erlang with Francesco Cesarini

January 4, 2013 Leave a comment

In 2011 I interviewed Francesco Cesarini for my blog. That was my second interview, a giant leap for my blogging experience. Today I am talking again with Francesco, mostly about his 2012 and an upcoming event organized by Erlang Solutions for all the erlanger in the USA:  the Evening School of Erlang.

 A 2013 full of Erlang!

 

Paolo – Hi Francesco! It’s good to have you here once again talking about Erlang. How was your Erlang year?

Francesco - 2012 has been a really good year. I spent a good part of it in the US, visiting companies using or looking to adopt Erlang to better understand their problems and needs. I taught the Concurrency Oriented Programming course at Oxford University both in the spring and the fall, alongside celebrating the 10th anniversary teaching at the IT University of Gothenburg. 600 served and counting. The best thing is seeing those who chose to work with Erlang after they graduated. Two EU funded research projects, Release and Paraphrase are sharing in excess of seven million euro. They have made excellent progress improving Erlang’s viability on multi-core architectures (we are talking tens of thousands of cores). A third project got funding in March and started in November. It is the Prowess project, taking property based testing to the next level. And Erlang Solutions is also doing very well. We expanded the offices in Krakow, moved to larger offices in London. There has been a huge interest for MongooseIM (our IM platform), our Erlang Management Console alongside lots of interesting courses and projects, all topped up and managed by great and dedicated staff. Record numbers at the San Francisco Erlang Factory and the Erlang User Conference, a lot more Erlang Factory Lites compared to 2011. It is clear that the adoption of Erlang is growing faster than ever before. I can’t wait for 2013.

Paolo – During the year many Erlang related events are held all around the world. In your opinion is this the best way to spread the Erlang word? How can we all help?

Francesco - The whole community is doing a fantastic job, so more of everything which builds the community is probably the right answer. We need more bloggers sharing their experiences, more people speaking at conferences and writing articles about their experiences. We need people to run user groups, self study circles, coding dojos and katas. We need better tools catering for the 21st century. Think cloud, embedded, massive scalability, with tens of thousands of nodes all interacting with each other. We need more research, more universities using Erlang as a tool to teach aspects of computer science such as distribution, concurrency and multi-core programming. And most important, we need to start speaking (and learn how to speak) to the CXO level. They are the decision makers who sit on the budgets and have a say on how and if Erlang is used out there. It is a very different language than that spoken by engineers. Instead of talking about cool debugging techniques or getting embroiled in the frames debate, we should be taking about financial benefits Erlang brings. How one reduces development, operations and hardware costs, making the software future proof towards future multi-core architectures.

Paolo – If you ask around you may find that many companies are afraid about using Erlang, mostly because they have a lot of know-how only about mainstream languages and fear the switch. How can we tackle this problem?

Francesco - I recently sat in a meeting where they were about to start a project with 100 Java developers. We suggested running a project in parallel, where we said we could do the work in half the time with 10 Erlang developers. It was a switching problem which had to handle peaks of traffic; Erlang was the perfect fit. The answer we got was, “If you are right, what do we do with our Java team”! This is fear, not common sense.

One has to introduce Erlang (or any emerging technology) starting small. Do a prototype or a proof of concept, show the advantages, and build on success. Mike Williams, co inventor of Erlang, include design by prototyping: In is not good enough to have ideas, you must be able to implement them and show they work. And make mistakes on a small scale, not in a full production project. When moving away from mainstream, at least in large companies, the conservative naysayers will be circling over you like vultures, waiting for the slightest hint of trouble. If you are 10% above budget, it does not matter if your budget is 1/10 of similar projects using mainstream languages. You are still over budget! Don’t give them the opportunity. But I am not answering your question, am I? My advise is to find your Erlang champion within the organization, make sure you are using the right tool for the job, get management buy in and start small.

Paolo – As many other Erlang developers, I am a member of the Erlang Questions mailing list; lately I spotted there a message from Erlang Solutions about an event called “Evening School of Erlang”. Can you tell us something more about it (e.g. locations and prices)?

Francesco - One of the biggest hurdles to adoption is lack of programmers. That was a clear concern when visiting companies on the US West coast. There are few experienced Erlang programmers commanding extremely high salaries and often changing jobs when new opportunities arise. To jump start the Erlang job ecosystem in the US, we decided to try out the Evening School of Erlang. Two nights a week, for four weeks, local trainers will be giving Erlang classes to developers looking for a career change. A few weeks after the course, those attending will be offered to take the certification exam. These classes will be heavily subsidized by corporate sponsors looking at recruiting/placing Erlang developers and will cost 199 USD. In exchange, your contact details will be shared with these sponsors.

In the new year, we are starting the courses on the 8th of Jan in San Francisco, close to Union Square, followed by Pasadena (Feb 19th) and San Jose (Feb 20th). Mountain View and Santa Monica will be announced soon. The goal for 2013 is to train 400 developers while expanding the network to cover Chicago, Seattle, Boston, New York, DC, and any other city where companies recruiting are willing to sponsor.

For those not interested in changing jobs but interested in learning Erlang, there is a corporate rate available which reflects the actual cost of the class. In this case, the details of the attendee will not be shared.

Paolo – Who may want to attend this kind of Erlang course? What are the topics and what is the Erlang level one must have in order to fully grasp them?

Francesco - Everyone who is interested in a career change and believes Erlang is the way forward. While we are hoping to attract experienced developers, students are just as welcome. Topics include:

  • Introduction
  • Basic Erlang
  • Sequential Programming
  • Concurrent Programming
  • Process Design Patterns
  • Process Error Handling
  • Code Updating
  • Records and Funs
  • ETS tables
  • Distributed Programming
  • Advanced Constructs
  • Ports and Sockets
  • Style and Efficiency

Paolo – In the aforesaid Erlang mailing list message, there was some reference to a “Certification Exam”. Can you tell our readers what it is? Will the exam price be included in the course price? I guess Erlang Solutions will the entity that grants the certification, am I right?

Francesco - The Certification in Erlang provides validation of Erlang/OTP knowledge. We provide two exams, one for Erlang and one for OTP. At a corporate level this validation is important both for employer and employee. It allows for employers to identify potential employees who are suitably skilled, and provides an on-going upgrade path to suit an organisation’s staff development plans and career aspirations.

It is possible to sit the examination for certification directly following the class, but we recommend that candidates undertake some self-study and obtain work in addition to the course, prior to sitting the exam. It is not easy to pass.

The Exam for the San Francisco class will take place in conjunction with the Erlang Factory in late March. The cost is included in the cost of the class and is subsidized by the sponsors.

Paolo – Do you think this kind of course may be helpful in order to get an Erlang related job? How can one developer attending to course to get in touch with these companies?

Francesco - The Evening School of Erlang is being sponsored by companies looking to recruit Erlang developers. At the end of every class, sponsors will give a 5 minute presentation on what they do with Erlang and pay for a round of drinks. These companies will get in touch with you.

Paolo – How can company become a supporter for this kind of event? How to get more information about it?

Francesco - For this and other classes, we are looking for support in the following areas:

  • Help in spreading the word to friends, colleagues and communities you believe might be interested in attending
  • Sponsors interested in recruiting Erlang developers willing to help out cover the costs of the trainer and material
  • Trainers interested in teaching the course
  • Companies with training facilities all across the US seating 10 – 20 delegates

You are welcome to contact me via our website, where you can also find more information and register:

https://www.erlang-solutions.com/services/evening-school-erlang

Paolo – What about European Erlang developers? As far as I know you already started some courses in Krakow. How long should we wait for something like this to happen all around the Europe (maybe Italy :D )?

Francesco - This is entirely driven by market needs. Europe has been teaching Erlang in its universities for over 20 years! Thousands of developers have been trained, so the situation is not as acute as in the US. But if companies come to us and say they are having a hard time recruiting, we will certainly consider it.

You mention Krakow, where Erlang Solutions had to recruit. We tried out the evening school of Erlang back in 2008. The first time, 7 people registered. The second time, the number went up to 20, and the following year, we had 70 applicants. Word got around. The universities there started teaching it. They started doing research. And the yearly Erlang Factory Lite has for the last three years attracted in excess of a hundred attendees.

Paolo – I do believe 2012 was a good year for Erlang: a lot of events, courses and some new good book. Our world proved to be fault-tolerant to 21st december 2012, so What should be expect from 2013?

Francesco - Massive concurrent expansion of the language adoption. Lots of books are being written. I am co-authoring the follow up of “Erlang Programming”, tentatively called “Designing for Scalability with Erlang/OTP”. It will be published by O’Reilly. Joe Armstrong is working on the second edition of his book. On top of that, there are four other books in the writing which I am aware of but am unsure if I am allowed to speak about. My wish of having a whole bookshelf with books on Erlang will be realized this year. We are planing at least an Erlang Factory Lite per month, break the previous attendance records at the Erlang Factory in San Francisco and Stockholm and continue our work on educating and helping people. We will soon be launching a new community site aimed at replacing Trapexit. On top of that, Erlang Solutions will continue its international expansion and help grow the community. So all in all, if 2012 was an excellent year, we are really looking forward to working with the community in making 2013 an even better one!

Distance between two points on Earth in Erlang: an implementation of Haversine function

December 26, 2012 Leave a comment

During my daily  routine at Univesity of Trento I deal with different tasks in different programming languages. Lately I had to find a good way to compute the distance between two points on Earth which were identified by their lat, long coordinates. After a while, I decided to solve this task by using the haversine function.

The haversine  (as known as the haversed sine), is a trigonometric function mostly employed in order to compute the great-circle distances between two points on a sphere, where the two points are identified by their longitude and latitude.

This method is strongly recommended in the literature  for calculating short distances on Earth and in that sense it works great, but when we use it we have to keep in mind that it has a major drawback: the formula approximates the shape of the Earth to a sphere (actually it is an ellipsoidal), therefore it introduces some overestimation errors for  trans-polar distances and underestimation errors for trans-equatorial distances.

If you don’t know how to implement the haversine function you will probably use your  google-fu. The first web page you should check out is the wikipedia page for haversine, and the second one is  this webpage. In the second link you may find a bunch of different implementations in several languages (e.g. Haskell, Python, C, Clojure etc) of the haversine problem…but wait! There isn’t an Erlang implementation!

Ok, let’s solve this problem right now! Here is my implementation of the haversine function for two points distance:

-module(haversine).
-export([distance/4]).

distance(Lng1, Lat1, Lng2, Lat2) ->
    Deg2rad = fun(Deg) -> math:pi()*Deg/180 end,
    [RLng1, RLat1, RLng2, RLat2] = [Deg2rad(Deg) || Deg <- [Lng1, Lat1, Lng2, Lat2]],

    DLon = RLng2 - RLng1,
    DLat = RLat2 - RLat1,

    A = math:pow(math:sin(DLat/2), 2) + math:cos(RLat1) * math:cos(RLat2) * math:pow(math:sin(DLon/2), 2),

    C = 2 * math:asin(math:sqrt(A)),

    %% suppose radius of Earth is 6372.8 km
    Km = 6372.8 * C,
    Km.

As you may notice the implementation is fairly easy: first of all we use a list comprehension to convert our latitudes and longitues to radians. Once we get the values expressed in radians, we just need to extract the desired distance by using the haversine function. 

Let’s try the code with the webpage example! Suppose you want to compute the distance between Nashville, TN, USA: (36.12, -86.67) and Los Angeles International Airport (LAX) in Los Angeles, CA, USA:  (33.94, -118.40):

1> haversine:distance(-86.67,36.12,-118.40,33.94).
2887.2599506071087

Good! Seems working! You may find my implementation here (pick the right git branch), just if you don’t want to cut and paste the code from this web page!

Hope this will be helpful to you as it was for me!

Categories: Erlang Tags: , ,

Learn You Some Erlang for Great Good! is now a real book!

December 17, 2012 1 comment

In my humble opinion if you want to learn or improve your Erlang, writing a lot of code is a good idea but is really not enough: you have to learn from other people’s work, you have to read more from blogs and books.

That’s the reason why in one of my oldest posts I recommended you to take a look at 7 Erlang related websites among which you will find the good old http://learnyousomeerlang.com/I firmly believe that most of Erlangers out there learnt a lot from Fred Heber‘s work; the amount of information he provides is just impressive and his way to teach Erlang by small (well, not that small) examples is the best one I have seen so far online.

If you liked and still like Fred’s online book as I did, you should probably be aware of the fact that this brilliant piece of Erlang knowledge is going to be published by No Starch Press. Yes, Learn You Some Erlang for Great Good! is going to be a real book! Isn’t this an amazing news?

Do you want to  purchase the book (which is now in pre-order)? In that case you have to go to http://nostarch.com/erlang and the book will be yours in few clicks.

Oh, I almost forgot two very important things:

  • if you buy the book you will also have the free ebook in several formats (pdf, mobi, etc)
  • if during the purchase procedure you use the coupon code PREORDER you will get 30% off

I really can’t wait for my copy to arrive!

Categories: Erlang Tags: ,

An interview about #Erlang and embedded devices with Omer Kilic (@OmerK)

December 10, 2012 Leave a comment

Hello there! Today you may read my interview to Omer Kilic, a very famous guy you may know if interested in Erlang and Embedded Electronic Systems. 

I think you will find his answers very inspiring….it is time to get a Raspberry PI!

Code some Erlang while you are having some raspberries!

 

Paolo – Hi Omer! Thank you for making yourself available for one of my interviews. Would you like to tell our readers something about you?

Sure, I’m an Embedded Systems Engineer currently working on Erlang Embedded, a Knowledge Transfer Partnership between Erlang Solutions and University of Kent. The aim of this KTP project is to bring the benefits of concurrent systems development using Erlang to the field of embedded systems; through investigation, analysis, software development and evaluation.

Paolo – Why should we want to have Erlang on embedded devices?

Erlang has features that are highly relevant to solving problems we face today with modern embedded systems such as dealing with connectivity, distribution and concurrency. We also have a different take on error recovery and supervision hierarchies which reduces the overall complexity of the system and leads to less code being written, which in turn increases testability.

These features make Erlang a suitable tool to use as the orchestrator and the systems language of these complex embedded applications we are developing for the future.

While Erlang is currently being used for very large scale distributed applications, it has roots in Embedded Systems. It was originally conceived to deal with the issues, such as the fault-tolerance, concurrency and the distributed nature of telephony hardware at Ericsson.

Paolo – What are the devices that currently can run Erlang?

The rule of thumb is: if you can run Linux on your device you should be able to run Erlang on it too. This covers most of the current ARM and MIPS based platforms. There have been ports to other operating systems, such as VxWorks, in the past as well. We currently don’t support a ‘bare-metal’ setup.

The VM doesn’t actually require a lot of resources to run (this obviously is application dependent) and you can slim down the size of the installation using the packaging tools included, which will create a tailored distribution that will only contain the runtime system, required libraries and your application.

We have chosen Raspberry Pi as our reference platform and we provide packages for the Raspbian distribution so you can get started with Erlang quite easily if you have a Raspberry Pi board. We will also be releasing packages for other distributions and platform in the near future.

Paolo – Why did you choose Raspberry PI and not one among the other famous platforms (e.g. Beagle Board)?

Raspberry Pi is an exciting project with a very enthusiastic community around it. I think they have successfully removed the hurdles in getting started with Embedded Linux by providing an affordable, simple and well documented hardware platform with a thriving hardware and software development body attached to it.

Another reason why we chose the Pi is the educational side of it. If we can introduce concurrency/parallelism into the ICT curriculum, young people will learn about these computer science concepts way before they start their further education.

Paolo – I think Raspberry PI is very good for learning, but do you think it is mature enough for industrial purposes?

We see it as a great educational tool but also acknowledge that it may not be the best platform to integrate into industrial applications. As such, we work with other Embedded platforms such as Beagleboard and Gumstix for commercial applications.

With the layered hardware abstraction model that we are working on at the moment, the platform choice doesn’t really change the way you architect your system. Learning/prototyping on the Pi and deploying it to another platform is perfectly viable as long as the low level drivers are in place.

Paolo – Was it difficult to port Erlang on Raspberry PI? Did you change some stuff related to the VM?

Other than a few minor fixes it wasn’t difficult at all, in the end we actually ditched our cross-compilation setup and compiled natively on the Pi itself!

Paolo – Most of the video published on you tube are simple examples of applications which turn on/off a led or exchange Erlang messages. Are you actually working on something more complex? And if so can you tell us something about it?

We wanted some simple examples for those videos as gentle introductions to some of the features of Erlang.

Our current project is the hardware abstraction library that I’ve mentioned previously, which maps hardware to the Erlang domain doing some interesting transformations along the way to facilitate concurrency. We will be releasing the first version of our library in the coming weeks.

Paolo – I believe you are not controlling the sensors connected to Raspberry PI with Erlang. Am I wrong? How do you deal with this? Maybe with a C port?

We are controlling the sensors using the peripherals on the Raspberry Pi, using a collection of NIFs and ports.

Most digital sensors can be controlled by the Pi as it has peripherals such as SPI and I2C to deal with the interfacing, analog sensors require some additional circuitry though as the Pi does not have an Analog-to-Digital converter.

We abstract away the lowest level functionality into C ‘drivers’ and interface them to the Erlang domain using ports and NIFs. These facilities are documented in the Interoperability User’s Guide.

Paolo – Nowadays, smart grids and smart buildings are on everyone’s lips. Both are related to distributed systems where efficiency, reliability and low power consumption are features needed. Do you think Erlang could help in this sense?

Certainly, we see Erlang as a highly relevant tool to tackle these challenges.

The Actor model of concurrency we have in Erlang lends itself well to distributed systems. The runtime is fully network aware and passing messages between different physical nodes is as simple as local message passing.

The OTP framework has battle-tested supervision hierarchies that can be employed to deal with error recovery/containment and provide high reliability. Quoting Joe Armstrong, the father of Erlang:

The Erlang flagship project (built by Ericsson, the Swedish telecoms company) is the AXD301. This has over 2 million lines of Erlang.

The AXD301 has achieved a NINE nines reliability (yes, you read that right, 99.9999999%). Let’s put this in context: 5 nines is reckoned to be good (5.2 minutes of downtime/year). 7 nines almost unachievable … but we did 9.

Power efficiency is an area we haven’t looked at yet but it is definitely on our very exciting list of future explorations.

Paolo – How can we know more about Erlang embedded? Is there any technical document or blog about it?

More information about the Erlang Embedded project can be found on our blog and you can also follow us on the @ErlangEmbedded twitter account. Please feel free to get in touch if you have any specific questions!

Erlang meets baseball: welcome TOK.tv!

November 27, 2012 Leave a comment

In this post I would to tell you something about my collaboration for TOK Baseball, the free iPad application created by the startup TOK.tv.

Last summer I was contacted by Fabrizio Capobianco, the CEO and founder of TOK.tv for a possible Erlang freelance job. During our discussion Fabrizio introduced me his idea about a brand new iPad application: TOK Baseball. The concept behind the application was very interesting; in today’s society more and more people are living away from their relatives or childhood friends, loosing the oppurtinity of watching a game togheter, and that is really sad.

If you are a sport fanatic as I am, you know what I mean. I believe that nothing beats the experience of watching a game togheter with your buddies: commenting a bad tackle, complaining your own team bad play or screaming for an amazing victory is really something! Here is where TOK.tv comes in.

TOK Baseball is an iPad application to be used as a second screen while you are watching a baseball game on tv, but unlike many other applications it doesn’t consist on a really boring number of Twitter status updates about the match. TOK Baseball allows you to invite up to three friends and have a real voice conversation while the app pushes live stats about the game you are watching. The application is not intended to substitute your tv, it’s rather a good way to enrich your experience, a way to bring back the concept of sociality in your tv/sport routine.

At this point, I may hear many of you saying: “Ok Paolo, nice ad for the application…but how is this related at all with Erlang?“. Well, Fabrizio and the other guys at TOK.tv are nice people so they let me write a little bit about my collaboration with them in my blog. First of all you may be interested in knowing that Erlang plays a major role in the application backend: the social core of the app is actually implemented using as base eJabberd, the very famous XMPP server you should already have heard of.

My work for TOK.tv was in fact devoted to the implementation of some eJabberd internal components, mostly related to the concept of friendship. I have to say that I did my last “real” work with XMPP during my bachelor thesis experience, so it was really good to go back and put my hands on eJabberd and Erlang stuff.

eJabberd code can be really hard to grasp since there is much code to go through and most of the times you have to jump from file to file, but once you start knowing how it works and its basic principles you can really enjoy it and undestand why it is still one of the most famous and appreciated Erlang applications out there.

Was it a good idea to use Erlang and eJabberd for the application backend? In my humble opinion it was indeed. Just think about this: for each game, you can have a huge number of users logging in and out, moving from match to match, making friendships and inviting friends…all of this must be very reliable and fast, especially because it must be connected to the real time voice experience. That’s way I strongly believe that by using Erlang the TOK.tv crew made a sound decision.

One more think: TOK.tv development is everything but slow! Soon the company will be launching TOK Football, the perfect companion for all the football fanatic….you know what? I hope they will have the application for Italian soccer soon enough!

Categories: Erlang Tags: , , , , ,
Follow

Get every new post delivered to your Inbox.