DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Day 5 - Erlang

Day 5 - Erlang

Wayne Adams user avatar by
Wayne Adams
·
Apr. 04, 11 · Java Zone · Interview
Like (0)
Save
Tweet
4.30K Views

Join the DZone community and get the full member experience.

Join For Free

If you are just dropping in on me, I'm reviewing Bruce Tate's Seven Languages in Seven Weeks, with the slightly lazy (or aggressive, depending on your view) twist of reviewing one language per day. As you can imagine, shrinking an already-tight one-week study schedule to one day means glossing over some things and skipping the extra exercises. The idea, though, is to still get a good feel for the topography of the language, and as I've already pointed out, this is a great little book and will be my first contact for the languages I choose to get to know a little better.

The 5th language of this book is Erlang ("Ericsson Language"), first developed by Joe Armstrong in 1986. A functional, dynamically-typed language geared toward telecommunications and its high availability requirements, Erlang relies on lightweight processes (rather than threads) as its base model. It is based on and quite similar to Prolog, something brought out by Bruce's interview with Joe Armstrong. Have I said I really like the interview portions of this book? After enough years in this industry, I had started to say "one more language; let me take a look at it and just give me the API docs", but after reviewing these languages I see I've overlooked the huge amount of variety in the development-language world.

Erlang is a compiled language, but it provides an interpreter which Bruce uses for the earliest, shortest examples. In his Day 1, Bruce discusses atoms, variables, lists and tuples, and gives a short discussion of pattern matching (including bit matching). Day 2 starts by discussing control structures, mostly case statements but also including the if statement.

Bruce then moves on to higher-order functions, starting with anonymous functions, and discusses using functions to manage lists. Highlights include the foldl and foldr functions, as well as a brief review of Erlang's list comprehension.

On Day 3 (using Bruce's timeline), he talks about concurrency. I said earlier that Erlang looked more to lightweight process than lightweight threads as a base model. The concurrency primitives in Erlang are sending messages, spawning processes, and receiving messages. He covers pattern matching in receive loops, which have a syntax similar to case statements, then discusses the use of spawn to spawn a process. Finally, the returned process ID of the spawned process is used as the destination for messages. He walks us through an asynchronous example, followed by a simple asynchronous messaging example. He then discusses linking processes and how to handle death (exit) of a process by its linked process (a technique used to create monitoring and keep-alive services).

The end of the Erlang section covers strengths and weaknesses of the language. One weakness, if you can call it that (at least from an adoption point of view) is not being on the Java Virtual Machine. I thought of this frequently while going through the Erlang section of this book. Reading about Erlang's support for concurrency is refreshing and quite inspiring for me. However, I know that I will most likely eventually use Scala. Why? That JVM is just going to make it a lot easier to sell to management. That might be a shame, but it's kind of a fact of life. I remember really liking Smalltalk, but realizing that summer was coming to an end and going with C++ anyway. But it doesn't mean I don't still think fondly of my first Smalltalk application. :) 

From http://wayne-adams.blogspot.com/2011/04/day-5-erlang.html

Erlang (programming language)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Revoking Access to JWTs With a Blacklist/Deny List
  • Component Testing of Frontends: Karate Netty Project
  • What Developers Need to Know About Table Partition Pruning
  • Event-Driven Hello World Program

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo