<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<feed xmlns="http://www.w3.org/2005/Atom">

	<title>Unofficial Erlang Planet</title>
	<link rel="self" href="http://www.erlangplanet.org/atom.xml"/>
	<link href="http://www.erlangplanet.org/"/>
	<id>http://www.erlangplanet.org/atom.xml</id>
	<updated>2009-01-06T21:31:04+00:00</updated>
	<generator uri="http://www.planetplanet.org/">Planet/2.0 +http://www.planetplanet.org</generator>

	<entry>
		<title type="html">Avoiding Erlang deadlocks</title>
		<link href="http://mue.tideland.biz/2009/01/avoiding-erlang-deadlocks.html"/>
		<id>tag:blogger.com,1999:blog-7840321658785378959.post-5349777312578170403</id>
		<updated>2009-01-06T18:33:01+00:00</updated>
		<content type="html">&lt;div&gt;A friend of mine - a long time and very good Java developer - mentioned in his blog that Erlang can produce deadlocks too. In his example a process &lt;strong&gt;A&lt;/strong&gt; send a message to process &lt;strong&gt;B&lt;/strong&gt; and waits for a reply. During the processing of the message in process &lt;strong&gt;B&lt;/strong&gt; this one sends a message to process &lt;strong&gt;A&lt;/strong&gt; and waits for a reply too. But this message won't be processed due to the waiting of process &lt;strong&gt;A&lt;/strong&gt;. And indeed, even if this example is trivial, he's right. The situation may for example be more complex, with a circle of several dozen processes all sending synchronous requests until the lock occurs.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;But the model behind Erlang isn't the traditional request/response way like it is done between instances in OOP. It's more like a communication between colleagues in a bureau all busy doing their stuff. Sometimes one has a question. He may ask his co-worker and wait for an answer, and waits, and waits, and waits. But at some point it will be enough and he will react, through asking somebody else, through asking again, or through throwing a book at his colleague. &lt;strong&gt;*smile*&lt;/strong&gt; That's like using a &lt;code&gt;timeout&lt;/code&gt; in a &lt;code&gt;receive&lt;/code&gt; statement, or the default behaviour of &lt;code&gt;gen_server:call()&lt;/code&gt;. No deadlock, no endless waiting like a dumb sheep - hmm, even those won't wait very long.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Another way would just continue doing the own work until the answer comes. This is highly asynchronous and needs to split the logic into small pieces and to remember the question in the state of the process. This way processes could juggle multiple tasks. Using OTP with supervisor trees and &lt;code&gt;gen_fsm&lt;/code&gt; for state machines helps a lot here. Additionally if needed all those concurrent working processes may share a process with a pure getting and setting functionallity for common status data or they may use one or more ets tables.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;So, once again, yes it is possible to produce deadlocks in Erlang. But the way to produce it is an improper way of developing in Erlang. Using &lt;code&gt;receive&lt;/code&gt; with &lt;code&gt;timeout&lt;/code&gt; or using the OTP default timout behaviour - no calls with the argument &lt;code&gt;infinity&lt;/code&gt; - is the first step, create solutions using the concurrency right the second one.&lt;/div&gt;</content>
		<author>
			<name>mue</name>
			<email>noreply@blogger.com</email>
			<uri>http://mue.tideland.biz/</uri>
		</author>
		<source>
			<title type="html">mue - embrace change</title>
			<subtitle type="html">Observations and opinions about a volatile world</subtitle>
			<link rel="self" href="http://mue.tideland.biz/feeds/posts/default"/>
			<id>tag:blogger.com,1999:blog-7840321658785378959</id>
			<updated>2009-01-06T21:30:49+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">Common Erlang misconceptions</title>
		<link href="http://jlouisramblings.blogspot.com/2009/01/common-erlang-misconceptions.html"/>
		<id>tag:blogger.com,1999:blog-5411139659011156551.post-2356426159531316603</id>
		<updated>2009-01-06T08:34:05+00:00</updated>
		<content type="html">There is a common saying that Erlangs I/O layer is slow. Bullshit. The etorrent program can easily sustain 70 megabit with less than 5% of CPU usage on my old machines. The reason is that etorrent is shuffling 16k binary blocks around mostly. But that means you have a pointer to each 16k block and you are only a writev(2) call away from the disk.&lt;br /&gt;&lt;br /&gt;This means I/O is not itself a problem. The problem that people often hit is Erlangs string handling. In Erlang a string can either by represented as an &lt;span&gt;immutable &lt;/span&gt;array of 8-bit characters, called a binary; or it can be represented as a list of integers (ie, a linked list of integers). The latter is mutable in the sense that you can generate new integers and update the linked list from the front only.&lt;br /&gt;&lt;br /&gt;Whenever you mutate the list of integers, garbage is generated. Allocation will happen and this directly translates to more garbage collection pressure later on. Had you had destructible arrays in Erlang it would have been very easy to circumvent the worst performance problems, but you will have to do with a limited zoo of types. In better languages, like Ocaml, Standard ML or Haskell, your type zoo is much richer here. You can choose between several immutable and mutable variants so the leverage is much greater.&lt;br /&gt;&lt;br /&gt;First trick: Erlang has the concept of an IO list. These are lists of binary/string chunks. They are fast because they lend themselves to a writev(2) in the bottom of the system. Thus you don't have to concatenate strings in the Erlang language but you can hand a quasi-concatenated list to the VM and let C do the heavy-lifting for you.&lt;br /&gt;&lt;br /&gt;Second trick: Mutating data as strings is slow. But if you have a abstract tree of tuples then it can be manipulated fast. If you think about the command &lt;span&gt;[Bin | IOList] &lt;/span&gt;where we add a Binary to the front of an IOList, you'll know it happens in O(1) (constant) time. If we build a tuple &lt;span&gt;{atom, D1, D2, ...}, &lt;/span&gt;we can build it in constant time. So the trick is to maintain your data in a &lt;span&gt;non-string &lt;/span&gt;form for as long as possible and then only change it to a string at the very last point in time.&lt;br /&gt;&lt;br /&gt;Third trick: Correct data structure. Ropes. Finger Trees. M-way trees. Don't brute force yourself over a string. Process the structure by pattern matching in a clever way so you minimize the amount of change needed. A good tree will have around logarithmic change whereas a list will have linear change. This leads to the next point: allocation.&lt;br /&gt;&lt;br /&gt;Another crap problem in Erlang is that you have few (traditional) ways to minimize &lt;span&gt;allocation. &lt;/span&gt;Any kind of operation will allocate data if you are not wary of it. Hence you should try to build programs that do not gloss over data and allocate all the time. Mapping of lists via list comprehensions is a good example. It is easy to understand but it will build a new list and garbage collection will cost you. If you can do multiple things in one list comprehension, you win traversals and allocations.&lt;br /&gt;&lt;br /&gt;Whenever I hear about &quot;Slow string processing&quot; in Erlang I immediately think: &quot;Another Ruby programmer trying to cram his language into Erlang&quot;. If you hit slowness the trick in Erlang is to redefine the problem! Don't try to string process yourself into oblivion. If the sole thing your problem concerns is string-processing, go use perl. Please. Or be clever and use Ocaml. Pre-process the data in other languages and make them into erlang terms which can be read fast by erlang. Erlangs power is the concurrency at which it is really good. There were no reason for giving it fast string processing.&lt;br /&gt;&lt;br /&gt;Also, don't get bitten by the mnesia bug, please. It is almost always the case that mnesia and ETS are the wrong way to go. I got bitten by it multiple times in etorrent and now I am contemplating ripping all of it out again. Plain old data structures baby! There are some nasty caveats to mnesia and ETS and they are not related to the size limit of the database.&lt;br /&gt;&lt;br /&gt;For mnesia, be aware that a failed transaction will be re-run! Now take 100 transactions tripping over each other. They will &lt;span&gt;never&lt;/span&gt; finish. Etorrent did that when peers should update their state. Instant snail-speed application. Mnesia is crap at doing joins. Just forget it.&lt;br /&gt;&lt;br /&gt;ETS is also problematic: Any store or get from ETS means a data copy. Don't do as etorrent and add large rows (128k+) to ETS. Your app will come to a grinding halt.&lt;br /&gt;&lt;br /&gt;Don't message big data structures around. Any message incurs a copy (in the default VM). If you need to work with a big data structure, shove it into a process and then send the Pid of that process around or register him globally. You can think of a Pid as &quot;Passing a pointer around&quot; in this case.&lt;br /&gt;&lt;br /&gt;And finally: Measure measure measure! Be scientific about your performance problems. You need to know exactly what causes it before jumping to conclusions. And don't worry too much about being parallel at the beginning. You can always split things up in finer granularity later.</content>
		<author>
			<name>Jlouis</name>
			<email>noreply@blogger.com</email>
			<uri>http://jlouisramblings.blogspot.com/</uri>
		</author>
		<source>
			<title type="html">JLOUIS Ramblings</title>
			<subtitle type="html">Musings of a mathematically oriented Computer Scientist. Anything that tickles my brain might go in here, be it Computer Science, mathematics, society, relationships, sex, 0xf00d, or pets.</subtitle>
			<link rel="self" href="http://jlouisramblings.blogspot.com/feeds/posts/default"/>
			<id>tag:blogger.com,1999:blog-5411139659011156551</id>
			<updated>2009-01-06T20:46:08+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en-us">
		<title type="html">Couch Book Progress</title>
		<link href="http://jchris.mfdz.com/posts/137"/>
		<id>http://jchris.mfdz.com/posts/137</id>
		<updated>2009-01-05T20:03:29+00:00</updated>
		<content type="html">&lt;p&gt;It&amp;#8217;s been a few weeks since we released the initial chapters of &lt;a href=&quot;http://books.couchdb.org&quot;&gt;O&amp;#8217;Reilly&amp;#8217;s CouchDB book.&lt;/a&gt; The next release ought to be happening &amp;#8220;soon&amp;#8221; &amp;#8211; There&amp;#8217;s more work to be done on it, but the major skeleton of the chapters has been written, and the figures drawn.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m posting the outline of the next section, so that people&amp;#8217;s expectations about the book are inline with what we provide. The next released section will be a few chapters walking through the creation of a simple web app (yes, a weblog). The point is not to teach Ajax, but to teach the CouchDB &lt;span class=&quot;caps&quot;&gt;HTTP API&lt;/span&gt; in a hands on way.&lt;/p&gt;


	&lt;p&gt;Yes, all the code runs, and the in-progress version of &lt;a href=&quot;http://github.com/jchris/couchdb-example-blog/tree/master&quot;&gt;the example blog is even available on github.&lt;/a&gt; One of my main tasks between now and the release is to make the installation proceedure &lt;strong&gt;much easier&lt;/strong&gt;. So you are welcome to play now, but if it seems messy or confusing, please try again when the chapters are released.&lt;/p&gt;


	&lt;p&gt;If anyone has input on pacing and ordering of the example
application I&amp;#8217;d love to hear it. I think this section should be
relatively fast-paced, and focussed on how easy it is to build
applications using CouchDB, with the occasional bits of &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;
specification or deeper material presented as asides and sidebars.&lt;/p&gt;


	&lt;h3&gt;2. Learning CouchDB&lt;/h3&gt;


	&lt;h4&gt;Touring the Futon Administration Interface&lt;/h4&gt;


	&lt;p&gt;A survey of CouchDB&amp;#8217;s http api, through the eyes of Futon. Touches
on most of the core concepts. This material is might be better suited
for Section 1, as it does stand alone as an introduction to the http
&lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;.&lt;/p&gt;


	&lt;h4&gt;Introducing the Example Blog&lt;/h4&gt;


	&lt;p&gt;Why we chose JavaScript for the book examples. Also: even if you are
storing scientific data, what you&amp;#8217;ll learn by following along is
applicable (views, document semantics, design docs).&lt;/p&gt;


	&lt;h4&gt;Setting Up Your Development Environment&lt;/h4&gt;


	&lt;p&gt;Getting the example app to your local drive, and being able to push
