<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SDLC Blog &#187; Languages</title>
	<atom:link href="http://www.rodenas.org/blog/category/languages/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rodenas.org/blog</link>
	<description>Software Development Life Cycle: Methodologies and Tools for the Enterprise</description>
	<lastBuildDate>Fri, 09 Sep 2011 12:02:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Erlang ring problem</title>
		<link>http://www.rodenas.org/blog/2007/08/27/erlang-ring-problem/</link>
		<comments>http://www.rodenas.org/blog/2007/08/27/erlang-ring-problem/#comments</comments>
		<pubDate>Mon, 27 Aug 2007 21:46:48 +0000</pubDate>
		<dc:creator>ferdy</dc:creator>
				<category><![CDATA[Languages]]></category>

		<guid isPermaLink="false">http://www.rodenas.org/blog/2007/08/27/erlang-ring-problem/</guid>
		<description><![CDATA[TweetTweetAs I am on vacation, I have had some time to read part of the Programming Erlang book I mentioned some posts ago. After reading the firsts chapters, I was surprised to see that one of the not so much mentioned Erlang central features is that relies extremely on the pattern matching idiom. Just one [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.rodenas.org/blog/2007/08/27/erlang-ring-problem/&via=ferdy&text=Erlang ring problem&related=:&lang=en&count=vertical" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.rodenas.org/blog/2007/08/27/erlang-ring-problem/&via=ferdy&text=Erlang ring problem&related=:&lang=en&count=vertical" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>As I am on vacation, I have had some time to read part of the <a href="http://www.rodenas.org/blog/2007/08/07/learning-erlang/">Programming Erlang</a> book I mentioned some posts ago. After reading the firsts chapters, I was surprised to see that one of the not so much mentioned <a href="http://www.erlang.org/">Erlang</a> central features is that relies extremely on the <a href="http://en.wikipedia.org/wiki/Pattern_matching">pattern matching</a> idiom. Just one example, the &#8220;=&#8221; operator is a pattern matching operator, which behaves like assignment when the variable is unbound, and act like a pattern matching expression when it is bound.</p>
<p>Another feature that I was glad to see is the <a href="http://en.wikipedia.org/wiki/Actor_model">actor model</a> paradigm, with messages sent from and to Actors (like <a href="http://en.wikipedia.org/wiki/Scala_%28programming_language%29">Scala</a> or <a href="http://en.wikipedia.org/wiki/Smalltalk">Smalltalk</a>) to deal with highly complex concurrency models.</p>
<p>But after playing with some of the examples that appear on the book, I found this exercise at the end of the chapter 8 :</p>
<blockquote><p>
Write a ring benchmark. Create N processes in a ring. Send a message round the ring M times so that a total of N * M messages get sent. Time how long this takes for different values of N and M.
</p></blockquote>
<p>Ok, so here it is my solution (<a href="http://www.rodenas.org/blog/wp-content/files/2007/08/ring.erl">ring.erl</a>):</p>
<pre>
-module (ring).
-export ([start/2]).

start(N, M) ->
     statistics(runtime),
     statistics(wall_clock),
     Main_process = self(),
     io:format("Creating ~p ring processes~n", [N]),
     spawn(fun() -> ring(1, N, M, self(), Main_process) end),
     receive
          ended -> void
     end,
     {_, Time1} = statistics(runtime),
     {_, Time2} = statistics(wall_clock),
     U1 = Time1,
     U2 = Time2,
     io:format("Ring benchmark for ~p processes and ~p messages =
                    ~p (~p) milliseconds~n", [N, M, U1, U2]).

ring(_, N, _, _, _) when(N =< 0)->
     io:format("Empty ring~n"),
     erlang:error(emptyRing);
ring(_, _, M, _, _) when(M =< 0)->
     io:format("No messages to send~n"),
     erlang:error(noMessagesToSend);
ring(N, N, M, First_process, Main_process) ->
     io:format("Ring process ~p (~p) created~n", [N, self()]),
     io:format("Sending ~p messages through the ring~n", [M]),
     First_process ! {send, main_process, Main_process},
     loop(M, N, N, First_process, Main_process);
ring(I, N, M, First_process, Main_process) ->
     io:format("Ring process ~p (~p) created~n", [I, self()]),
     Next_process = spawn(fun() ->
          ring(I+1, N, M, First_process, Main_process) end),
     loop(M, I, N, Next_process, Main_process).

loop(0, N, N, _, Main_process) ->
     io:format("Ring process ~p (~p) finished~n", [N, self()]),
     Main_process ! ended;
loop(0, I, _, _, _) ->
     io:format("Ring process ~p (~p) finished~n", [I, self()]);
loop(M, I, N, Next_process, Main_process) ->
     receive
          {send, From, From_process} ->
               io:format("Process ~p (~p) received message ~p
                    from process ~p (~p) ~n", [I, self(), M, From, From_process]),
               Next_process ! {send, I, self()},
               loop(M-1, I, N, Next_process, Main_process)
     end.
</pre>
<p>And here the <a href="http://spreadsheets.google.com/pub?key=pZQna6NUYg09EEhnbyMOsVw">benchmark results</a> based on Erlang R11B, two different configuration machines and running the above code but without I/O (<a href="http://www.rodenas.org/blog/wp-content/files/2007/08/ring_noio.erl">ring_noio.erl</a>):</p>
<ol>
<li>Mac OS-X 10.4.10:</li>
<ul>
<li>Processor: Intel Core 2 Duo Processor 2.2 GHz</li>
<li>Memory: 2 Gb 667 MHz DDR2</li>
</ul>
<li>Windows XP Professional SP2:</li>
<ul>
<li>Processor: AMD Athlon 64 X2 Dual Core Processor 4200+ (working each core at 2.2 GHz)</li>
<li>Memory: 2 Gb 667 MHz DDR2</li>
</ul>
</ol>
<p><a href="http://www.rodenas.org/blog/wp-content/files/2007/08/erlang-1.jpg"><img src='http://www.rodenas.org/blog/wp-content/files/2007/08/erlang-1.jpg' alt='Erlang ring problem: Benchmark' width="450" height="270" /></a></p>
<p>The exercise illustrates how long it takes to spawn a large number of processes and the cost of message passing between them. There is no parallelism in this exercise, as there is only one process active at a time (the others are waiting for a message), but demonstrates how well Erlang can deal with lots of processes and lots of sending and receiving messages. Although I believe I need to do more serious tests, creating 10.000 process and passing 100 million messages in 35 seconds is a great mark.</p>
<p>The second part of the exercise is to write a similar program in some other programming language and to compare the results. Check these links to see some results:</p>
<ul>
<li><a href="http://www.sics.se/~joe/ericsson/du98024.html">Performance Measurements of Threads in Java and Processes in Erlang</a></li>
<li><a href="http://muharem.wordpress.com/2007/07/31/erlang-vs-stackless-python-a-first-benchmark/">Erlang vs. Stackless python: a first benchmark</a></li>
<li><a href="http://weblog.plexobject.com/?p=1570">Benchmarking Java Vs Erlang</a></li>
<li><a href="http://jaortega.wordpress.com/2007/05/14/erlang-termite-and-a-blog/">Erlang, Termite and a Blog</a></li>
<li><a href="http://www.lshift.net/blog/2006/09/10/erlang-processes-vs-java-threads">Erlang processes vs. Java threads</a></li>
</ul>
<p></p>
<p>Next chapters: distributed programming, OTP and Mnesia (the Erlang Database).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rodenas.org/blog/2007/08/27/erlang-ring-problem/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Learning Erlang</title>
		<link>http://www.rodenas.org/blog/2007/08/07/learning-erlang/</link>
		<comments>http://www.rodenas.org/blog/2007/08/07/learning-erlang/#comments</comments>
		<pubDate>Tue, 07 Aug 2007 17:54:50 +0000</pubDate>
		<dc:creator>ferdy</dc:creator>
				<category><![CDATA[Languages]]></category>

		<guid isPermaLink="false">http://www.rodenas.org/blog/2007/08/07/learning-erlang/</guid>
		<description><![CDATA[TweetTweetAfter reading some exciting posts about Erlang, I decided to find out for myself what this language is all about. So I ordered Programming Erlang. Software for a Concurrent World, from the Pragmatic Bookshelf, and today I received my copy of the book. It&#8217;s about concurrency. It&#8217;s about distribution. It&#8217;s about fault tolerance. It&#8217;s about [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.rodenas.org/blog/2007/08/07/learning-erlang/&via=ferdy&text=Learning Erlang&related=:&lang=en&count=vertical" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.rodenas.org/blog/2007/08/07/learning-erlang/&via=ferdy&text=Learning Erlang&related=:&lang=en&count=vertical" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>After reading some exciting posts about <a href="http://en.wikipedia.org/wiki/Erlang_%28programming_language%29">Erlang</a>, I decided to find out for myself what this language is all about. So I ordered <a href="http://pragmaticprogrammer.com/titles/jaerlang/index.html">Programming Erlang. Software for a Concurrent World</a>, from the Pragmatic Bookshelf, and today I received my copy of the book.</p>
<blockquote>
<p>It&#8217;s about concurrency. It&#8217;s about distribution. It&#8217;s about fault tolerance. It&#8217;s about functional programming. It&#8217;s about programming a distributed concurrent system without locks and mutexes but using only pure message parsing. It&#8217;s about speeding up your programs on multi-core CPUs. It&#8217;s about writing distributed applications that allow people to interact with each other. It&#8217;s about design methods and behaviors for writing fault-tolerant and distributed systems. It&#8217;s about modeling concurrency and mapping those models onto computer programs, a process I call <i>concurrency-oriented programming</i>.</p>
</blockquote>
<p>I don&#8217;t have time right now to dive into it too deep, I just started reading the first chapter, and I am already shocked.</p>
<blockquote>
<p>Erlang has <i>single assignment variables</i>. As the name suggests, <b>single assignment variables can be given a value only once</b>. If you try to change the value of a variable once it has been set, then you&#8217;ll get an error.</p>
</blockquote>
<p>Wondering why?</p>
<blockquote>
<p>If you use a conventional programming language such as C or Java to program a multi-core CPU, then you will have to contend with the problem of <i>shared memory</i>. In order not to corrupt shared memory, the memory has to be locked while it is accessed. &#8230; In Erlang, there is no mutable state, there is no shared memory, and there are no locks. This makes it easy to parallelize our programs.</p>
</blockquote>
<p>I am sure I will have lots of fun learning it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rodenas.org/blog/2007/08/07/learning-erlang/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Esoteric programming languages</title>
		<link>http://www.rodenas.org/blog/2006/12/05/esoteric-programming-languages/</link>
		<comments>http://www.rodenas.org/blog/2006/12/05/esoteric-programming-languages/#comments</comments>
		<pubDate>Tue, 05 Dec 2006 22:46:48 +0000</pubDate>
		<dc:creator>ferdy</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[Languages]]></category>

		<guid isPermaLink="false">http://www.rodenas.org/blog/2006/12/05/esoteric-programming-languages/</guid>
		<description><![CDATA[TweetTweetWow! After studying Structured programming, Object-oriented programming and Functional programming for many years, today I&#8217;ve discovered a new programming discipline, the Esoteric programming. An esoteric programming language (aka Esolang) is a computer programming language designed to experiment with weird ideas, to be hard to program in, or as a joke, rather than for practical use. [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.rodenas.org/blog/2006/12/05/esoteric-programming-languages/&via=ferdy&text=Esoteric programming languages&related=:&lang=en&count=vertical" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.rodenas.org/blog/2006/12/05/esoteric-programming-languages/&via=ferdy&text=Esoteric programming languages&related=:&lang=en&count=vertical" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>Wow! After studying <a href="http://en.wikipedia.org/wiki/Structured_programming">Structured programming</a>, <a href="http://en.wikipedia.org/wiki/Object_oriented_programming">Object-oriented programming</a> and <a href="http://en.wikipedia.org/wiki/Functional_programming">Functional programming</a> for many years, today I&#8217;ve discovered a new programming discipline, the <a href="http://en.wikipedia.org/wiki/Esoteric_programming_language">Esoteric programming</a>.</p>
<p>An esoteric programming language (aka <em>Esolang</em>) is a computer programming language designed to experiment with weird ideas, to be hard to program in, or as a joke, rather than for practical use. Below there are some examples of &#8220;Hello World!&#8221; programs written in this kind of languages:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Brainfuck">Brainfuck</a>, which consist of only eight recognized characters:<br />
<code>++++++++++[>+++++++>++++++++++>+++>+<<<<-]<br />
>++.>+.+++++++..+++.>++.<br />
<<+++++++++++++++.>.+++.------.--------.>+.>.</code></li>
<li><a href="http://en.wikipedia.org/wiki/Befunge">Befunge</a>, where programs are arranged on a two-dimensional grid:<br />
<code>>              v<br />
v  ,,,,,"Hello"<<br />
>48*,          v<br />
v,,,,,,"World!"<<br />
>25*,@</code></li>
</ul>
<p>You&#8217;ll find the complete list at the <a href="http://esoteric.voxelperfect.net/wiki/Language_list">Esolang Community Portal</a>.</p>
<p>(Via <a href="http://ocio.barrapunto.com/ocio/06/12/04/2240238.shtml">Barrapunto</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rodenas.org/blog/2006/12/05/esoteric-programming-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello World!</title>
		<link>http://www.rodenas.org/blog/2006/11/06/hello-world/</link>
		<comments>http://www.rodenas.org/blog/2006/11/06/hello-world/#comments</comments>
		<pubDate>Mon, 06 Nov 2006 21:59:10 +0000</pubDate>
		<dc:creator>ferdy</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[Languages]]></category>

		<guid isPermaLink="false">http://www.rodenas.org/blog/2006/11/06/hello-world/</guid>
		<description><![CDATA[TweetTweetThe ACM &#8220;Hello World&#8221; project is attempting to collect examples for as many languages and related programming environments (shells etc.) as possible. Could you contribute with a new one? PD: My favourite one, the IBM 1401 self loading card.]]></description>
			<content:encoded><![CDATA[<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.rodenas.org/blog/2006/11/06/hello-world/&via=ferdy&text=Hello World!&related=:&lang=en&count=vertical" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.rodenas.org/blog/2006/11/06/hello-world/&via=ferdy&text=Hello World!&related=:&lang=en&count=vertical" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>The <a href="http://www2.latech.edu/~acm/HelloWorld.shtml">ACM &#8220;Hello World&#8221; project</a> is attempting to collect examples for as many languages and related programming environments (shells etc.) as possible. Could you contribute with a new one?</p>
<p>PD: My favourite one, the <a href="http://www2.latech.edu/~acm/helloworld/IBM1401.html">IBM 1401 self loading card</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rodenas.org/blog/2006/11/06/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cobol: a death language?</title>
		<link>http://www.rodenas.org/blog/2006/10/17/cobol-a-death-language/</link>
		<comments>http://www.rodenas.org/blog/2006/10/17/cobol-a-death-language/#comments</comments>
		<pubDate>Mon, 16 Oct 2006 22:43:03 +0000</pubDate>
		<dc:creator>ferdy</dc:creator>
				<category><![CDATA[Languages]]></category>

		<guid isPermaLink="false">http://www.rodenas.org/blog/2006/10/17/cobol-a-death-language/</guid>
		<description><![CDATA[TweetTweetA recent survey, conducted by Computerworld at 352 companies, revealed that a lot of them are still using Cobol actively. &#8220;A lot of people have said they were going to get rid of the mainframe, but that hasn&#8217;t happened. And for us, all that code is working. There&#8217;s no sense in rewriting it.&#8221; &#8220;For years, [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.rodenas.org/blog/2006/10/17/cobol-a-death-language/&via=ferdy&text=Cobol: a death language?&related=:&lang=en&count=vertical" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://www.rodenas.org/blog/2006/10/17/cobol-a-death-language/&via=ferdy&text=Cobol: a death language?&related=:&lang=en&count=vertical" class="twitter-share-button">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>A recent survey, conducted by <a href="http://www.computerworld.com/">Computerworld</a> at 352 companies, revealed that a lot of them are still using <a href="http://en.wikipedia.org/wiki/COBOL">Cobol</a> actively.</p>
<blockquote><p>&#8220;A lot of people have said they were going to get rid of the mainframe, but that hasn&#8217;t happened. And for us, all that code is working. There&#8217;s no sense in rewriting it.&#8221;</p></blockquote>
<blockquote><p>&#8220;For years, pundits have said that the way to avoid the headaches of maintaining Cobol &#8211; and mainframes, green screens and other legacy paraphernalia &#8211; is to replace them. But that hasn&#8217;t happened, even in the massive Y2k remediation effort.&#8221;</p></blockquote>
<p>But the most amazing fact of all is that <b>58% said they&#8217;re using it to develop new applications</b>. Viva Cobol!</p>
<p>See the full report at <a href="http://www.computerworld.com/action/article.do?command=viewArticleBasic&#038;articleId=266228">Cobol Coders: Going, Going, Gone?</a></p>
<p>(Via <a href="http://mainframe.typepad.com/blog/2006/10/day_of_the_dead.html">Mainframe</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rodenas.org/blog/2006/10/17/cobol-a-death-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

