Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang Code Snippet that shows off its benefits?

Tags:

erlang

I'm giving a small presentation to a group of C/C++ programmers who have very little experience with functional languages. Part of the presentation mentions Erlang, and I would like to give a specific small code example.

There is a ton of awesome information on StackOverflow about how/where Erlang is used and its advantages. One of the most common advantages I see is how it can do a lot with just a little terse code, especially compared to C/C++.

I am looking for a good code snippet of Erlang that simply illustrates these types of benefits. Especially something thats easily done in Erlang with few lines, that would be much more complicated in C/C++.

Anyone have any interesting suggestions?

like image 282
Lima Beans Avatar asked Oct 04 '11 01:10

Lima Beans


Video Answer


2 Answers

Check out example 4 for an excellent example of Erlang's bit syntax. I'm sure there are a number of c/c++ developers that will appreciate the brevity of the syntax!

like image 73
Refefer Avatar answered Oct 10 '22 15:10

Refefer


I would use an example which shows how easy it is to do concurrency.

So basically write map-reduce (but never ever use that word to describe it to a C programmer).

You could start with showing a program that plays Fizz Buzz, and then proceed to make it concurrent. Should easily fit a whiteboard, or two pages of powerpoint.

like image 3
Daniel Luna Avatar answered Oct 10 '22 14:10

Daniel Luna