<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Rewriting Playdar: C++ to Erlang, massive savings</title>
	<atom:link href="http://www.metabrew.com/article/rewriting-playdar-c-to-erlang-massive-savings/feed" rel="self" type="application/rss+xml" />
	<link>http://www.metabrew.com/article/rewriting-playdar-c-to-erlang-massive-savings/</link>
	<description>Erlang, PHP, C, C++, Java, PostgreSQL, MySQL, Hadoop, Linux, awk, bash, sed, grep, screen, vim, irc, ssh etc...</description>
	<lastBuildDate>Wed, 08 Sep 2010 09:00:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: emma</title>
		<link>http://www.metabrew.com/article/rewriting-playdar-c-to-erlang-massive-savings//comment-page-1#comment-15059</link>
		<dc:creator>emma</dc:creator>
		<pubDate>Thu, 28 Jan 2010 16:10:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.metabrew.com/?p=279#comment-15059</guid>
		<description>Is anyone looking for Erlang work in London?
Please contact emma@e-macrecruitment.com for further details.</description>
		<content:encoded><![CDATA[<p>Is anyone looking for Erlang work in London?<br />
Please contact <a href="mailto:emma@e-macrecruitment.com">emma@e-macrecruitment.com</a> for further details.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henning Diedrich</title>
		<link>http://www.metabrew.com/article/rewriting-playdar-c-to-erlang-massive-savings//comment-page-1#comment-13818</link>
		<dc:creator>Henning Diedrich</dc:creator>
		<pubDate>Wed, 23 Dec 2009 06:22:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.metabrew.com/?p=279#comment-13818</guid>
		<description>&quot;I’ve used processes to encapsulate state (active queries, specifically) where I didn’t really need to. It seemed sensible at the time ...&quot; -- what are you using now instead? Ets or Mnesia? The OO/Actor equation seems to encourage the encapsulation of state in processes. After the experience you had there, any suggestions along what lines to think one&#039;s way out of that? Back to separation of instructions and data - half way? I come to think that Mnesia is more integral than it looks at first glance. Even though it &#039;feels&#039; like too big for being the standard way of state handling, without its transactions something is missing. Ets are not sufficient. The abolition of locks and synchs may simply requiring for transactions in common state handling or it&#039;s merely a truncation of applicability where shared state is part of the requirements?</description>
		<content:encoded><![CDATA[<p>&#8220;I’ve used processes to encapsulate state (active queries, specifically) where I didn’t really need to. It seemed sensible at the time &#8230;&#8221; &#8212; what are you using now instead? Ets or Mnesia? The OO/Actor equation seems to encourage the encapsulation of state in processes. After the experience you had there, any suggestions along what lines to think one&#8217;s way out of that? Back to separation of instructions and data &#8211; half way? I come to think that Mnesia is more integral than it looks at first glance. Even though it &#8216;feels&#8217; like too big for being the standard way of state handling, without its transactions something is missing. Ets are not sufficient. The abolition of locks and synchs may simply requiring for transactions in common state handling or it&#8217;s merely a truncation of applicability where shared state is part of the requirements?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Linktipps Januar 2010 :: Blackflash</title>
		<link>http://www.metabrew.com/article/rewriting-playdar-c-to-erlang-massive-savings//comment-page-1#comment-13701</link>
		<dc:creator>Linktipps Januar 2010 :: Blackflash</dc:creator>
		<pubDate>Sat, 19 Dec 2009 13:49:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.metabrew.com/?p=279#comment-13701</guid>
		<description>[...]  [...]</description>
		<content:encoded><![CDATA[<p>[...]  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Linktipps #17 :: Blackflash</title>
		<link>http://www.metabrew.com/article/rewriting-playdar-c-to-erlang-massive-savings//comment-page-1#comment-11589</link>
		<dc:creator>Linktipps #17 :: Blackflash</dc:creator>
		<pubDate>Sun, 25 Oct 2009 13:23:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.metabrew.com/?p=279#comment-11589</guid>
		<description>[...]  [...]</description>
		<content:encoded><![CDATA[<p>[...]  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RobW</title>
		<link>http://www.metabrew.com/article/rewriting-playdar-c-to-erlang-massive-savings//comment-page-1#comment-11546</link>
		<dc:creator>RobW</dc:creator>
		<pubDate>Sat, 24 Oct 2009 14:41:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.metabrew.com/?p=279#comment-11546</guid>
		<description>@James

Concerning &quot;inconsistent&quot; capitalization, Erlang is 100% consistent with capitalization. It is *enforced*. In Erlang, variables are *always* capitalized, whereas &quot;atoms&quot; are *always* lower-case. An atom (like anything in the world that is *truly* an atom) is something that is meant to be indivisible: you can&#039;t reduce it. An atom is like a variable name where you use the name itself, there is no value associated with the name.

Concerning &quot;L&quot; versus &quot;L2&quot;, Erlang is a single-assignment language. These are variables, since they are capitalized, but the naming is used to show versioning of variables (e.g. making change explicit). Within the same *scope*, once a value is bound to a variable, the variable cannot be reassigned. This design philosophy is meant to eliminate whole categories of programming errors, which is important since *reliability* is Erlang&#039;s primary goal. With multiple-assignment that most languages use, it&#039;s almost as if you have to track the state of variables in addition to the state of objects, because the same name can be bound to different values at different times within the same scope. Erlang&#039;s need for distributed programming in order to allow fail-over and similar features requires reliable concurrency. Reliable concurrency can&#039;t happen if you have to track a lot of messy state. Therefore, at every opportunity, Erlang tries to be as stateless as possible. Only each process as a whole has state by continuously passing its variables back to itself via a recursive function that acts as a main loop (it doesn&#039;t run out of stack/memory due to tail-call optimization being required).

Concerning &quot;A&quot;, &quot;B&quot;, &quot;C&quot;, and &quot;D&quot;, it looks like the author is pattern-matching in order to assign values to these, so that if you pass into the function an IP address of &quot;127.0.0.1&quot;, the result is: A=127, B=0, C=0, D=1. Since you didn&#039;t include the entire function code, I don&#039;t see where these variables are used unless I dig into the source myself.</description>
		<content:encoded><![CDATA[<p>@James</p>
<p>Concerning &#8220;inconsistent&#8221; capitalization, Erlang is 100% consistent with capitalization. It is *enforced*. In Erlang, variables are *always* capitalized, whereas &#8220;atoms&#8221; are *always* lower-case. An atom (like anything in the world that is *truly* an atom) is something that is meant to be indivisible: you can&#8217;t reduce it. An atom is like a variable name where you use the name itself, there is no value associated with the name.</p>
<p>Concerning &#8220;L&#8221; versus &#8220;L2&#8243;, Erlang is a single-assignment language. These are variables, since they are capitalized, but the naming is used to show versioning of variables (e.g. making change explicit). Within the same *scope*, once a value is bound to a variable, the variable cannot be reassigned. This design philosophy is meant to eliminate whole categories of programming errors, which is important since *reliability* is Erlang&#8217;s primary goal. With multiple-assignment that most languages use, it&#8217;s almost as if you have to track the state of variables in addition to the state of objects, because the same name can be bound to different values at different times within the same scope. Erlang&#8217;s need for distributed programming in order to allow fail-over and similar features requires reliable concurrency. Reliable concurrency can&#8217;t happen if you have to track a lot of messy state. Therefore, at every opportunity, Erlang tries to be as stateless as possible. Only each process as a whole has state by continuously passing its variables back to itself via a recursive function that acts as a main loop (it doesn&#8217;t run out of stack/memory due to tail-call optimization being required).</p>
<p>Concerning &#8220;A&#8221;, &#8220;B&#8221;, &#8220;C&#8221;, and &#8220;D&#8221;, it looks like the author is pattern-matching in order to assign values to these, so that if you pass into the function an IP address of &#8220;127.0.0.1&#8243;, the result is: A=127, B=0, C=0, D=1. Since you didn&#8217;t include the entire function code, I don&#8217;t see where these variables are used unless I dig into the source myself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RJ</title>
		<link>http://www.metabrew.com/article/rewriting-playdar-c-to-erlang-massive-savings//comment-page-1#comment-11411</link>
		<dc:creator>RJ</dc:creator>
		<pubDate>Thu, 22 Oct 2009 09:55:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.metabrew.com/?p=279#comment-11411</guid>
		<description>The reason the C++ code exists and is run as a separate process (for taglib) is because that&#039;s one of the three Erlang ways to integrate with external code. It&#039;s the simplest and cleanest way. evgen covered the three ways in his comment above. I&#039;d actually claim that as one of the great things about Erlang - it&#039;s easy to interface with external code in a standard, supported way that makes the external code look like an Erlang process (Ports).

Regarding the SLOCcount for the LAN plugin, i adjusted the C++ linecount down when collecting these stats because I didn&#039;t implement the PING/PONG stuff in the Erlang code. (ie, i removed that code from C++ then counted the lines). So I still think it&#039;s a reasonable comparison. 

I&#039;ll admit the style/newline proliferation in some of the C++ code will have inflated the line-count a little, and it could certainly be written with less newlines (and less readability, some would say), but we&#039;re still in the right ballpark.

Playdar is often network/IO bound, but it also does a lot concurrently with plugins doing things in parallel then notifying the main resolver when they find something. Erlang style concurrency is perfect for this.</description>
		<content:encoded><![CDATA[<p>The reason the C++ code exists and is run as a separate process (for taglib) is because that&#8217;s one of the three Erlang ways to integrate with external code. It&#8217;s the simplest and cleanest way. evgen covered the three ways in his comment above. I&#8217;d actually claim that as one of the great things about Erlang &#8211; it&#8217;s easy to interface with external code in a standard, supported way that makes the external code look like an Erlang process (Ports).</p>
<p>Regarding the SLOCcount for the LAN plugin, i adjusted the C++ linecount down when collecting these stats because I didn&#8217;t implement the PING/PONG stuff in the Erlang code. (ie, i removed that code from C++ then counted the lines). So I still think it&#8217;s a reasonable comparison. </p>
<p>I&#8217;ll admit the style/newline proliferation in some of the C++ code will have inflated the line-count a little, and it could certainly be written with less newlines (and less readability, some would say), but we&#8217;re still in the right ballpark.</p>
<p>Playdar is often network/IO bound, but it also does a lot concurrently with plugins doing things in parallel then notifying the main resolver when they find something. Erlang style concurrency is perfect for this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: evgen</title>
		<link>http://www.metabrew.com/article/rewriting-playdar-c-to-erlang-massive-savings//comment-page-1#comment-11390</link>
		<dc:creator>evgen</dc:creator>
		<pubDate>Thu, 22 Oct 2009 04:33:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.metabrew.com/?p=279#comment-11390</guid>
		<description>If you want to interface to external code there are three options: ports (stdin/stdout piping) which are dead simple and prevent a crash in your external code from taking down the Erlang VM at the cost of some speed due to serialization/de-serialization, linked-in drivers which can load up DLLs and shared libraries and make their functions available with none of the port overhead at the risk of a null pointer ref or some other bug in the library taking down the whole Erlang VM, or nodes that interface for a specific language.  The last option is basically a process running in language X (C, Python [including one option that uses the Twisted event loop], Ruby, etc.) that knows how to speak the erlang node protocol and can basically pretend to be another distributed node in the system.  This option is less well known than the other two but is often a good one to look at; you get somewhat faster data transfer by only needing to convert data structures to something specific for your preferred language when/if you actually need the data and you can call specific functions across the node boundary (e.g. call an Erlang function from Python or call a C function from Erlang.)</description>
		<content:encoded><![CDATA[<p>If you want to interface to external code there are three options: ports (stdin/stdout piping) which are dead simple and prevent a crash in your external code from taking down the Erlang VM at the cost of some speed due to serialization/de-serialization, linked-in drivers which can load up DLLs and shared libraries and make their functions available with none of the port overhead at the risk of a null pointer ref or some other bug in the library taking down the whole Erlang VM, or nodes that interface for a specific language.  The last option is basically a process running in language X (C, Python [including one option that uses the Twisted event loop], Ruby, etc.) that knows how to speak the erlang node protocol and can basically pretend to be another distributed node in the system.  This option is less well known than the other two but is often a good one to look at; you get somewhat faster data transfer by only needing to convert data structures to something specific for your preferred language when/if you actually need the data and you can call specific functions across the node boundary (e.g. call an Erlang function from Python or call a C function from Erlang.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://www.metabrew.com/article/rewriting-playdar-c-to-erlang-massive-savings//comment-page-1#comment-11389</link>
		<dc:creator>James</dc:creator>
		<pubDate>Thu, 22 Oct 2009 04:28:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.metabrew.com/?p=279#comment-11389</guid>
		<description>It probably doesn&#039;t help that I don&#039;t know Erlang, but I don&#039;t understand why any time I read other people&#039;s Erlang code I see all these one letter variable names and weird, inconsistent capitalization. E.g.:

handle_info({udp, _Sock, {A,B,C,D}=Ip, _InPortNo, Packet}, State) -&gt;
    ?LOG(debug, &quot;received msg: ~s&quot;, [Packet]),
    {struct, L} = mochijson2:decode(Packet),
    case proplists:get_value(&lt;&gt;,L) of
        &lt;&gt; -&gt;
            Qid = proplists:get_value(&lt;&gt;, L),
            case resolver:qid2pid(Qid) of
                Qpid when is_pid(Qpid) -&gt;
                    {struct, L2} = proplists:get_value(&lt;&gt;, L),

What is all this A,B,C,D, Qid, L, L2, etc.? And why is your C++ code so vertically spaced out in some places?

            unsigned short port = DEFAULT_LAN_PORT;
            string ip;
            if( v.type() == str_type )
            {
                ip = v.get_str();
            } 
            else if( v.type() != array_type )
            {
                continue;
            }
            else
            {

This could as easily and as (more?) readably be written

            unsigned short port = DEFAULT_LAN_PORT;
            string ip;
            if( v.type() == str_type ) { ip = v.get_str(); } 
            else if( v.type() != array_type ) { continue; }
            else {

Voila! 50% savings, C++ versus . . . C++.

By the way, I&#039;m not trying to knock your choice in language by any means. From everything I&#039;ve heard, Erlang is a great language. And there may very well be a difference between it and C++ in terms of conciseness. But when I see all these line count comparisons sometimes I get a sense that it&#039;s less that one language offers more conciseness than another and more that the author _wants_ it to, and thus codes differently such that the conclusion they wish to draw is supported.</description>
		<content:encoded><![CDATA[<p>It probably doesn&#8217;t help that I don&#8217;t know Erlang, but I don&#8217;t understand why any time I read other people&#8217;s Erlang code I see all these one letter variable names and weird, inconsistent capitalization. E.g.:</p>
<p>handle_info({udp, _Sock, {A,B,C,D}=Ip, _InPortNo, Packet}, State) -&gt;<br />
    ?LOG(debug, &#8220;received msg: ~s&#8221;, [Packet]),<br />
    {struct, L} = mochijson2:decode(Packet),<br />
    case proplists:get_value(&lt;&gt;,L) of<br />
        &lt;&gt; -&gt;<br />
            Qid = proplists:get_value(&lt;&gt;, L),<br />
            case resolver:qid2pid(Qid) of<br />
                Qpid when is_pid(Qpid) -&gt;<br />
                    {struct, L2} = proplists:get_value(&lt;&gt;, L),</p>
<p>What is all this A,B,C,D, Qid, L, L2, etc.? And why is your C++ code so vertically spaced out in some places?</p>
<p>            unsigned short port = DEFAULT_LAN_PORT;<br />
            string ip;<br />
            if( v.type() == str_type )<br />
            {<br />
                ip = v.get_str();<br />
            }<br />
            else if( v.type() != array_type )<br />
            {<br />
                continue;<br />
            }<br />
            else<br />
            {</p>
<p>This could as easily and as (more?) readably be written</p>
<p>            unsigned short port = DEFAULT_LAN_PORT;<br />
            string ip;<br />
            if( v.type() == str_type ) { ip = v.get_str(); }<br />
            else if( v.type() != array_type ) { continue; }<br />
            else {</p>
<p>Voila! 50% savings, C++ versus . . . C++.</p>
<p>By the way, I&#8217;m not trying to knock your choice in language by any means. From everything I&#8217;ve heard, Erlang is a great language. And there may very well be a difference between it and C++ in terms of conciseness. But when I see all these line count comparisons sometimes I get a sense that it&#8217;s less that one language offers more conciseness than another and more that the author _wants_ it to, and thus codes differently such that the conclusion they wish to draw is supported.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik Frey</title>
		<link>http://www.metabrew.com/article/rewriting-playdar-c-to-erlang-massive-savings//comment-page-1#comment-11388</link>
		<dc:creator>Erik Frey</dc:creator>
		<pubDate>Thu, 22 Oct 2009 01:47:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.metabrew.com/?p=279#comment-11388</guid>
		<description>Wah-hey it broke my code, let&#039;s try html-escaping:

./server &lt; myfifo &#124; script.py &gt; myfifo</description>
		<content:encoded><![CDATA[<p>Wah-hey it broke my code, let&#8217;s try html-escaping:</p>
<p>./server &lt; myfifo | script.py &gt; myfifo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik Frey</title>
		<link>http://www.metabrew.com/article/rewriting-playdar-c-to-erlang-massive-savings//comment-page-1#comment-11387</link>
		<dc:creator>Erik Frey</dc:creator>
		<pubDate>Thu, 22 Oct 2009 01:45:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.metabrew.com/?p=279#comment-11387</guid>
		<description>But... but...

I was curious to see if erlang had some kind of support for binding to c libraries, for how you got taglib on erlang, but you&#039;re just spawning a process and talking on stdio!  That&#039;s cheating!    :p

That&#039;s about the biggest nit I can find to pick.  And I have a C++ server that&#039;s using python right now by running ./server  myfifo so I can&#039;t really say anything      :)

Pretty awesome.  I guess I&#039;m with Norman, a big pain in the ass VM was my last excuse.  I&#039;m out of excuses!</description>
		<content:encoded><![CDATA[<p>But&#8230; but&#8230;</p>
<p>I was curious to see if erlang had some kind of support for binding to c libraries, for how you got taglib on erlang, but you&#8217;re just spawning a process and talking on stdio!  That&#8217;s cheating!    :p</p>
<p>That&#8217;s about the biggest nit I can find to pick.  And I have a C++ server that&#8217;s using python right now by running ./server  myfifo so I can&#8217;t really say anything      :)</p>
<p>Pretty awesome.  I guess I&#8217;m with Norman, a big pain in the ass VM was my last excuse.  I&#8217;m out of excuses!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
