An interview with Evan Miller about Chicago Boss
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
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
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
)?
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
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!
Learn You Some Erlang for Great Good! is now a real book!
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!




