Erlang is a programming language that appeared in 1986. Originally it was designed to be used in telecom applications development but nowadays it is used in different spheres like instant messaging, ecommerce, computer telephony, banking. Erlang is effective when the system has to be soft, real-time, scalable with high availability. Concurrency, distribution and fault tolerance is supported by Erlang’s runtime system. There is a set of Erlang libraries called OTP. OTP includes a distributed database, tools for debugging and release handling.
Erlang can be used to build web applications with the help of frameworks. There are four actively maintained frameworks: ChicagoBoss, N2O, Nitrogen, Zotonic and Erlang Web which is no longer maintained.
ChicagoBoss was expired by Rails and designed to handle big traffic amounts without performance issues. It is event-driven, has a data model and provides a view/controller model for both web and emails. It has a framework for adding functional tests. I/O is fully asynchronous and it prevents the application of being slow because of unrelated requests that can take a lot of time to process. ChicagoBoss supports all main databases like MySql, PostgreSQL, MongoDb, and Riak. ChicagoBoss server after start provides a lot of useful services like URL router, session storage, message queue, email server.
N2O is an Erlang framework that uses WebSocket protocol. Its main features are binary page construction, binary data transfer, transmission of events using WebSocket and work within Cowboy processes. N2O has built-in support of DSL and HTML templates. JavaScript control elements can be added and rendered inline with DSL. Benchmark of existing web frameworks that were built using functional languages shows that Cowboy is the winner. The chart shows the performance of raw HTTP for functional and C-based languages with concurrent primitives.
Nitrogen has an event-driven model. This model is built on Erlang pattern matching. This framework gives a possibility to tag elements with Erlang terms, and then use Erlang functions as event handlers. Nitrogen has one-way data binding. Web page sections are built asynchronously using WebSockets. Custom elements and actions can be packed and re-used in different projects as Nitrogen Plugins. It is important to note that it has a testing framework.
Zotonic is a Content Management System. It is event-driven and supports MVC model. It has Comet and WebSockets support and a templating system similar to Django. The database to work with is PostgreSQL. The system can be easily extended with user models.
Erlang with its web frameworks can be used for web applications that have to be scaled, event-driven, asynchronous, non-blocking, reliable, real-time, distributed applications. It shows great performance results for message passing systems and is highly secure.