Erlang, a programming language originally created in 1987 by Ericsson in its
Computer Science Laboratory isn't exactly what anyone would call 'new', let
alone the next big thing.
In fact, it's so old that many of you may have never heard of it till now
either. So then, just why and how can a 20-year-old language suddenly become the
next big thing?
Direct Hit! |
Applies To: Developers USP: An introduction to this 20 years old, yet powerful Open Source language available for both Windows and Linux Primary Link: www.erlang.org Google Keywords:Erlang |
The answer, lies in the many features of Erlang, with one in particular —
concurrency, or the built-in ability to run a program over a cluster of
machines, even those of different platforms, which makes it easy to scale your
applications to support any number of users or transactions almost instantly.
Now, combine that with the support for fault-tolerance, non-stop applications
and hot code replacement and you might get an idea why Erlang could be very
attractive for web and software applications in use today.
In fact, Erlang is already demonstrating that power, moving from powering a
real-time telecom application for an ATM switch like AXD301 from Ericsson, to a
real-time chat application for Facebook.com, which supports over 70 million
users.
Another real example is Yaws, short for Yet Another Web Server, a web server
coded in Erlang. This server, in a benchmark test, held on even with 80,000
parallel requests, when Apache died at just over 4,000 parallel sessions.
All that power comes from the features of Erlang, like these:
Open Source & Availability in a variety of platforms
Erlang is a freely
available, open source language, which makes it easier to change and adapt. It's
also available on a variety of hardware platforms; like Linux and Windows as
pre-compiled binaries and for others like Mac OS X, compliable from source.
Concurrency & Distributed Applications
One of the most fundamental features of Erlang, concurrency or the ability to run multiple processes and message passing
is the most appreciated feature of Erlang. And since its built so, creating and
managing processes is quite trivial in Erlang, almost without any extra effort
for a developer. Technically, Erlang approaches the problem of program
parallelization differently from C, Java or other so-called sequential
languages: It uses very lightweight processes that don't share memory but rather
pass messages asynchronously.
Who is using Erlang? |
|
Erlang does that by using processes similar to 'green threads' used
originally by Java, which are neither operating system processes nor threads
with a big difference; they don't share any states.
Process communication is done with an asynchronous message-parsing system,
which is separate from the actual program. This means that processes can be run
on one machine or on several machines with the same or different platforms
without any effort.
Soft real-time
Erlang supports programming for "soft" real-time systems,
which require response times in the order of milliseconds.
In such systems you might need guarantees like “98% of chat requests with be
acknowledged in 5ms”; Erlang makes it possible to build such soft real-time
systems and offer guarantees with it's architecture and features like
incremental garbage collection.
Hot Code Replacement
Erlang was originally designed for non-stop systems; for
writing firmware's of telecom switches or banking applications; systems, which
are never meant to be shutdown, even for a software maintenance or when a
programming logic has to be changed or a feature had to be added.
Erlang makes it possible to replace code & functionality of an application
without shutting down the program by simply phasing out the old code with new
code.
More |
Erlang Official Site: www.erlang.org Download Erlang: www.erlang.org/download.html Books to read: Programming Erlang by Joe Armstrong |
But that's not it, Erlang takes it a step further by allowing both the new
code and old code to exist together during a transition; making it possible to
fix bugs and upgrades in a running system without disturbing it's operation.
Incremental Code Loading
Unlike traditional languages, Erlang allows the user to be in control of how the
code should be loaded — at boot or run time i.e. when an application or hardware
starts or only when a piece of code is needed.
This makes it trivial to replace buggy portion of code with new code and
gives it the ability for hot code replacement.
Built-in OTP libraries
Erlang was
initially designed for communications hardware, so, if you want to build
networking, telecom systems or applications like web servers, OTP (Open Telecom
Platform) libraries are always at hand.
The OTP platform with Erlang is also open-source, which makes it easy to
port.
Web ready
If you want to build web applications, Erlang now has a web
framework for building web applications on Erlang called ErlyWeb and a database
architecture called ErlyDB. Though they are not included with the Erlang source,
they are available separately for download, freely.
Distributed Database
Erlang comes with Mnesia — a real-time, distributed database that supports
RAM-replication as well as disk storage, and allows dynamic schema changes and
complex data structures to be stored. Mnesia itself is written in Erlang and is
under 20,000 lines of code, which further demonstrates the power of Erlang.
Hello |
|
External Interfaces
Erlang is not just about building programs within it-self; Erlang can even
interface with other languages like C, PHP etc. without much difficulty using
extensions. As you can understand, Erlang is interesting, the features that it
provides to a developer are quite path breaking and in some cases revolutionary,
nothing you might expect from such an old language. Which brings us to the
larger question; if you are developer, should you learn Erlang?
Erlang is a 20-year-old language and the implementation does show it's age,
making Erlang fundamentally quite different from other programming languages,
which makes it not a particularly an easy language to learn.
For instance, take the case of the '=', which is an operator assignment in
most languages. In Erlang though you might be able to assign X as 3 by using a
statement like X=3, an attempt to re-assign another value to X by using a
statement like X=4 will result in an error, simply because '=' is not treated as
an operator. If you are used to other higher-level programming languages, you
will find more such idiosyncrasies. In Erlang however, many of these would be
considered as “weird”.
But that said, if you have a background in C, Java, C++ or such, most of you
could learn and write non-trivial programs in Erlang in under a month.
Non-programmers or CIO's and Program Manager's can also appreciate Erlang's
abilities with a little more effort, at least from the implementation point of
view.
In either case, if you plan to create robust software, servers or web
applications that can handle millions of users without crashing and can scale up
in a jiffy, give Erlang a go. You might change your opinion about 'old' things.
Prasanth P (pp@prasanth.com) heads Exreal (www.exreal.com), a technology &
web consulting company.