it to CouchDB. Also cover design-doc / application correspondence
while explaining the couchapp script.&lt;/p&gt;


	&lt;h4&gt;Storing Blog Posts in CouchDB&lt;/h4&gt;


	&lt;p&gt;The &lt;span class=&quot;caps&quot;&gt;JSON&lt;/span&gt; doc format, validation functions, plus the &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; and
Javascript it takes to support the blog post form. (This will be a
longer one, but the code for it shouldn&amp;#8217;t be changing.)&lt;/p&gt;


	&lt;h4&gt;Rendering Documents with CouchDB Forms&lt;/h4&gt;


	&lt;p&gt;What forms are. Why they have the single-doc constraint. Mention
that you can write raw JS, but then show CouchApp&amp;#8217;s require / include
system as a best practice, using templates and a basic templating
engine.&lt;/p&gt;


	&lt;h4&gt;Browsing Recent Posts with Map Views&lt;/h4&gt;


	&lt;p&gt;Introduce a simple view by published at date. Show basics of
pagination. Explain the view-query &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; by looking at the JavaScript
client &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; used to query the view.&lt;/p&gt;


	&lt;p&gt;Mention that there will be forms for views in the future, so that
this page can be served as &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; as well. (Forms for views should be in
Couch 1.0 &amp;#8211; and thus in the book, so polishing this section now is
lower priority. Pagination will also be easier with view forms)&lt;/p&gt;


	&lt;h4&gt;Accepting Reader Comments&lt;/h4&gt;


	&lt;p&gt;The &lt;span class=&quot;caps&quot;&gt;JSON&lt;/span&gt; format, validations, and the &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; form for updating a
comment. This is a short one, mostly repeats what happened in &amp;#8220;Storing
Blog Posts in CouchDB&amp;#8221; but its the second time, so we can touch on
different aspects and explain other &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; details. (One neat difference
is that we&amp;#8217;re adding Javascript behavior to a page that was rendered
as a CouchDB form, rather than a static document.)&lt;/p&gt;


	&lt;h4&gt;Listing Related Comments Using View Collation and Compound Keys&lt;/h4&gt;


	&lt;p&gt;&lt;em&gt;(I didn&amp;#8217;t say &amp;#8220;joins&amp;#8221;) ;)&lt;/em&gt;&lt;/p&gt;


	&lt;p&gt;Currently this uses an Ajax query that lists comments by [post_id,
date]. When view forms are available, we&amp;#8217;ll change it to &lt;a href=&quot;http://www.cmlenz.net/archives/2007/10/couchdb-joins&quot;&gt;Christopher Lenz&amp;#8217;s
query,&lt;/a&gt; which includes the post itself, so the whole thing can be
rendered in a single request. This chapter works on the same files as
the previous chapter, they could be &amp;#8220;joined&amp;#8221; but I think this is
material we should take the space to cover as clearly as possible.&lt;/p&gt;


&lt;hr /&gt;


	&lt;p&gt;If you&amp;#8217;ve gotten this far, then you must be seriously interested in CouchDB. If you are, then you should familiarize yourself with the &lt;a href=&quot;http://svn.apache.org/repos/asf/couchdb/trunk/share/www/script/couch_tests.js&quot;&gt;test suite.&lt;/a&gt; It&amp;#8217;s written in JavaScript, so anyone can understand it, and it&amp;#8217;s the main gateway for new features. Plus, code speaks louder than words.&lt;/p&gt;</content>
		<author>
			<name>Chris Anderson</name>
			<uri>http://jchris.mfdz.com/posts</uri>
		</author>
		<source>
			<title type="html">Daytime Running Lights : Coding</title>
			<link rel="self" href="http://jchris.mfdz.com/xml/rss20/feed.xml"/>
			<id>http://jchris.mfdz.com/xml/rss20/feed.xml</id>
			<updated>2009-01-06T21:30:45+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">Higher Order abstractions in Scala with Type Constructor Polymorphism</title>
		<link href="http://debasishg.blogspot.com/2009/01/higher-order-abstractions-in-scala-with.html"/>
		<id>tag:blogger.com,1999:blog-22587889.post-4924208956799352292</id>
		<updated>2009-01-05T12:25:08+00:00</updated>
		<content type="html">Abstractions at a higher level through type constructor polymorphism. Good type systems are expressive enough to conceal the implementation complexity, and expose *only* what it matters to the developer. People often cringe about the complexity of Scala's type system and how it serves as a barrier to the entry point in mainstream programming. As Michael Feathers recently &lt;a href=&quot;http://twitter.com/mfeathers/status/1088198974&quot;&gt;noted&lt;/a&gt; on Tweeter, the unfortunate fact is that people often jump at the esoteric parts of a language before looking at the simpler subset, which he will be using 90% of the time. And, I think Scala has that sweet spot, where you need not mess around too much with variances, implicits and existentials and yet come up with a nice, concise and functional codebase. &lt;br /&gt;&lt;br /&gt;In this post, I discuss the already introduced intimidating phrase &quot;Type Constructor Polymorphism&quot; through a series of code snippets ranging from toys to some real-world stuff. The idea is, once again, not to evangelize type theory intricacies, but share some of the experiences of how this feature in Scala's type system can help write idiomatic code, while staying away from the complexities of its underlying implementation.&lt;br /&gt;&lt;br /&gt;Jump on .. &lt;br /&gt;&lt;br /&gt;We have a list of &lt;code&gt;Option[String]&lt;/code&gt; that we need to abstract over and compute some value. Say, for the sake of keeping the example simple, we will calculate the sum of lengths of all the strings present ..&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span class=&quot;java_keyword&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;employees&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;dave&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;john&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;sam&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;n&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&amp;nbsp;employees&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;map&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;x&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;name&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;length&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;}.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;reduceLeft&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;](&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;_&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;_&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Let us take another problem that needs to abstract over a different &lt;code&gt;List&lt;/code&gt; structure, a &lt;code&gt;List&lt;/code&gt; of &lt;code&gt;List&lt;/code&gt; of &lt;code&gt;String&lt;/code&gt;s, and compute the same result as before, i.e. the sum of lengths of all the strings encountered in the collection ..&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span class=&quot;java_keyword&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;brs&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;dave&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;john&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;sam&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;peter&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;robin&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;david&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;pras&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;srim&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;m&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&amp;nbsp;brs&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;flatMap&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;x&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;x&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;map&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;reduceLeft&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;](&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;_&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;_&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Do you see any commonality in the solution structure in the above snippets ? After all, the problem space has a common generic structure ..&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;we have a &lt;code&gt;List&lt;/code&gt; with some &lt;code&gt;String&lt;/code&gt; values abstracted in different forms&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;need to iterate over the list&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;do some stuff with elements in the list and compute an &lt;code&gt;Int&lt;/code&gt; value&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;Unfortunately the actual solution structures look quite different and have to deal a lot digging into the abstractions of the underlying representations within the collection itself. And this is because, we cannot abstract over the type constructor (the List in this case) that takes another type constructor as an argument (&lt;code&gt;Option[String]&lt;/code&gt; in the first case and &lt;code&gt;List[String]&lt;/code&gt; in the second case).&lt;br /&gt;&lt;br /&gt;Enter type constructor polymorphism. &lt;br /&gt;&lt;br /&gt;Sounds intimidating ? Maybe, but ask the Haskellers .. they have been using typeclasses ever since so successfully in comprehensions, parser combinators and embedded DSLs and programming at a different level of abstraction.&lt;br /&gt;&lt;br /&gt;Scala supports type constructor polymorphism since 2.5, and the details have been discussed in a recent &lt;a href=&quot;http://www.cs.kuleuven.be/~adriaan/?q=genericshk&quot;&gt;paper&lt;/a&gt; by Adriaan Moors et al in OOPSLA 2008.&lt;br /&gt;&lt;br /&gt;Here is a snippet of the Scala code that works seamlessly for both of the above cases ..&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span class=&quot;java_keyword&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;l&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;employees&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;flatMapTo&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;]{&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;sum&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;l&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;reduceLeft&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;](&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;_&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;_&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;  &lt;br /&gt;The above code abstracts over &lt;code&gt;List&lt;/code&gt; through higher order parametric polymorphism, i.e. independent of whether the List parameter is an &lt;code&gt;Option[]&lt;/code&gt; or another &lt;code&gt;List[]&lt;/code&gt;. Incidentally both of them (&lt;code&gt;List&lt;/code&gt; and &lt;code&gt;Option&lt;/code&gt;) are monads and flatMapTo abstracts a monadic computation, hiding all details of type constructor polymorphism from the developer.&lt;br /&gt;&lt;br /&gt;Now here is some real life example (elided for simplicity) ..&lt;br /&gt;&lt;br /&gt;Here are the simple domain models for &lt;code&gt;Customer&lt;/code&gt;, &lt;code&gt;Instrument&lt;/code&gt; and &lt;code&gt;Trade&lt;/code&gt;, used for modeling a use case where a &lt;code&gt;Customer&lt;/code&gt; can order for the &lt;code&gt;Trade&lt;/code&gt; of an &lt;code&gt;Instrument&lt;/code&gt; in an exchange.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span class=&quot;java_keyword&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Customer&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;name&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;nomura&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Customer&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;NOMURA&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;meryll&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Customer&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;MERYLL&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;lehman&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Customer&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;&amp;quot;LEHMAN&amp;quot;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Instrument&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;ibm&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Instrument&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;sun&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Instrument&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;google&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Instrument&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Trade&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;ref&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;ins&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Instrument&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;qty&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;price&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;And we fetch the following list through a query from the database. It is a &lt;code&gt;List&lt;/code&gt; of tuples where each tuple consists of a &lt;code&gt;Customer&lt;/code&gt; and a trade that has been executed based on the &lt;code&gt;Order&lt;/code&gt; he placed at the exchange. And here is the snippet of the code that computes the sum total of the values of all trades executed in the day for all customers.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span class=&quot;java_keyword&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;trades&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Customer&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Trade&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;])]&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;nomura&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Trade&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;ibm&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;))),&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;meryll&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;lehman&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Some&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Trade&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;google&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_literal&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;))))&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;ts&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Option&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Trade&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;trades&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;_2&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;t&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;ts&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;flatMapTo&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;]{&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;x&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;x&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;qty&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;x&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;}}&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_keyword&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;value&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;t&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;reduceLeft&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;java_type&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;](&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;_&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;java_operator&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&amp;nbsp;_&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;java_plain&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;java_separator&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;java_plain&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Really not much different from the above simple cases where we were dealing with toy examples - isn't it ? The structure of the solution is the same irrespective of the complexity of data being stored within the collections. The iteration is being done at a much higher level of abstraction, independent of the types stored within the container. And as I mentioned above, &lt;code&gt;flatMapTo&lt;/code&gt; is the secret sauce in the above solution structure that abstracts the building of the new container hiding the inner details. To get more into the innards of &lt;code&gt;flatMapTo&lt;/code&gt; and similar higher order abstractions, including the new form of &lt;code&gt;Iterable[+T]&lt;/code&gt;, have a look at the OOPSLA paper referenced above.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Postscript:&lt;/b&gt;&lt;/i&gt; In all the snippets above, I have been explicit about all type signatures, just for the sake of easier understanding of my passionate reader. In reality, almost all of these will be inferred by Scala.</content>
		<author>
			<name>Debasish</name>
			<email>ghosh.debasish@gmail.com</email>
			<uri>http://debasishg.blogspot.com/</uri>
		</author>
		<source>
			<title type="html">Ruminations of a Programmer</title>
			<subtitle type="html">A programmer's blog - will deal with everything that relates to a programmer. Occasionally, it will contain some humour, some politics and some sport news.</subtitle>
			<link rel="self" href="http://debasishg.blogspot.com/feeds/posts/default?alt=rss"/>
			<id>tag:blogger.com,1999:blog-22587889</id>
			<updated>2009-01-06T21:15:03+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Large set of ejabberd resources</title>
		<link href="http://www.process-one.net/en/blogs/article/large_set_of_ejabberd_resources/"/>
		<id>tag:process-one.net,2009:en/blogs/3.457</id>
		<updated>2009-01-05T10:01:05+00:00</updated>
		<content type="html">Planet Erlang is fastly becoming a large index for Erlang projects resources, including ejabberd. &lt;p&gt;Since its relaunch, &lt;a href=&quot;http://www.planeterlang.org&quot;&gt;Planet Erlang&lt;/a&gt; is now indexing content from tens of Erlang related blogs. Thank to its search engine, you can now find many blog posts and articles on lots of different Erlang topic. ejabberd is one of the most covered topic there.&lt;/p&gt;
&lt;p&gt;You should have a look and try searching for ejabberd in the search engine (search field on the right).&lt;/p&gt;
&lt;p&gt;The list of resources is growing every day as we are adding even more older resources.&lt;/p&gt;
&lt;p&gt;Your comments and feature requests are welcome !&lt;/p&gt;</content>
		<author>
			<name>Mickaël Rémond</name>
			<uri>http://www.process-one.net/en/blogs/</uri>
		</author>
		<source>
			<title type="html">ProcessOne Blogs</title>
			<subtitle type="html">ProcessOne Blogs:ProcessOne Blogs</subtitle>
			<link rel="self" href="http://www.process-one.net/en/blogs/atom/"/>
			<id>tag:process-one.net,2009:01:05</id>
			<updated>2009-01-05T10:01:42+00:00</updated>
			<rights type="html">Copyright (c) 2009, ProcessOne</rights>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Sendfile for Yaws</title>
		<link href="http://steve.vinoski.net/blog/2009/01/05/sendfile-for-yaws/"/>
		<id>http://steve.vinoski.net/blog/?p=211</id>
		<updated>2009-01-05T07:22:54+00:00</updated>
		<content type="html">&lt;p&gt;A few months back Klacke gave me committer rights for &lt;a href=&quot;http://yaws.hyber.org/&quot;&gt;Yaws&lt;/a&gt;. I&amp;#8217;ve made a few fixes here and there, including adding support for &lt;a href=&quot;http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.2&quot;&gt;passing &amp;#8220;*&amp;#8221; as the request URI for OPTIONS&lt;/a&gt;, enabling OPTIONS requests to be dispatched to &lt;a href=&quot;http://yaws.hyber.org/appmods.yaws&quot;&gt;appmods&lt;/a&gt; and &lt;a href=&quot;http://yaws.hyber.org/yapp_intro.yaws&quot;&gt;yapps&lt;/a&gt;, and completing a &lt;a href=&quot;http://sourceforge.net/mailarchive/forum.php?thread_name=48DA651E.80708%40lionet.info&amp;forum_name=erlyaws-list&quot;&gt;previously-submitted patch for configuring the listen backlog&lt;/a&gt;. Klacke has just started putting a test framework into the codebase and build system so that contributors can include tests with any patches or new code they submit, and I&amp;#8217;ve contributed to that as well.&lt;/p&gt;
&lt;p&gt;The biggest feature I&amp;#8217;ve added to date, though, is a new linked-in driver that allows Yaws to use the &lt;a href=&quot;http://www.freebsd.org/cgi/man.cgi?query=sendfile&amp;sektion=2&quot;&gt;sendfile system call&lt;/a&gt; on Linux, OS X, and FreeBSD. I never wrote a linked-in driver before, so I was happy and fortunate to have an Erlang expert like Klacke providing hints and reviewing my code.&lt;/p&gt;
&lt;p&gt;I did some preliminary testing that showed that sendfile definitely improves CPU usage across the board but depending on file size, sometimes does so at the cost of increasing request times. I used my otherwise idle 2-core 2.4GHz Ubuntu 8.04.1 Dell box with 2 GB of RAM, and ran Apache Bench (ab) from another Linux host to simulate 50 concurrent clients downloading a 64k data file a total of 100000 times. I saw that user/system CPU on the web host tended to run around 33%/28% without sendfile, while with sendfile it dropped to 22%/17%. The trade-off was request time, though, where each request for the 64k file averaged 0.928ms with sendfile but 0.567ms without. With larger files, however, sendfile is slightly faster and still has better CPU usage. For example, with a 256k file, sendfile averaged 2.251ms per request with user/system CPU at 8%/16% whereas it was 2.255ms and 16%/27% CPU without sendfile, which makes me wonder if the figures for the 64k file are outliers for some reason. I performed these measurements fairly quickly, so while I believe they&amp;#8217;re reasonably accurate, don&amp;#8217;t take them as formal results.&lt;/p&gt;
&lt;p&gt;On my MacBook Pro laptop running OS X 10.5.6, CPU usage didn&amp;#8217;t seem to differ much whether I used sendfile or not, but requests across the board tended to be slightly faster with sendfile.&lt;/p&gt;
&lt;p&gt;I ran FreeBSD 7.0.1 in a Parallels VM on my laptop, and there I saw significantly better system CPU usage with sendfile than without, sometimes as much as a 30% improvement. Requests were also noticeably faster with sendfile than without, sometimes by as much as 17%, and again depending on file size, with higher improvements for larger files. User CPU was not a factor. All in all, though, I don&amp;#8217;t know how much the fact that I ran all this within a VM affected these numbers.&lt;/p&gt;
&lt;p&gt;Given that Yaws is often used for delivering mainly dynamic content, sendfile won&amp;#8217;t affect those cases. Still, I think it&amp;#8217;s nice to have it available for the times when you do have to deliver file-based content, especially if the files are of the larger variety. Anyway, I committed this support to the &lt;a href=&quot;http://erlyaws.svn.sourceforge.net/viewvc/erlyaws/trunk/yaws/&quot;&gt;Yaws svn repository&lt;/a&gt; back around December 21 or so. If you&amp;#8217;d like to do your own testing, please feel free &amp;mdash; I&amp;#8217;d be interested in learning your results. Also, if you have ideas for further tests I might try, please leave a comment to let me know.&lt;/p&gt;</content>
		<author>
			<name>steve</name>
			<uri>http://steve.vinoski.net/blog</uri>
		</author>
		<source>
			<title type="html">Steve Vinoski's Blog</title>
			<subtitle type="html">Ask forgiveness, not permission.</subtitle>
			<link rel="self" href="http://steve.vinoski.net/blog/feed/atom/"/>
			<id>http://steve.vinoski.net/blog/feed/atom/</id>
			<updated>2009-01-05T07:30:25+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">I suck</title>
		<link href="http://feeds.feedburner.com/~r/TenerifeSkunkworks/~3/498842461/i-suck.html"/>
		<id>tag:typepad.com,2003:post-60600442</id>
		<updated>2009-01-05T05:12:34+00:00</updated>
		<content type="html" xml:lang="en-US">&lt;div&gt;&lt;p&gt;I seem to be particularly good at picking very narrow, most likely unprofitable niches. A translator from a particular trading language to another product with a much smaller user base is one example, writing Mac OSX device drivers is another one.&lt;/p&gt;
&lt;p&gt;If I were a trader, I could short myself and do the opposite of any idea I came up with. How do I apply this strategy to business, though?&lt;/p&gt;

&lt;p&gt;On a different tangent, this blog gained about 100 more subscribers to this blog all of a sudden, whereas &lt;a href=&quot;http://thinkerlang.com&quot;&gt;Think Erlang&lt;/a&gt; has less than 100 subscribers a few weeks after launch.&lt;/p&gt;

&lt;p&gt;Should I assume that you are not here to read about my Erlang progress but rather about my multi-language antics? Let me know!&lt;/p&gt;

&lt;p&gt;I'm about to dive into Linux device drivers, Forth, low-power embedded devices, FPGAs, marine electronics and navigation software. I hope you'll still be around in a year! :D&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update 1:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whipsawing back and forth too much between ideas is a side effect of being burned by OpenPoker, which I spent way too much time on. It's a disaster from a commercial point of view and so whenever I sense that an idea may turn out to be unprofitable, I drop it like a hot potato.&lt;/p&gt;

&lt;p&gt;Granted, I may not be giving ideas enough time to develop and should probably have a method of delivering bare-bones working implementations, if only to see them fail quickly.&lt;/p&gt;

&lt;p&gt;As for sticking with one language, it just doesn't work, period. There's a language for every task. &lt;/p&gt;

&lt;p&gt;Mac OSX device drivers (IOKit) are programmed in C++, Linux device drivers in C. FPGAs are programmed in VHDL and Forth is an excellent tool to program cheap low-power controllers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;http://www.facebook.com/photo.php?pid=1782864&amp;l=d3d08&amp;id=517973124&quot;&gt;baby&lt;/a&gt; less than two months old so I'm a little foggy. Still, I think I have reached enlightenment on at least one issue. &lt;/p&gt;

&lt;p&gt;I'll short myself on device drivers...&lt;/p&gt;

&lt;p&gt;Hot: Linix. 
Not: Mac and IOKit.&lt;/p&gt;

&lt;div&gt;
&lt;a href=&quot;http://www.indeed.com/jobtrends?q=linux+device+driver%2C+mac+iokit&quot; title=&quot;linux device driver, mac iokit Job Trends&quot;&gt;
&lt;img width=&quot;540&quot; height=&quot;300&quot; src=&quot;http://www.indeed.com/trendgraph/jobgraph.png?q=linux+device+driver%2C+mac+iokit&quot; border=&quot;0&quot; alt=&quot;linux device driver, mac iokit Job Trends graph&quot; /&gt;
&lt;/a&gt;
&lt;table width=&quot;100%&quot; cellpadding=&quot;6&quot; cellspacing=&quot;0&quot; border=&quot;0&quot;&gt;&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;http://www.indeed.com/jobtrends?q=linux+device+driver%2C+mac+iokit&quot;&gt;linux device driver, mac iokit Job Trends&lt;/a&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;&lt;a href=&quot;http://www.indeed.com/q-linux-device-driver-jobs.html&quot;&gt;linux device driver jobs&lt;/a&gt; - &lt;a href=&quot;http://www.indeed.com/q-mac-iokit-jobs.html&quot;&gt;mac iokit jobs&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;img src=&quot;http://feeds.feedburner.com/~r/TenerifeSkunkworks/~4/498842461&quot; height=&quot;1&quot; width=&quot;1&quot; /&gt;</content>
		<author>
			<name>Joel Reymont</name>
			<uri>http://www.wagerlabs.com/blog/</uri>
		</author>
		<source>
			<title type="html">Tenerife Skunkworks</title>
			<subtitle type="html">Ramblings on programming languages and technology</subtitle>
			<link rel="self" href="http://www.wagerlabs.com/blog/atom.xml"/>
			<id>tag:typepad.com,2003:weblog-1554916</id>
			<updated>2009-01-06T16:01:19+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">OpenPoker is open again</title>
		<link href="http://feeds.feedburner.com/~r/TenerifeSkunkworks/~3/477850121/openpoker-is-open-again.html"/>
		<id>tag:typepad.com,2003:post-59633572</id>
		<updated>2009-01-05T04:54:24+00:00</updated>
		<content type="html" xml:lang="en-US">&lt;p&gt;I'm releasing OpenPoker, a scalable poker server written in Erlang, under a &lt;a href=&quot;http://creativecommons.org/licenses/by-nc-sa/3.0/us/&quot;&gt;Creative Commons Non-Commercial License&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Please make a $100 donation at &lt;a href=&quot;http://github.com/wagerlabs/openpoker/tree/master&quot;&gt;GitHub&lt;/a&gt; and subscribe to &lt;a href=&quot;http://www.wagerlabs.com/blog/2008/11/the-erlang-journal.html#more&quot;&gt;The Erlang Journal&lt;/a&gt; if you want to discuss the OpenPoker architecture!&lt;/p&gt;
&lt;p&gt;The donations button is in the upper right corner of &lt;a href=&quot;http://github.com/wagerlabs/openpoker/tree/master&quot;&gt;this page&lt;/a&gt;, or you can just PayPal me at joelr1@gmail.com.&lt;/p&gt;
&lt;img src=&quot;http://feeds.feedburner.com/~r/TenerifeSkunkworks/~4/477850121&quot; height=&quot;1&quot; width=&quot;1&quot; /&gt;</content>
		<author>
			<name>Joel Reymont</name>
			<uri>http://www.wagerlabs.com/blog/</uri>
		</author>
		<source>
			<title type="html">Tenerife Skunkworks</title>
			<subtitle type="html">Ramblings on programming languages and technology</subtitle>
			<link rel="self" href="http://www.wagerlabs.com/blog/atom.xml"/>
			<id>tag:typepad.com,2003:weblog-1554916</id>
			<updated>2009-01-06T16:01:19+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">A Case Study of Scalability Related &quot;Out of memory&quot; Crash in Erlang</title>
		<link href="http://blogtrader.net/page/dcaoyuan/entry/a_case_study_of_scalable"/>
		<id>http://blogtrader.net/page/dcaoyuan/entry/a_case_study_of_scalable</id>
		<updated>2009-01-04T02:59:59+00:00</updated>
		<content type="html">&lt;p&gt;
We are building a platform for message switching, in Erlang. Everything looks OK on stability and features. It actually has run more than half year with zero down. We tested its performance on our 2-core CPU machine before, and got about 140 transactions/second, it's good enough.
&lt;p&gt;
Then, we got a 8-core CPU machine several weeks ago, and we did same performance testing on it, to see the scalability. Since Erlang is almost perfect on scalability, you can image the result, yes, about 700 transactions/second now, scaled almost linear. Until it crashed with &quot;out of memory&quot; when million hits processed.
&lt;p&gt;
It left a very big &quot;erl_crash.dump&quot; file there, I had to dig the issue. My first guess was, were some remote requests (access db, access remote web service etc) timeout but the process itself was not timeout yet, and cause more and more processes kept in VM?
&lt;p&gt;
A quick &lt;b&gt;grep &quot;=proc:&quot; erl_crash.dump&lt;/b&gt; showed that the total number of processes was about 980, which was reasonable for our case.
&lt;p&gt;
So, which process ate so many memory? A quick &lt;b&gt;grep &quot;Stack+head&quot; erl_crash.dump&lt;/b&gt; showed that there was indeed a process with 285082125 size of Stack+head there.
&lt;p&gt;
Following this clue, I caught this process:
&lt;pre&gt;
=proc:0.4.0&gt;
State: Garbing
Name: error_logger
Spawned as: proc_lib:init_p/5
Last scheduled in for: io_lib_format:pad_char/2
Spawned by: 0.1.0&gt;
Started: Sun Apr  1 01:21:50 2012
Message queue length: 2086029
Number of heap fragments: 1234053
Heap fragment data: 281266956
Link list: [0.27.0&gt;, 0.0.0&gt;, {from,0.42.0&gt;,#Ref0.0.0.88&gt;}]
Reductions: 72745575
Stack+heap: 285082125
OldHeap: 47828850
Heap unused: 121777661
OldHeap unused: 47828850
Program counter: 0x0764c66c (io_lib_format:pad_char/2 + 4)
CP: 0x0764c1b4 (io_lib_format:collect_cseq/2 + 124)
&lt;/pre&gt; 
&lt;p&gt;
This process was error_logger, which is from OTP/Erlang standard lib: &lt;b&gt;error_logger&lt;/b&gt;, writing received messages to log file or tty. The typical usage is:
&lt;pre class=&quot;sh_erlang&quot;&gt;
error_logger:info_msg(&quot;~p:~p &quot; ++ Format, [?MODULE, ?LINE] ++ Data))
&lt;/pre&gt;
&lt;p&gt;
Which will format Data to a &lt;b&gt;String&lt;/b&gt; according to the Format string, and write it to tty or log file.
&lt;p&gt; 
The above case showed the message queue length of process &quot;error_logger&quot; had reached 1234053, and the Stack+heap was 285082125, about 272M size. 
&lt;p&gt;
So the cause may be, that the message queue could not be processed in time, the messages were crowded in error_logger's process and finally caused &quot;out of memory&quot;. The bottle-neck was that when error_logger tried to format the message to String, Erlang VM was weak on processing them, which seemed to need a lot of CPU cycles.
&lt;p&gt; 
In my previous blog, I talked about Erlang is bad on massive text processing. Erlang processes String/Text via List, which is obvious bottle-neck in Erlang now, with Erlang is getting much and much popular and more and more Erlang applications are written.
&lt;p&gt;
But, why this did not happen on our 2-core CPU machine? It's an interesting scalability related problem:
&lt;p&gt;
&quot;error_logger&quot; module will registered one and only one process to receive and handle all log messages. But Erlang VM's scheduler can not distribute &lt;b&gt;ONE&lt;/b&gt; process to use multiple CPUs' computing ability. In our 2-core machine, the whole ability is about 140 transactions/second, the one process of &quot;error_logger&quot; just happened to have the power to handle corresponding log messages in time. Under 8-core CPUs machine, our platform scales to handle 700 transactions/second, but there is still only one process of &quot;error_logger&quot;, which can not use 8-core CPUs' ability at all, and finally fail on it.
&lt;p&gt;
Erlang treats every process fairly (although you can change the priority manually), we can do a simple/quick evaluation:
&lt;p&gt;
1. 2-Core machine, keeping hits at 140 trans/second:&lt;br /&gt;
The number of simultaneous processes will be about 200, each process shares the CPU cycles: 1/200 * 2 Core = 1%
&lt;p&gt;
2. 8-Core machine, keeping hits at 700 trans/second:&lt;br /&gt;
The number of simultaneous processes will be about 980, each process shares the CPU cycles: 1/980 * 8 Core = 0.82%
&lt;p&gt;
So, the CPU cycles shared by error_logger process actually not increases.
&lt;p&gt;
BTW, I think error_logger should cut its message queue when can not process them in time (disk IO may also be slower than receiving messages).
&lt;p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</content>
		<author>
			<name>dcaoyuan</name>
			<uri>http://blogtrader.net/page</uri>
		</author>
		<source>
			<title type="html">BlogTrader</title>
			<subtitle type="html">A space for traders</subtitle>
			<link rel="self" href="http://blogtrader.net/page/dcaoyuan/feed/entries/atom"/>
			<id>http://blogtrader.net/page</id>
			<updated>2009-01-06T21:30:18+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Erlang - overhyped or underestimated?</title>
		<link href="http://sacharya.com/erlang-overhyped-or-underestimated/"/>
		<id>http://sacharya.com/erlang-overhyped-or-underestimated/</id>
		<updated>2009-01-04T01:30:54+00:00</updated>
		<content type="html">Erlang is like an exotic beautiful woman with no dressing sense.
I came across Erlang about a year ago. It is a language of a kind - precise, crafted and powerful. Its been there for about two decades now, and people have been using it for serious real-time applications. But the hype Erlang is getting in [...]</content>
		<author>
			<name>Sudarshan Acharya</name>
			<uri>http://sacharya.com</uri>
		</author>
		<source>
			<title type="html">Sudarshan Acharya</title>
			<subtitle type="html">Dreams for Sale!</subtitle>
			<link rel="self" href="http://sacharya.com/?feed=rss"/>
			<id>http://sacharya.com/?feed=rss</id>
			<updated>2009-01-04T20:01:10+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">MD5 in Erlang</title>
		<link href="http://sacharya.com/md5-in-erlang/"/>
		<id>http://sacharya.com/md5-in-erlang/</id>
		<updated>2009-01-04T01:30:54+00:00</updated>
		<content type="html">An MD5 hash for any given message is 16 bytes (128 bits) in size and is represented by a unique 32 digit Hexadecimal number.
Erlang has a built-in-function to calculate the MD5, which returns the hash in the form of a binary data-structure.

$ erlang:md5&amp;#40;&quot;hello&quot;&amp;#41;.
&amp;#60;93,65,64,42,188,75,42,118,185,113,157,145,16,23,197,146&amp;#62;

But what we usually need is a string representation of the Hexadecimal value. [...]</content>
		<author>
			<name>Sudarshan Acharya</name>
			<uri>http://sacharya.com</uri>
		</author>
		<source>
			<title type="html">Sudarshan Acharya</title>
			<subtitle type="html">Dreams for Sale!</subtitle>
			<link rel="self" href="http://sacharya.com/?feed=rss"/>
			<id>http://sacharya.com/?feed=rss</id>
			<updated>2009-01-04T20:01:10+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Erlang mode on Emacs</title>
		<link href="http://sacharya.com/erlang-mode-on-emacs/"/>
		<id>http://sacharya.com/erlang-mode-on-emacs/</id>
		<updated>2009-01-04T01:30:54+00:00</updated>
		<content type="html">Although there are a few other editors for Erlang, I prefer to use Emacs for Erlang and its the only major reason I use Emacs for. Erlang now has an eclipse plugin too, called Erlide.
Erlang comes with the emacs mode as part of its standard distribution, so you only need to customize your emacs settings [...]</content>
		<author>
			<name>Sudarshan Acharya</name>
			<uri>http://sacharya.com</uri>
		</author>
		<source>
			<title type="html">Sudarshan Acharya</title>
			<subtitle type="html">Dreams for Sale!</subtitle>
			<link rel="self" href="http://sacharya.com/?feed=rss"/>
			<id>http://sacharya.com/?feed=rss</id>
			<updated>2009-01-04T20:01:10+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Erlang on Mac OSX</title>
		<link href="http://sacharya.com/erlang-on-mac-osx/"/>
		<id>http://sacharya.com/erlang-on-mac-osx/</id>
		<updated>2009-01-04T01:30:54+00:00</updated>
		<content type="html">On a fresh install of Leopard, the following is what I did in order to set up Erlang working on my Mackbook Pro:
1. Download Xcode by going to Apple ADC. Xcode is the Apple&amp;#8217;s developer tool set, and its available for free. At the time of my install, the latest is Xcode 3.0 and its [...]</content>
		<author>
			<name>Sudarshan Acharya</name>
			<uri>http://sacharya.com</uri>
		</author>
		<source>
			<title type="html">Sudarshan Acharya</title>
			<subtitle type="html">Dreams for Sale!</subtitle>
			<link rel="self" href="http://sacharya.com/?feed=rss"/>
			<id>http://sacharya.com/?feed=rss</id>
			<updated>2009-01-04T20:01:10+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Nginx vs Yaws vs MochiWeb : Web Server Performance Deathmatch, Part 2 [Update x 2]</title>
		<link href="http://www.joeandmotorboat.com/2009/01/03/nginx-vs-yaws-vs-mochiweb-web-server-performance-deathmatch-part-2/"/>
		<id>http://www.joeandmotorboat.com/?p=742</id>
		<updated>2009-01-03T23:19:33+00:00</updated>
		<content type="html">&lt;p&gt;&lt;em&gt;Update 1: Retest data (using different machine and Erlang kernel polling) added near bottom of post.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Update 2: More details and testing on the weird MochiWeb kernel polling results, bottom of post.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Almost a year ago I did some &lt;a href=&quot;http://www.joeandmotorboat.com/2008/02/28/apache-vs-nginx-web-server-performance-deathmatch/&quot;&gt;Apache and Nginx performance testing&lt;/a&gt;. Apparently I have the bug again and have done some performance testing on &lt;a href=&quot;http://www.nginx.net/&quot;&gt;Nginx&lt;/a&gt;, &lt;a href=&quot;http://yaws.hyber.org/&quot;&gt;Yaws&lt;/a&gt; and &lt;a href=&quot;http://code.google.com/p/mochiweb/&quot;&gt;MochiWeb&lt;/a&gt;. The latter two being Erlang based. Again deathmatch may be an overstatement but this is my attempt at gleaning some interesting performance data from some high performance web servers. Also, I attempted to improve the graphs this time around since they were a bit hard to read the last time.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Setup:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I was not able to use the same server and setup as the last time, so comparing between this and my last deathmatch probably isn&amp;#8217;t very accurate. For this test I used a Intel Dual Core 2.2GHz, 4GB RAM machine running Ubuntu 8.10 (64bit) and for the test server. Erlang (R12B-3), Yaws (1.77) and Nginx (0.6.32) are installed from the standard repository and mochiweb from subversion (rev 88). All are using the &lt;strong&gt;default configurations&lt;/strong&gt; outside of adjusting listening port numbers. The test is again against a basic robots.txt file. The tests were done using a consumer grade 100mb switch and all tests originated from an old laptop I had laying around. I think that about covers the test bed, if you have any questions let me know.&lt;/p&gt;
&lt;p&gt;For the tests I used autobench (httperf under the hood) with the following command, each test ran ten minutes apart. The order of the tests were done in was MochiWeb then Yaws and lastly Nginx.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;autobench &amp;#8211;single_host &amp;#8211;host1 HOST &amp;#8211;port1 PORT &amp;#8211;uri1 /robots.txt &amp;#8211;low_rate 10 &amp;#8211;high_rate 200 &amp;#8211;rate_step 10 &amp;#8211;num_call 10 &amp;#8211;num_conn 5000 &amp;#8211;timeout 5 &amp;#8211;file SERVER-results-`date +%F-%H:%M:%S`.tsv&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;The Results:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There are a few results from httperf/autobench that I would like to show, errors, network I/O, reply rate (and it&amp;#8217;s standard deviation) and response time. &lt;em&gt;(click on the graphs for a larger view)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/errors.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/errors.png&quot; alt=&quot;nginx yaws mochiweb errors&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;MochiWeb and Yaws both seem to be the most consistent here. Nginx had a couple of funky spikes, I do not know if this was an issue with Nginx or with my tests and/or test bed. Take from it what you will.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/network.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/network.png&quot; alt=&quot;mochiweb yaws nginx network io&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Nginx seems to use a bit more network I/O consistently through the lower ranges of this test and then again as some spikes. MochiWeb and Yaws seem to have some inconsistencies as well.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/replyrate.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/replyrate.png&quot; alt=&quot;mochiweb yaws nginx reply rate&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The reply rate and network I/O graphs certainly seem to be tied, which would make sense. &lt;em&gt;Edit: Average reply rate is average replies per second.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/replyratestddev.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/replyratestddev.png&quot; alt=&quot;mochiweb yaws nginx reply rate standard deviation&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In the higher reaches of the tests Yaws seems to be most consistent.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/responsetime.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/responsetime.png&quot; alt=&quot;mochiweb yaws nginx response time&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;MochiWeb seems to have consistently the highest response times with Nginx has the lowest. This also follows the data from the first deathmatch. Nginx had consistently low response times against Apache. &lt;em&gt;Edit: Response time is how quickly replies are sent in milliseconds.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Next up are the system graphs, I have CPU usage (both cores combined), context switches, interrupts and load. To help read these please note recall that each test ran ten minutes apart and the order of the tests was MochiWeb then Yaws and lastly Nginx. The data was gathered using sar at five minute intervals and graphed using ksar.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws_all-cpu.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws_all-cpu.png&quot; alt=&quot;nginx yaws mochiweb cpu usage&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It seems Nginx is the clear winner here. Kernel polling may be the answer here, a retest may be in order to see if it makes a difference.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws_LinuxcswchSar.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws_LinuxcswchSar.png&quot; alt=&quot;nginx yaws mochiweb context switch&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;MochiWeb and Nginx seem pretty even on context switches with Yaws a little higher. I suppose turning on kernel polling might make this a bit more even, since Erlang and Nginx both use epoll. This may also account for the CPU usage difference above.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws_LinuxintrSar.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws_LinuxintrSar.png&quot; alt=&quot;nginx yaws mochiweb interrupts&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Interrupts are fairly even across all of them.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws_LinuxloadSar.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws_LinuxloadSar.png&quot; alt=&quot;nginx yaws mochiweb load&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Again Nginx takes it, again likely due to kernel polling being disabled. That&amp;#8217;s my best guess anywho.&lt;/p&gt;
&lt;p&gt;The data I used to create the graphs and etc is available &lt;a href=&quot;http://www.joeandmotorboat.com/files/webservertests_results.tar.gz&quot;&gt;here&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Let me know if you are interested in me retesting anything, I may try to enable kernel polling and try again if I get a chance.&lt;/p&gt;
&lt;p&gt;Note that these are *my* experiences with each webserver, your testing and experiences may be different. As with most things there are pro&amp;#8217;s, con&amp;#8217;s, trade offs and pitfalls. The only way to find out what will work best for your environment is to test, test and test. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: &lt;/p&gt;
&lt;p&gt;I performed the upper half of the tests again to see if there were any changes to sporadic jumps in the graphs http performance graphs. My initial test using the old laptop I saw the same results. I then ran the tests from a VM (running Ubuntu 8.10 in a KVM VM) on my dual core machine and found that the results were much more even. Unfortunately it&amp;#8217;s the same machine that the webservers are running on but the results look much better. The first set is using the same setup as before but just adjusted to have the top half test. The second is the same test but with kernel polling turned on in Erlang.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/avgreplyrate-test2.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/avgreplyrate-test2.png&quot; alt=&quot;nginx yaws mochiweb reply rate&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;All of them are very even and close, no real winners here.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/responsetime-test2.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/responsetime-test2.png&quot; alt=&quot;nginx yaws mochiweb response time&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Looks like Nginx is the clear winner with Yaws next, followed by MochiWeb.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/nginx-yaws-mochiweb-test2_all-cpu.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/nginx-yaws-mochiweb-test2_all-cpu.png&quot; alt=&quot;nginx yaws mochiweb cpu usage&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Pretty much the same as last time (likely a little higher across the board due to running the tests in a VM on the same machine). Note that Nginx is a system process, so for Yaws and MochiWeb follow the blue line and Nginx follow the green. &lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/nginx-yaws-mochiweb-test2_LinuxcswchSar.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/nginx-yaws-mochiweb-test2_LinuxcswchSar.png&quot; alt=&quot;nginx yaws mochiweb context switches&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;About the same as before, other than being higher due to running a VM.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/nginx-yaws-mochiweb-test2_LinuxloadSar.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/nginx-yaws-mochiweb-test2_LinuxloadSar.png&quot; alt=&quot;nginx yaws mochiweb load&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Pretty much the same as before again, Nginx seems the lowest.&lt;/p&gt;
&lt;p&gt;Now for the tests &lt;strong&gt;with kernel polling enabled in Erlang&lt;/strong&gt; (&lt;em&gt;erl +K true&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/nginx-yaws-mochiweb-replyrate-wkernelpolling.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/nginx-yaws-mochiweb-replyrate-wkernelpolling.png&quot; alt=&quot;nginx yaws mochiweb reply rate kernel polling&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;With kernel polling on it looks like Yaws actually performs better in the reply rate test with MochiWeb performing worse and Nginx in the middle&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/nginx-yaws-mochiweb-responsetime-wkernelpolling.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/nginx-yaws-mochiweb-responsetime-wkernelpolling.png&quot; alt=&quot;nginx yaws mochiweb response time kernel polling&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In the response time test a huge change is noted, MochiWeb goes from roughly a ~14 ms response time at 2000 requests to ~65 ms. Also noted Yaws performs much better matching or beating Nginx.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws-wkernelpolling_all-cpu.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws-wkernelpolling_all-cpu.png&quot; alt=&quot;nginx yaws mochiweb cpu usage kernel polling&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;With kernel polling in the Erlang webservers Nginx still seems to come out on top for CPU usage.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws-wkernelpolling_LinuxcswchSar.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws-wkernelpolling_LinuxcswchSar.png&quot; alt=&quot;nginx yaws mochiweb context switches kernel polling&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Following the performance trend we saw above Yaws sees a drop in context switches and MochiWeb increases.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws-wkernelpolling_LinuxloadSar.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/nginx-mochi-yaws-wkernelpolling_LinuxloadSar.png&quot; alt=&quot;nginx yaws mochiweb load kernel polling&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Load-wise things stay roughly the same with Nginx being the lowest.&lt;/p&gt;
&lt;p&gt;While it certainly seems that my old laptop that I did the original tests on is too slow or has a network issue, hopefully with these new tests we have some more clarity. It seems that Yaws improves with kernel polling enabled and competes well with Nginx. MochiWeb on the other hand apparently has issues with kernel polling and actually degrades performance. If anyone has more info on the internals of MochiWeb and possible causes I would be certainly interested.&lt;/p&gt;
&lt;p&gt;If anyone would like the data from the second round of tests it is available &lt;a href=&quot;http://www.joeandmotorboat.com/files/webservertests.3.tar.gz&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I did some more testing to see what the issue might be with MochiWeb, response times and kernel polling. I did a few tests with different versions of Erlang, with and without kernel polling and testing from within and outside a KVM VM. From what I can tell the issue seems to be isolated to testing from within a VM with MochiWeb and kernel polling. Seems to be sorta strange but all my testing and retesting shows the same issue. Just to be clear on my setup, I am running httperf from with in a VM to MochiWeb running outside the VM. Here is the latest round of testing to show this point.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.joeandmotorboat.com/files/mochiweb-responsetime-kvm-kp.png&quot;&gt;&lt;img src=&quot;http://www.joeandmotorboat.com/files/mochiweb-responsetime-kvm-kp.png&quot; alt=&quot;nginx yaws mochiweb kvm vm response time kernel polling&quot; width=&quot;514&quot; height=&quot;387&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Even though the numbers are higher from within the VM without kernel polling, it certainly seems to be an issue with the combination of MochiWeb, KVM and kernel polling. Since I did not see the same spike from within a VM in the earlier tests with Yaws and kernel polling I assume it is not an issue with Erlang or it&amp;#8217;s kernel polling mechanism conflicting with KVM. I am not entirely sure what to make of this other than MochiWeb, kernel polling and KVM don&amp;#8217;t play well together and that &lt;strong&gt;kernel polling actually helps MochiWeb significantly when KVM is not involved&lt;/strong&gt;. If anyone has any ideas on why that may be I am all ears.&lt;/p&gt;</content>
		<author>
			<name>Joe's blog</name>
			<uri>http://www.joeandmotorboat.com</uri>
		</author>
		<source>
			<title type="html">Joe's Blog!</title>
			<link rel="self" href="http://www.joeandmotorboat.com/feed/"/>
			<id>http://www.joeandmotorboat.com/feed/</id>
			<updated>2009-01-06T21:30:26+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">SHA-256 in Erlang</title>
		<link href="http://steve.vinoski.net/blog/2009/01/02/sha-256-in-erlang/"/>
		<id>http://steve.vinoski.net/blog/?p=182</id>
		<updated>2009-01-03T17:14:59+00:00</updated>
		<content type="html">&lt;p&gt;&lt;a href=&quot;http://www.sriramkrishnan.com/blog/&quot;&gt;Sriram Krishnan&lt;/a&gt; was recently &lt;a href=&quot;http://www.sriramkrishnan.com/blog/2008/12/thoughts-on-erlang.html&quot;&gt;lamenting the lack of SHA-256 support&lt;/a&gt; in &lt;a href=&quot;http://erlang.org/doc/man/crypto.html&quot;&gt;Erlang&amp;#8217;s crypto module&lt;/a&gt;, so just for fun I wrote a simple &lt;a href=&quot;http://steve.vinoski.net/code/sha256.erl&quot;&gt;sha256 module&lt;/a&gt; based on the &lt;a href=&quot;http://en.wikipedia.org/wiki/SHA1&quot;&gt;pseudocode in Wikipedia&lt;/a&gt;. The tests use the test data from &lt;a href=&quot;http://www.aarongifford.com/computers/sha.html&quot;&gt;this C implementation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;[Update: I've posted a &lt;a href=&quot;http://steve.vinoski.net/blog/2009/01/03/more-sha-in-erlang/&quot;&gt;new module&lt;/a&gt; that implements more SHA digest variants and so renders this module obsolete.]&lt;/em&gt;&lt;/p&gt;</content>
		<author>
			<name>steve</name>
			<uri>http://steve.vinoski.net/blog</uri>
		</author>
		<source>
			<title type="html">Steve Vinoski's Blog</title>
			<subtitle type="html">Ask forgiveness, not permission.</subtitle>
			<link rel="self" href="http://steve.vinoski.net/blog/feed/atom/"/>
			<id>http://steve.vinoski.net/blog/feed/atom/</id>
			<updated>2009-01-05T07:30:25+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">More SHA in Erlang</title>
		<link href="http://steve.vinoski.net/blog/2009/01/03/more-sha-in-erlang/"/>
		<id>http://steve.vinoski.net/blog/?p=193</id>
		<updated>2009-01-03T17:11:54+00:00</updated>
		<content type="html">&lt;p&gt;Yesterday I posted a &lt;a href=&quot;http://steve.vinoski.net/blog/2009/01/02/sha-256-in-erlang/&quot;&gt;SHA-256 Erlang module&lt;/a&gt;, but I figured since other SHA algorithms are similar, I might as well finish the job. I grabbed the &lt;a href=&quot;http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf&quot;&gt;Secure Hash Standard&lt;/a&gt; and went to work.&lt;/p&gt;
&lt;p&gt;The resulting new module is named &lt;a href=&quot;http://steve.vinoski.net/code/sha2.html&quot;&gt;sha2&lt;/a&gt; and it implements SHA-224, SHA-256, SHA-384, and SHA-512.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://steve.vinoski.net/code/sha2.erl&quot;&gt;Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Light &lt;a href=&quot;http://steve.vinoski.net/code/sha2.html&quot;&gt;documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Tests are included in the module but you get the test vectors &lt;a href=&quot;http://www.aarongifford.com/computers/sha2-1.0.tar.gz&quot;&gt;here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;It&amp;#8217;s open source, &lt;a href=&quot;http://www.opensource.org/licenses/bsd-license.php&quot;&gt;BSD license&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I hope you find it useful.&lt;/p&gt;</content>
		<author>
			<name>steve</name>
			<uri>http://steve.vinoski.net/blog</uri>
		</author>
		<source>
			<title type="html">Steve Vinoski's Blog</title>
			<subtitle type="html">Ask forgiveness, not permission.</subtitle>
			<link rel="self" href="http://steve.vinoski.net/blog/feed/atom/"/>
			<id>http://steve.vinoski.net/blog/feed/atom/</id>
			<updated>2009-01-05T07:30:25+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">BeepBeep Is Another New Erlang Framework</title>
		<link href="http://erlanginside.com/beepbeep-is-another-new-erlang-framework-66"/>
		<id>http://erlanginside.com/?p=66</id>
		<updated>2009-01-03T12:14:39+00:00</updated>
		<content type="html">&lt;p&gt;Happy New Year! It&amp;#8217;s been a great 2008 for Erlang, which we&amp;#8217;ll cover in our 2008 Retrospective in another post later this week. For today, it&amp;#8217;s a new, simple web framework for Erlang called &lt;a href=&quot;http://github.com/davebryson/beepbeep/tree/master&quot;&gt;BeepBeep&lt;/a&gt;. Written by Dave Bryson, it uses &lt;a href=&quot;http://code.google.com/p/mochiweb/&quot;&gt;MochiWeb&lt;/a&gt;, which most Erlang Web developers are familiar with, and &lt;a href=&quot;http://code.google.com/p/erlydtl/&quot;&gt;ErlyDTL&lt;/a&gt;, which is an Erlang port of the Python Template Language. Travis Slicegood has a &lt;a href=&quot;http://www.travisswicegood.com/index.php/2009/01/02/playing-with-beepbeep-and-flickr&quot;&gt;demo application&lt;/a&gt; written in BeepBeep grabbing photos from Flickr, and Dave Bryson has a sample &lt;a href=&quot;http://github.com/davebryson/beepbeep-blog-demo/tree/master&quot;&gt;Blog Application&lt;/a&gt; as well.&lt;/p&gt;
&lt;p&gt;The new set of Erlang web frameworks is more proof of the number of ambitious, sharp developers moving to the language is growing.&lt;/p&gt;</content>
		<author>
			<name>Chad DePue</name>
			<uri>http://erlanginside.com</uri>
		</author>
		<source>
			<title type="html">Erlang Inside</title>
			<subtitle type="html">News and Information on Erlang and Concurrent Computing</subtitle>
			<link rel="self" href="http://erlanginside.com/feed/atom"/>
			<id>http://erlanginside.com/feed/atom</id>
			<updated>2009-01-03T12:46:18+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">2008 in Review &amp;amp; 2009 Goals</title>
		<link href="http://blog.socklabs.com/2009/01/02/2008_in_review_and_2009_goals.html"/>
		<id>http://blog.socklabs.com/2009/01/02/2008_in_review_and_2009_goals</id>
		<updated>2009-01-02T00:00:00+00:00</updated>
		<content type="html">&lt;p&gt;2008 was a great year of activity and excitement. I've got the sneaking suspicion that 2009 is going to be no less busy.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finished and published my first book!&lt;/li&gt;
&lt;li&gt;Spoke at CUFP and met a lot of really smart people.&lt;/li&gt;
&lt;li&gt;Gave several tech-talks and presentations.&lt;/li&gt;
&lt;li&gt;Learned how to develop apps for the iPhone.&lt;/li&gt;
&lt;li&gt;Migrated I Play WoW from a Perl app to an Erlang app.&lt;/li&gt;
&lt;li&gt;Learned about CouchDB.&lt;/li&gt;
&lt;li&gt;Learned Git.&lt;/li&gt;
&lt;li&gt;Accepted a lead position at EA.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;This is what I'd like to accomplish in 2009.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finish my second book.&lt;/li&gt;
&lt;li&gt;Do more tech-talks and presentations.&lt;/li&gt;
&lt;li&gt;Have a 100 day streak of open source commits on GitHub.&lt;/li&gt;
&lt;li&gt;Write more technical articles and entries.&lt;/li&gt;
&lt;li&gt;Learn Python.&lt;/li&gt;
&lt;li&gt;Hit level 80 with Korale and get into tier 9.&lt;/li&gt;
&lt;li&gt;Grow I Play WoW to 75,000 monthly active users.&lt;/li&gt;
&lt;/ul&gt;</content>
		<author>
			<name>Nick Gerakines</name>
			<email>nick@gerakines.net</email>
			<uri>http://blog.socklabs.com/</uri>
		</author>
		<source>
			<title type="html">Socklabs</title>
			<subtitle type="html">We sit together, the mountain and I, until only the mountain remains.</subtitle>
			<link rel="self" href="http://blog.socklabs.com/atom.xml"/>
			<id>http://blog.socklabs.com/</id>
			<updated>2009-01-05T04:46:12+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">The Year That Will Be</title>
		<link href="http://blogtrader.net/page/dcaoyuan/entry/the_year_that_will_be"/>
		<id>http://blogtrader.net/page/dcaoyuan/entry/the_year_that_will_be</id>
		<updated>2009-01-01T19:39:00+00:00</updated>
		<content type="html">It's 2009 now, in Beijing.

&lt;h2&gt;1==0.999999999......&lt;/h2&gt;
I met Erlang 2 years ago, which finally brings me to Scala. I learnt a lot from Erlang, and I entered the Scala world with Erlang atmosphere surrounding me. The FP, the Pattern Match, the Actor/Process, I found these familiar friends in Scala everywhere.
&lt;p&gt;
Scala has extra bonus, to me, static types and OO/FP. The domains I face are usually with a lot of business logic, or, the worlds I try to describe are not only messages, they are, models I don't think are suitable to describe in Function only. 
&lt;p&gt;
The world itself is OO/FP mixed, like Martin's quote: Two sides of coin. It's something like the Particle/Wave in Quantum. The world is an infinite whole, but the reason of Human Being is always finite, we are using out finite reason to measure the infinite world, it's an unsolvable contradiction: Infinity vs Finite. We have to read our world in OO and, in FP, in snapshot and in continuation.
&lt;p&gt;
There won't be &quot;Super Hero&quot; in computer languages, the world is getting self-organization and harmony, so do the languages. Each language is living in an eco-system, born, growing via interacting with environment, disappear ...

&lt;h2&gt;The Economy&lt;/h2&gt;
It was bad in 2008. I tried to do some computing on stock market based on my neural network. What I can say is it will be swing in the next half-year, no big drop, no big rise. The Shanghai Stock Index will swing between 1200 and 3000. At least, no big worse any more.

&lt;h2&gt;My Self&lt;/h2&gt;
I need to make some big decisions in this a year.
&lt;p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</content>
		<author>
			<name>dcaoyuan</name>
			<uri>http://blogtrader.net/page</uri>
		</author>
		<source>
			<title type="html">BlogTrader</title>
			<subtitle type="html">A space for traders</subtitle>
			<link rel="self" href="http://blogtrader.net/page/dcaoyuan/feed/entries/atom"/>
			<id>http://blogtrader.net/page</id>
			<updated>2009-01-06T21:30:18+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">Links for 2008-12-31 [del.icio.us]</title>
		<link href="http://feeds.feedburner.com/~r/TenerifeSkunkworks/~3/499999569/wagerlabs"/>
		<id>http://del.icio.us/wagerlabs#2008-12-31</id>
		<updated>2009-01-01T06:00:00+00:00</updated>
		<content type="html">&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.programmersheaven.com/2/Writing-Your-Own-GPS-Applications&quot;&gt;Writing Your Own GPS Applications - Programmer's Heaven&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.codeproject.com/KB/cs/NMEAtoOSG.aspx&quot;&gt;CodeProject: GPS- Deriving British Ordnance Survey Grid Reference from NMEA data. Free source code and programming help&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://nmea.sourceforge.net/&quot;&gt;NMEA library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.maartenlamers.com/nmea/&quot;&gt;NMEA:: Wiring / Arduino library for easy decoding of GPS data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.visualgps.net/Papers/NMEAParser/NMEA%20Parser%20Design.htm&quot;&gt;NMEA Parser Design&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://vancouver-webpages.com/peter/nmeafaq.txt&quot;&gt;http://vancouver-webpages.com/peter/nmeafaq.txt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://pyserial.wiki.sourceforge.net/pySerial&quot;&gt;SourceForge.net: pyserial &amp;raquo; pySerial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://regexp.bjoern.org/archives/000186.html&quot;&gt;reg:exp: GPS + Google Maps Mash-up in 42 lines of code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://home.mira.net/~gnb/gps/nmea.html&quot;&gt;Glenn Baddeley - GPS - NMEA sentence information&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gpsd.berlios.de/NMEA.txt&quot;&gt;http://gpsd.berlios.de/NMEA.txt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gpsinformation.org/dale/nmea.htm&quot;&gt;NMEA data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.systec-electronic.com/html/index.pl/en_product_can_ethernet_gateway&quot;&gt;Product CAN-Ethernet Gateway - SYS TEC electronic GmbH&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://clutter-project.org/&quot;&gt;Clutter Toolkit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.linux-nantes.org/~fmonnier/OCaml/ocaml-wrapping-c.php&quot;&gt;How to wrap C functions to OCaml&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://spivey.oriel.ox.ac.uk/mike/obc/&quot;&gt;Oxford Oberon-2 Compiler&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src=&quot;http://feeds.feedburner.com/~r/TenerifeSkunkworks/~4/499999569&quot; height=&quot;1&quot; width=&quot;1&quot; /&gt;</content>
		<author>
			<name>Joel Reymont</name>
			<uri>http://www.wagerlabs.com/blog/</uri>
		</author>
		<source>
			<title type="html">Tenerife Skunkworks</title>
			<subtitle type="html">Ramblings on programming languages and technology</subtitle>
			<link rel="self" href="http://www.wagerlabs.com/blog/atom.xml"/>
			<id>tag:typepad.com,2003:weblog-1554916</id>
			<updated>2009-01-06T16:01:19+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">Thinking in Scala vs Erlang</title>
		<link href="http://blogtrader.net/page/dcaoyuan/entry/thinking_in_the_scala_vs"/>
		<id>http://blogtrader.net/page/dcaoyuan/entry/thinking_in_the_scala_vs</id>
		<updated>2008-12-30T18:15:17+00:00</updated>
		<content type="html">Keeping Erlang in mind, I've coded two months in Scala, I'm thinking something called &quot;Scala vs Erlang&quot;, I wrote some benchmark code to prove me (the code and result may be available someday), and I'd like to do some gradually summary on it in practical aspect. These opinions may be or not be correct currently due to lacking of deep experience and understanding, but, anyway, I need to record them now and correct myself with more experiences and understanding got on both Scala and Erlang.

&lt;h2&gt;Part I. Syntax&lt;/h2&gt;

&lt;h3&gt;List comprehension&lt;/h3&gt;

&lt;p&gt;Erlang:
&lt;pre class=&quot;sh_erlang&quot;&gt;
Lst = [1,2,3,4],
[X + 1 || X - Lst],
lists:map(fun(X) -&gt; X + 1 end, Lst)
&lt;/pre&gt;

&lt;p&gt;Scala:
&lt;pre class=&quot;sh_scala&quot;&gt;
val lst = List(1,2,3,4) 
for (x - lst) yield x + 1
lst.map{x =&gt; x + 1}
lst.map{_ + 1} // or place holder
&lt;/pre&gt;

&lt;h3&gt;Pattern match&lt;/h3&gt;

&lt;p&gt;Erlang:
&lt;pre class=&quot;sh_erlang&quot;&gt;
case X of
   {A, B} when is_integer(A), A &gt; 1 -&gt; ok;
   _ -&gt; error
end,

{ok, [{A, B} = H|T]} = my_function(X)
&lt;/pre&gt;

&lt;p&gt;Scala:
&lt;pre class=&quot;sh_scala&quot;&gt;
x match {
   case (a:Int, b:_) if a &gt; 1 =&gt; OK // can match type
   case _ =&gt; ERROR
}

val (&quot;ok&quot;, (h@(a, b)) :: t) = my_function(x)
&lt;/pre&gt;

&lt;h3&gt;List, Tuple, Array, Map, Binary, Bit&lt;/h3&gt;

&lt;p&gt;Erlang:
&lt;pre class=&quot;sh_erlang&quot;&gt;
Lst = [1, 2, 3] %% List
[0 | Lst]  %% List concat
{1, 2, 3}  %% Tuple
1, 2, “abc”&gt;&gt;  %% Binary
%% no Array, Map syntax
&lt;/pre&gt;

&lt;p&gt;Scala:
&lt;pre class=&quot;sh_scala&quot;&gt;
val lst = List(1, 2, 3)  // List
0 :: lst  // List concat
(1, 2, 3) // Tuple
Array(1, 2, 3) // Array
Map(“a” -&gt; 1, “b” -&gt; 2) // Map
// no Binary, Bit syntax
&lt;/pre&gt;

&lt;h3&gt;Process, Actor&lt;/h3&gt;
&lt;p&gt;Erlang:
&lt;pre class=&quot;sh_erlang&quot;&gt;
the_actor(X) -&gt; 
   receive 
      ok -&gt; io:format(“~p~n”, [X]);
      I -&gt; the_actor(X + I) %% needs to explicitly continue loop
   end.
P = spawn(mymodule, the_actor, [0])
P ! 1
P ! ok
&lt;/pre&gt;

&lt;p&gt;Scala I:
&lt;pre class=&quot;sh_scala&quot;&gt;
class TheActor(x:Int) extends Actor { 
   def act = loop {
      react {
         case “ok” =&gt; println(x); exit // needs to explicitly exit loop
         case i:Int =&gt; x += i
      }
   }
}
val a = new TheActor(0)
a ! 1
a ! “ok”
&lt;/pre&gt;
&lt;p&gt;Scala II:
&lt;pre class=&quot;sh_scala&quot;&gt;
val a = actor { 
   def loop(x:Int) = {
      react {
         case &quot;ok&quot; =&gt; println(x)
         case i:Int =&gt; loop(x + i)
      }
   }
   loop(0)
}
a ! 1
a ! &quot;ok&quot;
&lt;/pre&gt;

&lt;p&gt;
&lt;h2&gt;Part II. Processes vs Actors&lt;/h2&gt;

&lt;h3&gt;Something I&lt;/h3&gt;
&lt;p&gt;Erlang:
&lt;ul&gt;
&lt;li&gt;Lightweight processes&lt;/li&gt;
&lt;li&gt;You can always (almost) create a new process for each new comer&lt;/li&gt;
&lt;li&gt;Scheduler treats all processes fairly&lt;/li&gt;
&lt;li&gt;Share nothing between processes&lt;/li&gt;
&lt;li&gt;Lightweight context switch between processes&lt;/li&gt;
&lt;li&gt;IO has been carefully delegated to independent processes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Scala:
&lt;ul&gt;
&lt;li&gt;Active actor is delegated to JVM thread, actor /= thread&lt;/li&gt;
&lt;li&gt;You can create a new actor for each new comer&lt;/li&gt;
&lt;li&gt;But the amount of real workers (threads) is dynamically adjusted according to the processing time&lt;/li&gt;
&lt;li&gt;The later comers may be in wait list for further processing until a spare thread is available&lt;/li&gt;
&lt;li&gt;Share nothing or share something upon you decision&lt;/li&gt;
&lt;li&gt;Heavy context switch between working threads&lt;/li&gt;
&lt;li&gt;IO block is still pain unless good NIO framework (Grizzly?)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Something II&lt;/h3&gt;
&lt;p&gt;Erlang:
&lt;ul&gt;
&lt;li&gt;Try to service everyone simultaneously&lt;/li&gt;
&lt;li&gt;But may loss service quality when the work is heavy, may time out (out of service)&lt;/li&gt;
&lt;li&gt;Ideal when processing cost is comparable to context switching cost&lt;/li&gt;
&lt;li&gt;Ideal for small message processing in soft real-time&lt;/li&gt;
&lt;li&gt;Bad for massive data processing, and cpu-heavy work&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Scala:
&lt;ul&gt;
&lt;li&gt;Try to service limited number of customers best first&lt;/li&gt;
&lt;li&gt;If can not service all, the later comers will be put in waiting list and may time out (out of service)&lt;/li&gt;
&lt;li&gt;It's difficult for soft real-time on all coming concurrent customers&lt;/li&gt;
&lt;li&gt;Ideal when processing cost is far more than context switching cost (context switch time is in ns on modern JVM)&lt;/li&gt;
&lt;li&gt;When will there be perfect NIO + Actor library?&lt;/li&gt;
&lt;/ul&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</content>
		<author>
			<name>dcaoyuan</name>
			<uri>http://blogtrader.net/page</uri>
		</author>
		<source>
			<title type="html">BlogTrader</title>
			<subtitle type="html">A space for traders</subtitle>
			<link rel="self" href="http://blogtrader.net/page/dcaoyuan/feed/entries/atom"/>
			<id>http://blogtrader.net/page</id>
			<updated>2009-01-06T21:30:18+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Planet Erlang updated</title>
		<link href="http://www.process-one.net/en/blogs/article/planet_erlang_updated1/"/>
		<id>tag:process-one.net,2008:en/blogs/3.445</id>
		<updated>2008-12-30T09:23:27+00:00</updated>
		<content type="html">PlanetErlang, the Erlang news and blog post aggregation site has been rewritten. &lt;p&gt;The new site should be easier to read. It includes a search engine, that allows users to search inside the history of Erlang posts among all the known blogs. The sitebar also contains latest Twitter post on Erlang.&lt;/p&gt;

&lt;p&gt;Planet Erlang is available on the following address: &lt;a href=&quot;http://www.planeterlang.org&quot;&gt;http://www.planeterlang.org&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Enjoy !&lt;/p&gt;</content>
		<author>
			<name>Mickaël Rémond</name>
			<uri>http://www.process-one.net/en/blogs/</uri>
		</author>
		<source>
			<title type="html">ProcessOne Blogs</title>
			<subtitle type="html">ProcessOne Blogs:ProcessOne Blogs</subtitle>
			<link rel="self" href="http://www.process-one.net/en/blogs/atom/"/>
			<id>tag:process-one.net,2009:01:05</id>
			<updated>2009-01-05T10:01:42+00:00</updated>
			<rights type="html">Copyright (c) 2009, ProcessOne</rights>
		</source>
	</entry>

	<entry>
		<title type="html">Using Test::Harness with etap</title>
		<link href="http://blog.socklabs.com/2008/12/30/using_test_harness_and_etap.html"/>
		<id>http://blog.socklabs.com/2008/12/30/using_test_harness_and_etap</id>
		<updated>2008-12-30T00:00:00+00:00</updated>
		<content type="html">&lt;p&gt;This isn't a beginner's walk through. It assumes you know how to use and read Erlang as well as install Erlang and Perl libraries &lt;/p&gt;

&lt;p&gt;I love &lt;a href=&quot;http://search.cpan.org/dist/TAP/&quot;&gt;TAP&lt;/a&gt;. TAP is a protocol used to create and interact with testing frameworks. The general idea is that your unit tests interact with a TAP client which outputs the TAP protocol that is then consumed by a TAP server. What it boils down to is a really simple text based structure used to convey unit test results, with a few added bonuses here and there.&lt;/p&gt;

&lt;p&gt;With &lt;a href=&quot;http://github.com/ngerakines/etap/tree/master&quot;&gt;etap&lt;/a&gt; and Perl's &lt;a href=&quot;http://search.cpan.org/%7Eandya/Test-Harness/&quot;&gt;TAP::Harness&lt;/a&gt; we can create really slick test result output and move closer to having a continuous integration build environment. Before you get ahead of yourself, you'll need to make sure that you've got etap downloaded and in your Erlang lib path. You'll also have to install TAP::Harness and it's dependancies. &lt;/p&gt;

&lt;p&gt;To demonstrate how this is done, we'll use the &lt;a href=&quot;http://github.com/ngerakines/erlang_protobuffs/tree/master&quot;&gt;erlang_protobuffs&lt;/a&gt; library. This library is composed of two modules that provide functionality through direct interaction with their exported functions. They don't extend any OTP behaviors and have very few side effects. The project's sources are contained in the &lt;code&gt;src&lt;/code&gt; directory and it's tests in the &lt;code&gt;t&lt;/code&gt; directory. There is also a support directory that provides the Makefile include for building the actual modules.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;test&lt;/code&gt; target in the root Makefile calls the &lt;code&gt;prove&lt;/code&gt; command with the verbose flag and a glob of the *.t files in the &lt;code&gt;t&lt;/code&gt; diretory.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;test: all
    prove -v t/*.t
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The actual tests for the project are &lt;a href=&quot;http://erlang.org/doc/man/escript.html&quot;&gt;escript&lt;/a&gt; files with the .t extension. Using the escript hash bang lets us treat each file as it's own complete unit test. They can be run in any order and have their own configuration and directives. Below is the protobuffs_t_001.t file.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env escript
%% -*- erlang -*-
%%! -pa ./ebin -sasl errlog_type error -boot start_sasl -noshell

main(_) -&gt;
    etap:plan(8),
    etap_can:loaded_ok(protobuffs, &quot;module 'protobuffs' loaded&quot;),
    etap_can:can_ok(protobuffs, encode),
    etap_can:can_ok(protobuffs, encode, 3),
    etap_can:can_ok(protobuffs, decode),
    etap_can:can_ok(protobuffs, decode, 2),
    etap_can:loaded_ok(protobuffs_compile, &quot;module 'protobuffs_compile' loaded&quot;),
    etap_can:can_ok(protobuffs_compile, scan_file),
    etap_can:can_ok(protobuffs_compile, scan_file, 1),
    etap:end_tests().
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Lines 1, 2 and 3 are used by the shell and escript command to set any Erlang vm options necessary. In this case we want to include the &lt;code&gt;ebin&lt;/code&gt; directory, start sasl with minimal logging and disable the shell.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;main/0&lt;/code&gt; function is called escript with whatever relevant arguments that may apply, but we don't care about them so we ignore them for now. Here we perform several tests to assert that the project's modules load and export the proper functions.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;etap:plan/1&lt;/code&gt; and &lt;code&gt;etap:end_tests/0&lt;/code&gt; functions wrap the &lt;code&gt;etap*:*&lt;/code&gt; function calls and is used to define the test plan. At this point etap is not designed to work without finite plans.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env escript
%% -*- erlang -*-
%%! -pa ./ebin -sasl errlog_type error -boot start_sasl -noshell

-record(person, {name, address, phone_number, age, location}).

main(_) -&gt;
    etap:plan(1),
    etap:is(protobuffs_compile:scan_file(&quot;t/simple.proto&quot;), ok, &quot;simple.proto compiled&quot;),
    compile:file(&quot;simple_pb.erl&quot;),
    Data = [{1, &quot;Nick&quot;&gt;&gt;, string}, {2, &quot;Mountain View&quot;&gt;&gt;, string}, {3, &quot;+1 (000) 555-1234&quot;&gt;&gt;, string}, {4, 25, int32}],
    BinData = erlang:iolist_to_binary([protobuffs:encode(Pos, Value, Type) || {Pos, Value, Type} - Data]),
    #person{ name = &quot;Nick&quot;&gt;&gt;, address = &quot;Mountain View&quot;&gt;&gt;, phone_number = &quot;+1 (000) 555-1234&quot;&gt;&gt;, age = 25} = simple_pb:decode_person(BinData),
    BinData = simple_pb:encode_person(#person{ name = &quot;Nick&quot;&gt;&gt;, address = &quot;Mountain View&quot;&gt;&gt;, phone_number = &quot;+1 (000) 555-1234&quot;&gt;&gt;, age = 25}),
    etap:end_tests().
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In the protobuffs_t_005.t file you see that you can do things like define records. In this test unit we call several of the library's exported functions and test some of the more complex functionality. The &lt;code&gt;protobuffs_compile:scan_file/1&lt;/code&gt; function actually writes several files which are then compiled by &lt;code&gt;compile:file/1&lt;/code&gt; and used by subsequent test unit function calls.&lt;/p&gt;

&lt;p&gt;The output of the &lt;code&gt;make test&lt;/code&gt; command, as processed by the TAP::Harness perl module, is very clean.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mbp:erlang_protobuffs ngerakines$ make test
mkdir -p ebin/
(cd src;make)
erlc -W -I ../include  +debug_info -o ../ebin protobuffs.erl
erlc -W -I ../include  +debug_info -o ../ebin protobuffs_compile.erl
prove t/*.t
t/protobuffs_t_001....ok   
t/protobuffs_t_002....ok   
t/protobuffs_t_003....ok   
t/protobuffs_t_004....ok   
t/protobuffs_t_005....ok   
t/protobuffs_t_006....ok   
All tests successful.
Files=6, Tests=17,  1 wallclock secs ( 0.04 usr  0.02 sys +  0.97 cusr  0.27 csys =  1.30 CPU)
Result: PASS
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Depending on the error and severity, failed tests will either output in a similarly clean fashion or stop the entire suite from processing.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mbp:erlang_protobuffs ngerakines$ make test
mkdir -p ebin/
(cd src;make)
erlc -W -I ../include  +debug_info -o ../ebin protobuffs.erl
erlc -W -I ../include  +debug_info -o ../ebin protobuffs_compile.erl
prove t/*.t
t/protobuffs_t_001....ok   
t/protobuffs_t_002....ok   
t/protobuffs_t_003.... Failed 1/3 subtests 
t/protobuffs_t_004....ok   
t/protobuffs_t_005....ok   
t/protobuffs_t_006....ok   

Test Summary Report
-------------------
t/protobuffs_t_003 (Wstat: 0 Tests: 3 Failed: 1)
  Failed test:  2
Files=6, Tests=17,  2 wallclock secs ( 0.04 usr  0.02 sys +  0.96 cusr  0.26 csys =  1.28 CPU)
Result: FAIL
make: *** [test] Error 1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The prove command has a number of options and arguments that augment test execution. Please refer to &lt;code&gt;prove --help&lt;/code&gt; or the documentation available on CPAN for more information.&lt;/p&gt;

&lt;p&gt;There are a few things to take note of. All of the paths to included and referenced files, such as the &lt;code&gt;simple.proto&lt;/code&gt; file, are relative to where the &lt;code&gt;prove&lt;/code&gt; command is called. In this case it's in the root directory as part of the &lt;code&gt;test&lt;/code&gt; target. Also, for some more complex and lengthy tests, please read up on the escript documentation. The compile mode can be used to pre-compile the file before being called but has a few caveats that you should be aware of.&lt;/p&gt;</content>
		<author>
			<name>Nick Gerakines</name>
			<email>nick@gerakines.net</email>
			<uri>http://blog.socklabs.com/</uri>
		</author>
		<source>
			<title type="html">Socklabs</title>
			<subtitle type="html">We sit together, the mountain and I, until only the mountain remains.</subtitle>
			<link rel="self" href="http://blog.socklabs.com/atom.xml"/>
			<id>http://blog.socklabs.com/</id>
			<updated>2009-01-05T04:46:12+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">CN Erlounge III</title>
		<link href="http://blogtrader.net/page/dcaoyuan/entry/cn_erlounge_iii"/>
		<id>http://blogtrader.net/page/dcaoyuan/entry/cn_erlounge_iii</id>
		<updated>2008-12-28T18:29:16+00:00</updated>
		<content type="html">I attended CN Erlounge III last weekend, it was a 2-day conference. I did a presentation about Scala vs Erlang.
&lt;p&gt;
I met &lt;a href=&quot;http://erlang-china.org/&quot;&gt;Jackyz&lt;/a&gt; who is one of the translators of Chinese version &quot;Programming Erlang&quot;. And &lt;a href=&quot;http://blog.csdn.net/aimingoo/&quot;&gt;Aimin&lt;/a&gt; who is writing a &lt;a href=&quot;http://code.google.com/p/derlang/&quot;&gt;Delphi module&lt;/a&gt; to support Erlang c-node and c-driver in Delphi.
&lt;p&gt;
There is a commercial network monitoring product using Erlang from a major telecom company in China. And our Mobile-Banking platform (in Erlang) is scheduled to launch at middle of January too.
&lt;p&gt;
I talked with Yeka and Diuera from &lt;a href=&quot;http://www.broadview.com.cn/&quot;&gt;Broadview&lt;/a&gt;, a leading publisher in IT in China, they are really interested in importing &quot;Programming in Scala&quot; to mainland China.
&lt;p&gt;
And many thanks to Shiwei Xu, who is heavy working on Erlang community in China, and took the place to organize this conference.
&lt;p&gt;
I gave some encouragements to younger developers on learning Erlang and reading &quot;Programming Erlang&quot;, since I'm the oldest one in attendees :-). Erlang is one of the best pragmatic and clear languages to learn concurrent/parallel and functional programming, and the book, is a very thoughtful and philosophic one on these perceptions.
&lt;p&gt;
And I'd like to see &quot;Programming in Scala&quot; also appeals in China soon, Scala is another pragmatic language on solving real world problems and, the book, is also thoughtful and philosophic one on our real world on Types, OO and FP.
&lt;p&gt;
Of course, choosing Scala or Erlang for your real world project should depend on the requirements.
&lt;p&gt;
I may be back to Vancouver next month for a while. Oh, it will be the beginning of new year.
&lt;p&gt;
&lt;a href=&quot;http://picasaweb.google.com/krzycube/CnErloungeIii&quot;&gt;CN Erlounge III photos&lt;/a&gt; by krzycube
&lt;p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</content>
		<author>
			<name>dcaoyuan</name>
			<uri>http://blogtrader.net/page</uri>
		</author>
		<source>
			<title type="html">BlogTrader</title>
			<subtitle type="html">A space for traders</subtitle>
			<link rel="self" href="http://blogtrader.net/page/dcaoyuan/feed/entries/atom"/>
			<id>http://blogtrader.net/page</id>
			<updated>2009-01-06T21:30:18+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Windows tricks for erlangers</title>
		<link href="http://ulf.wiger.net/weblog/2008/12/27/windows-tricks-for-erlangers/"/>
		<id>http://ulf.wiger.net/weblog/?p=78</id>
		<updated>2008-12-27T09:00:05+00:00</updated>
		<content type="html">&lt;p&gt;Not that I spend much time compiling erlang code in Windows (unless I&amp;#8217;m using cygwin or coLinux), but the issue does pop up from time to time. Here are a few minor tricks that can help a bit.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Starting Erlang in the current directory&lt;/strong&gt;&lt;br /&gt;
For a unix user, it&amp;#8217;s of course odd that this should be a problem.&lt;/p&gt;
&lt;p&gt;John Hughes used a nice trick that&amp;#8217;s so simple that I slap myself for not having thought of it: Right-click on a .beam file, select &amp;#8220;Open With&amp;#8230;&amp;#8221; and locate werl.exe. Now you can open an erlang shell in the current working directory by double-clicking a .beam file.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Modifying the Windows context menu&lt;/strong&gt;&lt;br /&gt;
So what if you don&amp;#8217;t have any .beam files, and you&amp;#8217;re trying to get to an erlang shell&lt;br /&gt;
in order to create some?&lt;/p&gt;
&lt;p&gt;I did some googling and found &lt;a href=&quot;http://www.youtube.com/watch?v=L36u7GudN8k&quot;&gt;this tutorial&lt;/a&gt; on youtube on how to add custom entries to the context menu. &lt;/p&gt;
&lt;p&gt;It seemed simple enough, but Vista still served me a few hours of utter confusion since it took what I inserted, and then copied it to another place in the registry (without letting me know)&amp;#8230; but only the first time. My changes and additions were simply ignored. The solution? Search the registry for the key you inserted, and you&amp;#8217;ll figure out where Vista wants it to be, then make your changes there.&lt;/p&gt;
&lt;p&gt;What I&amp;#8217;ve experimented with so far is to add under Computer\HKEY_CLASSES_ROOT\ErlangSource\shell\ the following entries:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;br /&gt;
Compile with erlc&lt;br /&gt;
- Command = &quot;C:\Program Files\erl5.6.3\bin\erlc.exe&quot; &quot;%1&quot;&lt;br /&gt;
Make all&lt;br /&gt;
- Command = &quot;C:\Program Files\erl5.6.3\bin\werl.exe&quot; &quot;-make&quot;&lt;br /&gt;
Erlang shell&lt;br /&gt;
- Command = &quot;C:\Program Files\erl5.6.3\bin\werl.exe&quot; &quot;%1&quot;&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;A problem with running erlc this way is that the window is destroyed immediately upon completion. I&amp;#8217;ve poked around a bit for good workarounds. One option is of course to write an erlang function that compiles the file, then either sleeps a short while, or waits for input.&lt;/p&gt;</content>
		<author>
			<name>Ulf Wiger</name>
			<uri>http://ulf.wiger.net/weblog</uri>
		</author>
		<source>
			<title type="html">Ulf Wiger</title>
			<subtitle type="html">Just another WordPress weblog</subtitle>
			<link rel="self" href="http://ulf.wiger.net/weblog/feed/"/>
			<id>http://ulf.wiger.net/weblog/feed/</id>
			<updated>2008-12-27T09:15:41+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">Alas Poor Erlang, I Knew Ye Well!</title>
		<link href="http://concise-software.blogspot.com/2008/12/alas-poor-erlang-i-knew-ye-well.html"/>
		<id>tag:blogger.com,1999:blog-1172307519118716047.post-1460691718506996917</id>
		<updated>2008-12-27T07:27:14+00:00</updated>
		<content type="html">&lt;p&gt;The death of useful insight from a new idea encountered or approach studied begins a time of denial for me and then a time of mourning. Erlang stopped providing me with useful insight months ago, yet I doggedly pursued it hoping I would experience more of the mind-opening joy I had when I first encountered it. This has not happened. Worse than that I feel a seething resentment for Erlang now since it continually pops up in my head as a possible solution to things I am ill-equipped to solve using it. None of this is a fault of Erlang, but rather a reality of my inexperience with Functional Programming and the lack of modules in Erlang for structuring and developing RESTful Web Services the way I would like.&lt;/p&gt;

&lt;p&gt;Certainly Yaws and mochiweb let you build RESTful Web Services, but I find myself fumbling with them rather than solving my real domain problems. I am not sure if this is a side-effect of transparent data structures in Erlang vs objects in Java or what. I do know that I find it easier to grow a solution gradually with Restlet (a Java REST framework). Nothing inherently prevents Erlang from providing developers with a good framework for building RESTful Web Services. I believe Erlang is inherently better suited to the purpose at a runtime level than Java, but Yaws and mochiweb do not fit my way of thinking.&lt;/p&gt;

&lt;p&gt;It would be very interesting to see OTP-style behaviours for Resources and Routers (and the various other actors of the Restlet framework) wh