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

<channel>
	<title>Monomorphic &#187; Software development</title>
	<atom:link href="http://www.monomorphic.org/wordpress/category/dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.monomorphic.org/wordpress</link>
	<description>Nystrom re-presents</description>
	<lastBuildDate>Tue, 27 Jul 2010 02:12:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Why Scala? (2) Compact syntax applied to probabilistic actions</title>
		<link>http://www.monomorphic.org/wordpress/why-scala-2-compact-syntax-applied-to-probabilistic-actions/</link>
		<comments>http://www.monomorphic.org/wordpress/why-scala-2-compact-syntax-applied-to-probabilistic-actions/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 22:13:36 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Software development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=671</guid>
		<description><![CDATA[As a little fun project, I developed some probabilistic cellular automata with Scala and very basic AWT graphics. I continue to become more proficient with Scala, and it feels increasingly natural to use. During this exercise I came up with something that I thought was particularly elegant, and that I am pretty sure would have [...]]]></description>
			<content:encoded><![CDATA[<p>As a little fun project, I developed some probabilistic cellular automata with Scala and very basic AWT graphics. I continue to become more proficient with Scala, and it feels increasingly natural to use. During this exercise I came up with something that I thought was particularly elegant, and that I am pretty sure would have been a lot less readable in Java. I will just reproduce the interesting bits. The basic idea is that I want cells on a 2D grid to take certain redrawing actions according to given probabilities. First, I define this utility function:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">object</span> Util <span style="color: #F78811;">&#123;</span>
&nbsp;
	<span style="color: #008000; font-style: italic;">//sum of floats (probabilities) should be at most 1.0</span>
	<span style="color: #0000ff; font-weight: bold;">def</span> multiAction<span style="color: #F78811;">&#40;</span>acts<span style="color: #000080;">:</span> Seq<span style="color: #F78811;">&#91;</span>Tuple2<span style="color: #F78811;">&#91;</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span><span style="color: #000080;">=&gt;</span> Unit, Float<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> <span style="color: #F78811;">&#123;</span>
		<span style="color: #0000ff; font-weight: bold;">val</span> r <span style="color: #000080;">=</span> Math.<span style="color: #000000;">random</span>
		<span style="color: #0000ff; font-weight: bold;">var</span> soFar<span style="color: #000080;">:</span> Float <span style="color: #000080;">=</span> <span style="color: #F78811;">0</span>
		<span style="color: #0000ff; font-weight: bold;">var</span> acted <span style="color: #000080;">=</span> <span style="color: #0000ff; font-weight: bold;">false</span>
		<span style="color: #0000ff; font-weight: bold;">for</span> <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span>act,prob<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">&lt;</span>- acts<span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
			soFar +<span style="color: #000080;">=</span> prob
&nbsp;
			<span style="color: #0000ff; font-weight: bold;">if</span> <span style="color: #F78811;">&#40;</span>soFar <span style="color: #000080;">&gt;</span> r <span style="color: #000080;">&amp;&amp;</span> <span style="color: #000080;">!</span>acted<span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
				act<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span>	
				acted <span style="color: #000080;">=</span> <span style="color: #0000ff; font-weight: bold;">true</span>
			<span style="color: #F78811;">&#125;</span>
		<span style="color: #F78811;">&#125;</span>
	<span style="color: #F78811;">&#125;</span>
&nbsp;
<span style="color: #F78811;">&#125;</span></pre></div></div>

<p>The idea here is that we supply a list of tuples. The first element of each tuple is a function, and the second element is a float value between 0 and 1 representing the probability that each function is evaluated. Only one of the functions supplied is actually evaluated.</p>
<p>This is how I put it to use (excerpt from another class):</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;">Util.<span style="color: #000000;">multiAction</span><span style="color: #F78811;">&#40;</span>
  List<span style="color: #F78811;">&#40;</span> 
  <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> <span style="color: #F78811;">&#123;</span>
     cellsWrite<span style="color: #F78811;">&#40;</span>x, y-<span style="color: #F78811;">1</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> cellsRead<span style="color: #F78811;">&#40;</span>x, y-<span style="color: #F78811;">1</span><span style="color: #F78811;">&#41;</span> + 0.01f<span style="color: #000080;">;</span>
     cellsWrite<span style="color: #F78811;">&#40;</span>x, y+<span style="color: #F78811;">1</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> cellsRead<span style="color: #F78811;">&#40;</span>x, y+<span style="color: #F78811;">1</span><span style="color: #F78811;">&#41;</span> + 0.01f 
    <span style="color: #F78811;">&#125;</span>, 0.2f<span style="color: #F78811;">&#41;</span>,
  <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> <span style="color: #F78811;">&#123;</span> 
     cellsWrite<span style="color: #F78811;">&#40;</span>x+<span style="color: #F78811;">1</span>, y<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> cellsRead<span style="color: #F78811;">&#40;</span>x+<span style="color: #F78811;">1</span>, y<span style="color: #F78811;">&#41;</span> + 0.01f<span style="color: #000080;">;</span>
     cellsWrite<span style="color: #F78811;">&#40;</span>x-<span style="color: #F78811;">1</span>, y<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> cellsRead<span style="color: #F78811;">&#40;</span>x-<span style="color: #F78811;">1</span>, y<span style="color: #F78811;">&#41;</span> + 0.01f 
    <span style="color: #F78811;">&#125;</span>, 0.1f<span style="color: #F78811;">&#41;</span>
 <span style="color: #F78811;">&#41;</span>
<span style="color: #F78811;">&#41;</span></pre></div></div>

<p>Once you take in the braces here it is actually quite simple. We have two anonymous functions taking zero parameters of two statements each. The first one has probability 0.2 and the second probability 0.1, meaning that there&#8217;s a 70% probability that nothing will happen. We can also make an arbitrarily long list of such functions on the fly.</p>
<p>To the best of my knowledge, the only way of reproducing this flexibility in Java would be to create anonymous inner classes and put them inside an array. Certainly that would be quite a bit more verbose than this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/why-scala-2-compact-syntax-applied-to-probabilistic-actions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The aesthetics of technology</title>
		<link>http://www.monomorphic.org/wordpress/the-aesthetics-of-technology/</link>
		<comments>http://www.monomorphic.org/wordpress/the-aesthetics-of-technology/#comments</comments>
		<pubDate>Tue, 18 May 2010 14:20:51 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[culture]]></category>
		<category><![CDATA[darwinism]]></category>
		<category><![CDATA[human condition]]></category>
		<category><![CDATA[society]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=583</guid>
		<description><![CDATA[Different technologies have different kinds of aesthetics, and they affect us in various ways, whether we are particularly fascinated with technology or not. The easiest technologies to understand on an intuitive-emotional basis seem to be those that involve physical processes. Objects rotating, moving, being lifted and displaced, compressed, crushed. Gases and liquids being sent around [...]]]></description>
			<content:encoded><![CDATA[<p>Different technologies have different kinds of aesthetics, and they affect us in various ways, whether we are particularly fascinated with technology or not.</p>
<p>The easiest technologies to understand on an intuitive-emotional basis seem to be those that involve physical processes. Objects rotating, moving, being lifted and displaced, compressed, crushed. Gases and liquids being sent around in conduits, mediating force and energy. In short, the technology that has its foundation in classical mechanics.</p>
<p><a href="http://en.wikipedia.org/wiki/Steam_engine"><img class="alignleft size-medium wp-image-584" style="margin:1em" title="steamEngine" src="http://www.monomorphic.org/wordpress/wp-content/uploads/2010/05/steamEngine-300x199.jpg" alt="" width="300" height="199" /></a></p>
<p>If these are easy to <em>get a feel for</em>, it would probably be in part because an understanding of mechanical processes has been of use to us throughout history, and also before the advent of civilisation. An intuitive understanding of things such as momentum, acceleration, gravity has no doubt benefited mankind and its ancestors for a very long time.</p>
<p>It gets trickier when we get to the more recent technologies. Take electricity to be an arbitrary watershed. We have no intuitive idea of what electricity is, apart from the fact we might be afraid of thunder. Electricity has to be taught through the abstract idea of electrons flowing in conduits, a bit like water in pipes (to name one of many images being used).</p>
<p>And then there&#8217;s analog and digital electronics, integrated circuits, semiconductors and so on, where intuition has long ago been left behind. We are forced to approach these things in a purely abstract domain.</p>
<p><a href="http://www.monomorphic.org/wordpress/wp-content/uploads/2010/05/earlyLed.jpg"><img class="alignleft size-medium wp-image-591" style="margin:1em" title="earlyLed" src="http://www.monomorphic.org/wordpress/wp-content/uploads/2010/05/earlyLed-300x90.jpg" alt="" width="300" height="90" /></a>Yet, when our Mp3 players, game consoles, mobile phones and computers do things for us, we are left with a sense of wonder. Our minds, always looking for stories and explanations, want to associate the impressive effects produced by these devices with some stimuli. With a steam engine, it&#8217;s easy to associate the energy with pressure, heat and motion, all of which are well understood on a low level. With a mobile phone, not so much. A lot of very abstract stories have to be used in order to reach anything that resembles an explanation, and still it doesn&#8217;t reach the essence of the device, which might be in its interplay between radio transceivers, sound codec chips, a display with a user interface and software to drive it, a central CPU, and so on, together with, of course, the network of physical antennas and their connectivity with other such networks. Is it too much to suppose that the human mind often stops short of the true explanation here? That we associate the effects produced by the device with what we can touch, smell, see and hear?</p>
<p><a href="http://en.wikipedia.org/wiki/Computer_terminal"><img class="alignleft size-medium wp-image-586" style="margin:1em" title="crtTerminal" src="http://www.monomorphic.org/wordpress/wp-content/uploads/2010/05/crtTerminal-300x257.jpg" alt="" width="300" height="257" /></a> This is of course the point where many computer geeks worldwide start to feel a certain affection for the materials that make up the machines. Suppose that we are in the 1980&#8242;s. Green text on a black terminal background. A particular kind of fixed width font. The clicking of the keyboard. The dull grey plastic used to make the case. All of these things can acquire a lot of meaning that they don&#8217;t really have, because the users lack a window (physical and emotional) into the essence of the machine. The ultimate &#8220;disconnected machine&#8221;, to relate to my field, is software.</p>
<p>This brings up questions such as: how far can we as a species proceed with technology that we cannot understand instinctively, how can we teach such technology meaningfully and include it in democratic debate, and how can we use people&#8217;s tendencies to associate sensory stimuli with meaning and effects in a more meaningful way? &#8211; for instance, when we design hardware and software interfaces.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/the-aesthetics-of-technology/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Doing generality right</title>
		<link>http://www.monomorphic.org/wordpress/doing-generality-right/</link>
		<comments>http://www.monomorphic.org/wordpress/doing-generality-right/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 02:00:02 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[HCI]]></category>
		<category><![CDATA[platforms]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[reuse]]></category>
		<category><![CDATA[smalltalk]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=558</guid>
		<description><![CDATA[Many software developers, while making a tool to solve a specific problem, heed the siren call of generality. By making a few specific changes, they can turn the tool into a general framework for solving a larger class of problems. And then, with a few more changes, an even larger class of problems, and so [...]]]></description>
			<content:encoded><![CDATA[<p>Many software developers, while making a tool to solve a specific problem, heed the siren call of generality. By making a few specific changes, they can turn the tool into a general framework for solving a larger class of problems. And then, with a few more changes, an even larger class of problems, and so on. This often turns into a trap, and there is a risk that the end of the line is an over-generalised tool that isn&#8217;t very good at solving any problem, because the specificity that was present in the first place was part of why it was powerful. In this way, constraints can equal freedom.</p>
<p>Sometimes, though, the generalizers get it right. These are often moments of exceptional and lasting innovation. One example of such a system is the fabulously influential (but today, not that widely used) programming language <a href="http://www.smalltalk.org">Smalltalk</a>. Invented by the former jazz guitarist and subsequent Turing award winner <a href="http://en.wikipedia.org/wiki/Alan_Kay">Alan Kay</a>, Smalltalk was released as one of the first true object-oriented programming languages in 1980. It is probably still ahead of its time. It runs on a virtual machine, it has reflection, everything is an object, and the separation between applications is blurred in favour of a big object box. On running <a href="http://www.squeak.org/">Squeak</a>, a popular Smalltalk implementation, with its default system image today, users discover that all the objects on the screen, including the IDE to develop and debug objects, appear to follow the same rules. No objects seem to have special privileges.</p>
<p>Another such system is an application that used to be shipped on Mac computers in the distant past, <a href="http://en.wikipedia.org/wiki/HyperCard">Hypercard</a>. Hypercard enabled ordinary users to create highly customized software using the idea of filing cards in a drawer as the underlying model, blurring the line between end users and developers through its accessibility. I haven&#8217;t had the privilege to use it myself, but it seems like this was as powerful as it was because it served up a homogenous and familiar model, where everything was a card, and yet the cards had considerable scope for modification and special features. Even though, in some ways, this system appears to be a database, the cards didn&#8217;t need to have the same format, for instance. (Are we seeing this particular idea being recycled in a more enterprisey form in <a href="http://couchdb.apache.org/">CouchDB</a>?)</p>
<p>There are more examples of successful highly general design: the Unix file system, TCP/IP sockets and so on. They all have in common that they are easy to think about as a mental model, since a universal set of rules apply to all objects, they scale well in different directions when used for different purposes, and they give the user a satisfying sense of empowerment, <a href="http://www.monomorphic.org/wordpress/making-playtime-useful-with-color-filling-games/">blurring the line between work and play</a> to draw on the user&#8217;s natural creativity. Successful general systems are the ones that can be easily applied in quite varied situations without tearing in the seams.</p>
<p>While not widely used by industrial programmers today, Smalltalk was incredibly influential. In 1981 Objective-C was created by Brad Cox and Tom Love, directly inspired by what the Smalltalk designers had done. Objective-C was subsequently used as the language of choice for NeXTStep, and later for Apple&#8217;s MacOS X when Apple bought NeXT. Today it&#8217;s seeing a big surge in popularity thanks to devices like the iPhone, on which it is also used. In 1995 Java was introduced, owing a great deal of its design to Objective-C, but also introducing features such as a universal virtual machine and garbage collection, which Objective-C didn&#8217;t have at the time. In some sense, both Objective-C and Java are blends of the C-family languages and Smalltalk. Tongue in cheek, we might say that it seems evolution in industrial programming these days consists of finding blends that contain less of the C model and more of smalltalk or functional programming.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/doing-generality-right/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Overloading words in research and programming</title>
		<link>http://www.monomorphic.org/wordpress/overloading-words-in-research-and-programming/</link>
		<comments>http://www.monomorphic.org/wordpress/overloading-words-in-research-and-programming/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 06:16:22 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[human condition]]></category>
		<category><![CDATA[Natural language]]></category>
		<category><![CDATA[ontologies]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=540</guid>
		<description><![CDATA[In research and academia, one of the fundamental activities is the invention and subsequent examination of new concepts. For concepts, we need names. One way of making a name is stringing words together until the meaning is sufficiently specific. E.g. &#8220;morphism averse co-dependent functor substitutions in virtual machine transmigration systems&#8221;. Thus the abstruse academic research [...]]]></description>
			<content:encoded><![CDATA[<p>In research and academia, one of the fundamental activities is the invention and subsequent examination of new concepts. For concepts, we need names.</p>
<p>One way of making a name is stringing words together until the meaning is sufficiently specific. E.g. &#8220;morphism averse co-dependent functor substitutions in virtual machine transmigration systems&#8221;. Thus the abstruse academic research paper title is born.</p>
<p>Sciences sometimes give new meanings to existing words. This could be called overloading, following the example of object-oriented programming. E.g. a &#8220;group&#8221; in mathematics is something different from the everyday use of the term. A &#8220;buffer&#8221; in chemistry is something different from a software or hardware buffer, even though a fragment of similarity is there. And so on. This overloading of words gives newcomers to the field a handle on what is meant, but full understanding is still impossible without understanding the actual definitions being employed.</p>
<p>Sometimes new terms can be created using inventors&#8217; names and everyday words. E.g. a &#8220;Lie group&#8221; or the &#8220;Maxwell equations&#8221;, or &#8220;Curry-Howard correspondence&#8221;. This is potentially useful, but perhaps not something you can do freely with your own research without seeming like you&#8217;re trying to inflate your ego excessively. (Even though researchers love inflating their egos, nobody wants to admit it.)</p>
<p>There&#8217;s a similar problem in software development. When we invent names of functions, classes and variables, the lack of words becomes very clear. Intuitively, what is an &#8220;adapter registry&#8221;? An &#8220;observer list&#8221;? Or an &#8220;observer list mediation adapter?&#8221; My feeling is that we often end up compounding abstract words because we have no better choice. And here lies a clue to some of the apparent impermeability of difficult source code. We need better ways of making names. We&#8217;re inventing ideas faster than our language can stretch.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/overloading-words-in-research-and-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gregorian misery</title>
		<link>http://www.monomorphic.org/wordpress/gregorian-misery/</link>
		<comments>http://www.monomorphic.org/wordpress/gregorian-misery/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 02:12:47 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Software development]]></category>
		<category><![CDATA[complexity]]></category>
		<category><![CDATA[papal]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=541</guid>
		<description><![CDATA[The Gregorian calendar has been in use since 1582. Among its features is a moderately complicated rule for leap years: if n mod 4 is 0, then n is a leap year. However, if n mod 100 is 0, then n is not a leap year, unless n is a multiple of 400. In addition, [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://en.wikipedia.org/wiki/Gregorian_calendar">Gregorian calendar</a> has been in use since 1582. Among its features is a moderately complicated rule for leap years: if <em>n mod 4</em> is 0, then <em>n</em> is a leap year. However, if <em>n mod 100 </em> is 0, then <em>n </em>is not a leap year, unless <em>n</em> is a multiple of 400.</p>
<p>In addition, we live in a world with timezones and regional differences in when countries go on and off daylight savings time, if they have such a system. As yet another example of Japanese rationality, Japan does not have a DST system.</p>
<p>Implementing date and time computations correctly can be very hard for computer programmers and is invariably a source of many hidden bugs that may take a long time to discover. Yesterday, a large amount of Sony&#8217;s Playstation 3 game consoles <a href="http://news.cnet.com/8301-17938_105-10461364-1.html?part=rss&amp;subj=news&amp;tag=2547-1_3-0-20">stopped working normally</a>. Â This was later <a href="http://news.cnet.com/8301-17938_105-10461881-1.html?part=rss&amp;subj=news&amp;tag=2547-1_3-0-20">fixed</a>. There was speculation the error was due to incorrect leap year handling. It wouldn&#8217;t be the first time this occurred if this was indeed the reason.</p>
<p>In a software company where I used to work, there would usually be massive troubles every time some country went on or off daylight savings time, or any other time calculation hit a sensitive spot. I&#8217;m fairly sure that the world&#8217;s software systems, including government, finance, insurance, health care, suffer untold billions of damage every year due to the complexity of the system. Maybe we should simplify it.</p>
<p>I suggest having &#8220;years&#8221; with 365 x 4 + 1 = 1461 days instead of the usual year for starters. This would move the leap year problem ahead until year 2100, when the next special rule comes in. By that time, software engineering technology should have improved enough that this should no longer be an issue, I hope. If not, we can invent another system by then. Let&#8217;s also scrap all daylight savings time everywhere. It&#8217;s easy to do and the savings would be huge.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/gregorian-misery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tips for academics who develop software</title>
		<link>http://www.monomorphic.org/wordpress/advice-for-academics-who-develop-software/</link>
		<comments>http://www.monomorphic.org/wordpress/advice-for-academics-who-develop-software/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 17:44:14 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Software development]]></category>
		<category><![CDATA[academic]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[software engineering]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=533</guid>
		<description><![CDATA[Academics and practitioners, having rather different goals in life, tend to approach software development in quite different ways. No doubt there are many things each side of the fence can learn from the other, but I think academics in particular could often benefit quite a lot by adopting some of the practices used in industrial [...]]]></description>
			<content:encoded><![CDATA[<p>Academics and practitioners, having rather different goals in life, tend to approach software development in quite different ways. No doubt there are many things each side of the fence can learn from the other, but I think academics in particular could often benefit quite a lot by adopting some of the practices used in industrial development. And not just computer science academics!</p>
<p>A common misconception is that these techniques only are useful with large projects and large teams. I find, though, that they can help reduce much of the growth pains even in small projects, helping them reach maturity much faster.</p>
<p><strong>Use version control.</strong> Classical, but invalid, counter arguments include &#8220;it&#8217;s a hassle and too much work to set up&#8221;, or &#8220;there&#8217;s only one person working on this project anyway&#8221;. Even if it&#8217;s only you, you will benefit massively from being able to undo your changes far back in time. It will let you experiment safely. Plus, setup is no longer an issue with free and easy-to-use services like <a href="http://www.gitbub.com">github</a> and <a href="http://www.bitbucket.org">bitbucket</a>. My tool of choice is now Mercurial, and I used to use SVN. And there are many other good choices.</p>
<p><strong>Use a debugger.</strong> If there is a debugger available for your language, and there most certainly is, then you should use it to find nontrivial errors, rather than extensive printf style testing.</p>
<p><strong>Don&#8217;t optimise prematurely, but when you need to, use a profiler.</strong> Profilers tell you where a program&#8217;s performance bottlenecks are. You can profile things like heap usage (what classes use most space in Java, for instance) and CPU usage (which functions use the most CPU time). For Java, I&#8217;ve discovered that the NetBeans IDE has a very good built in profiler. Eclipse also has one, but it didn&#8217;t work on Mac last time I checked. For C/C++, GProf used to be good and probably still is.</p>
<p><strong>Use unit testing wisely.</strong> All of the above apply even to very small projects, but I think some projects are too small to need unit tests, at least initially. You be the judge. I find that unit tests can have a lot of benefit when applied to the fragile, complicated parts of a system, where many different things interlock. If you are ambitious you can also write tests first and code later &#8212; test driven development.</p>
<p><strong>Use a good IDE if you can.</strong> For a language like Java, where you have to type a lot of code to get something done and spread out your code across lots of files, a good IDE that can generate boilerplate code and navigate quickly can really speed up your work. It&#8217;s beneficial for other languages too. But I have no problem with people who use pure vim or emacs, after all these are practically IDEs.</p>
<p>I believe that honing your software development skills as an academic can pay off. Also see: Daniel Lemire on <a href="http://feedproxy.google.com/~r/daniel-lemire/atom/~3/yCTh62CVGi0/">why you should open source your projects</a>. (I will get around to doing this eventually, I promise <img src='http://www.monomorphic.org/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> )</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/advice-for-academics-who-develop-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Scala? The mixing of imperative and functional style</title>
		<link>http://www.monomorphic.org/wordpress/why-scala-the-mixing-of-imperative-and-functional-style/</link>
		<comments>http://www.monomorphic.org/wordpress/why-scala-the-mixing-of-imperative-and-functional-style/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 04:15:29 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Software development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=519</guid>
		<description><![CDATA[Scala is a little wonderland sprinkled with useful things you can mix and match as you like to improve your coding experience while staying on the Java platform. The Option classes, the structural case matching, the compact declarations, lazy evaluation&#8230; the list goes on. But at the heart of it is the decision to mix [...]]]></description>
			<content:encoded><![CDATA[<p>Scala is a little wonderland sprinkled with useful things you can mix and match as you like to improve your coding experience while staying on the Java platform. The Option classes, the structural case matching, the compact declarations, lazy evaluation&#8230; the list goes on. But at the heart of it is the decision to mix freely the functional and imperative programming styles.</p>
<p>How does this work in practice?</p>
<ul>
<li>Statements can have side effects, like in Java</li>
<li>The final statement evaluated in a function is its return value by default</li>
<li>Every statement evaluates to a value, even control flow statements like if&#8230; else, unlike in Java</li>
</ul>
<p>The bottom line is that some problems call for a functional programming style, and others for an imperative one. Scala doesn&#8217;t force you into a mold, it just gives you what you need to express what you&#8217;d like to express. This can lead to very compact code. Here&#8217;s a function that recursively finds all files ending in .java starting in a given directory. The File class here is the standard Java java.io.File!</p>
<p>Remember, the last expression evaluated is the return value.</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"> <span style="color: #0000ff; font-weight: bold;">def</span> findJavaFiles<span style="color: #F78811;">&#40;</span>dir<span style="color: #000080;">:</span> File<span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> List<span style="color: #F78811;">&#91;</span>File<span style="color: #F78811;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #F78811;">&#123;</span>
    <span style="color: #0000ff; font-weight: bold;">val</span> files <span style="color: #000080;">=</span> dir.<span style="color: #000000;">listFiles</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span>
    <span style="color: #0000ff; font-weight: bold;">val</span> javaFiles <span style="color: #000080;">=</span> files.<span style="color: #000000;">filter</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#123;</span><span style="color: #000080;">_</span>.<span style="color: #000000;">getName</span>.<span style="color: #000000;">endsWith</span><span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;.java&quot;</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#125;</span><span style="color: #F78811;">&#41;</span>
    <span style="color: #0000ff; font-weight: bold;">val</span> dirs <span style="color: #000080;">=</span> files.<span style="color: #000000;">filter</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#123;</span><span style="color: #000080;">_</span>.<span style="color: #000000;">isDirectory</span><span style="color: #F78811;">&#125;</span><span style="color: #F78811;">&#41;</span>
    javaFiles.<span style="color: #000000;">toList</span> ++ dirs.<span style="color: #000000;">flatMap</span><span style="color: #F78811;">&#123;</span>findJavaFiles<span style="color: #F78811;">&#40;</span><span style="color: #000080;">_</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#125;</span>
  <span style="color: #F78811;">&#125;</span></pre></div></div>

<p>But we can write it even more compactly at the expense of some clarity:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"> <span style="color: #0000ff; font-weight: bold;">def</span> findJavaFiles<span style="color: #F78811;">&#40;</span>dir<span style="color: #000080;">:</span> File<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> <span style="color: #F78811;">&#123;</span>
    <span style="color: #0000ff; font-weight: bold;">val</span> files <span style="color: #000080;">=</span> dir.<span style="color: #000000;">listFiles</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span>
    files.<span style="color: #000000;">filter</span><span style="color: #F78811;">&#40;</span><span style="color: #000080;">_</span>.<span style="color: #000000;">getName</span>.<span style="color: #000000;">endsWith</span><span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;.java&quot;</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>.<span style="color: #000000;">toList</span> ++
 files.<span style="color: #000000;">filter</span><span style="color: #F78811;">&#40;</span><span style="color: #000080;">_</span>.<span style="color: #000000;">isDirectory</span><span style="color: #F78811;">&#41;</span>.<span style="color: #000000;">flatMap</span><span style="color: #F78811;">&#123;</span>findJavaFiles<span style="color: #F78811;">&#40;</span><span style="color: #000080;">_</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#125;</span>
  <span style="color: #F78811;">&#125;</span></pre></div></div>

<p>Now write this function in Java and see how many lines you end up with.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/why-scala-the-mixing-of-imperative-and-functional-style/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nietzsche on software (?)</title>
		<link>http://www.monomorphic.org/wordpress/nietzsche-on-software/</link>
		<comments>http://www.monomorphic.org/wordpress/nietzsche-on-software/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 12:16:54 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[fallacies]]></category>
		<category><![CDATA[nietzsche]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=458</guid>
		<description><![CDATA[In his first amendment toÂ Human, All Too Human (1886), entitled Miscellaneous Maxims and Opinions, Friedrich Nietzsche states that 300. HOW FAR EVEN IN THE GOOD THE HALF MAY BE MORE THAN THE WHOLE. &#8212; In all things that are constructed to last and demand the service of many hands, much that is less good must [...]]]></description>
			<content:encoded><![CDATA[<p>In his first amendment toÂ <em>Human, All Too Human (1886), </em>entitled <em>Miscellaneous Maxims and Opinions</em>, Friedrich Nietzsche states that</p>
<blockquote><p>300. HOW FAR EVEN IN THE GOOD THE HALF MAY BE MORE THAN THE WHOLE. &#8212; In all things that are constructed to last and demand the service of many hands, much that is less good must be made the rule, although the organiser knows what is better and harder very well.He will calculate that there will never be a lack of persons Â who <em>can</em> correspond to the rule, and he knows that the middling good is the rule. &#8212; The youth seldom sees this point, and as an innovator thinks how marvelously he is in the right and how strange is the blindness of others. (Helen Zimmern transl.)</p></blockquote>
<p>Friedrich Nietzsche did not describe software making &#8211; I can only assume that he was describing authors and ideologists &#8211; but this seems to capture the difficulties of software development only too well. And it seems to give a recipe for how to overcome the communication difficulties (abandon exotic, over-refined solutions and focus on an easily understood middle ground, so that everybody can get together and comprehend the architecture). This was originally published in 1886.</p>
<p>With that, merry christmas!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/nietzsche-on-software/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>An immutable MultiMap for Scala</title>
		<link>http://www.monomorphic.org/wordpress/an-immutable-multimap-for-scala/</link>
		<comments>http://www.monomorphic.org/wordpress/an-immutable-multimap-for-scala/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 06:41:05 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Software development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=438</guid>
		<description><![CDATA[The Scala collections library (in version 2.7.7) has a MultiMap trait for mutable collections, but none for immutable ones. I hacked something up to use while waiting for an official version. I&#8217;m finding this to work well, but I don&#8217;t have much experience with collections design, so it&#8217;s likely to have some flaws. Also, this [...]]]></description>
			<content:encoded><![CDATA[<p>The Scala collections library (in version 2.7.7) has a MultiMap trait for mutable collections, but none for immutable ones. I hacked something up to use while waiting for an official version. I&#8217;m finding this to work well, but I don&#8217;t have much experience with collections design, so it&#8217;s likely to have some flaws. Also, this is a class and not a trait, so you can&#8217;t use it with any map you like. And from a concurrency perspective, maybe it&#8217;s sometimes better to use backing collections other than the HashSet and the HashMap.</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;">&nbsp;
<span style="color: #0000ff; font-weight: bold;">import</span> scala.<span style="color: #000000;">collection</span>.<span style="color: #000000;">immutable</span>.<span style="color: #000080;">_</span>
&nbsp;
<span style="color: #00ff00; font-style: italic;">/**
A multimap for immutable member sets (the Scala libraries 
only have one for mutable sets). 
*/</span>
<span style="color: #0000ff; font-weight: bold;">class</span> MultiMap<span style="color: #F78811;">&#91;</span>A, B<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span><span style="color: #0000ff; font-weight: bold;">val</span> myMap<span style="color: #000080;">:</span> Map<span style="color: #F78811;">&#91;</span>A, Set<span style="color: #F78811;">&#91;</span>B<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
&nbsp;
	<span style="color: #0000ff; font-weight: bold;">def</span> <span style="color: #0000ff; font-weight: bold;">this</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> <span style="color: #0000ff; font-weight: bold;">this</span><span style="color: #F78811;">&#40;</span><span style="color: #0000ff; font-weight: bold;">new</span> HashMap<span style="color: #F78811;">&#91;</span>A, Set<span style="color: #F78811;">&#91;</span>B<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#41;</span>
&nbsp;
	<span style="color: #0000ff; font-weight: bold;">def</span> +<span style="color: #F78811;">&#40;</span>kv<span style="color: #000080;">:</span> Tuple2<span style="color: #F78811;">&#91;</span>A, B<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> MultiMap<span style="color: #F78811;">&#91;</span>A, B<span style="color: #F78811;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #F78811;">&#123;</span>
	  <span style="color: #0000ff; font-weight: bold;">val</span> set <span style="color: #000080;">=</span> <span style="color: #0000ff; font-weight: bold;">if</span> <span style="color: #F78811;">&#40;</span>myMap.<span style="color: #000000;">contains</span><span style="color: #F78811;">&#40;</span>kv.<span style="color: #000080;">_</span>1<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
		  myMap<span style="color: #F78811;">&#40;</span>kv.<span style="color: #000080;">_</span>1<span style="color: #F78811;">&#41;</span> + kv.<span style="color: #000080;">_</span>2
	  <span style="color: #F78811;">&#125;</span> <span style="color: #0000ff; font-weight: bold;">else</span> <span style="color: #F78811;">&#123;</span>
		  <span style="color: #0000ff; font-weight: bold;">new</span> HashSet<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> + kv.<span style="color: #000080;">_</span>2	     	   
	  <span style="color: #F78811;">&#125;</span>
&nbsp;
	  <span style="color: #0000ff; font-weight: bold;">new</span> MultiMap<span style="color: #F78811;">&#91;</span>A, B<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span>myMap + <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span>kv.<span style="color: #000080;">_</span>1, set<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>
	<span style="color: #F78811;">&#125;</span>
&nbsp;
	<span style="color: #0000ff; font-weight: bold;">def</span> -<span style="color: #F78811;">&#40;</span>kv<span style="color: #000080;">:</span> Tuple2<span style="color: #F78811;">&#91;</span>A, B<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> MultiMap<span style="color: #F78811;">&#91;</span>A, B<span style="color: #F78811;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #F78811;">&#123;</span>
	  <span style="color: #0000ff; font-weight: bold;">if</span> <span style="color: #F78811;">&#40;</span><span style="color: #000080;">!</span>myMap.<span style="color: #000000;">contains</span><span style="color: #F78811;">&#40;</span>kv.<span style="color: #000080;">_</span>1<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
	    <span style="color: #0000ff; font-weight: bold;">throw</span> <span style="color: #0000ff; font-weight: bold;">new</span> Exception<span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;No such key&quot;</span><span style="color: #F78811;">&#41;</span>
	  <span style="color: #F78811;">&#125;</span>
	  <span style="color: #0000ff; font-weight: bold;">val</span> set <span style="color: #000080;">=</span> myMap<span style="color: #F78811;">&#40;</span>kv.<span style="color: #000080;">_</span>1<span style="color: #F78811;">&#41;</span> - kv.<span style="color: #000080;">_</span>2
	  <span style="color: #0000ff; font-weight: bold;">if</span> <span style="color: #F78811;">&#40;</span>set.<span style="color: #000000;">isEmpty</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
	    <span style="color: #0000ff; font-weight: bold;">new</span> MultiMap<span style="color: #F78811;">&#91;</span>A, B<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span>myMap - kv.<span style="color: #000080;">_</span>1<span style="color: #F78811;">&#41;</span>
	  <span style="color: #F78811;">&#125;</span> <span style="color: #0000ff; font-weight: bold;">else</span> <span style="color: #F78811;">&#123;</span>
		  <span style="color: #0000ff; font-weight: bold;">new</span> MultiMap<span style="color: #F78811;">&#91;</span>A, B<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span>myMap + <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span>kv.<span style="color: #000080;">_</span>1, set<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>
	  <span style="color: #F78811;">&#125;</span>
	<span style="color: #F78811;">&#125;</span>
&nbsp;
	<span style="color: #0000ff; font-weight: bold;">def</span> entryExists<span style="color: #F78811;">&#40;</span>kv<span style="color: #000080;">:</span> Tuple2<span style="color: #F78811;">&#91;</span>A, B<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> Boolean <span style="color: #000080;">=</span> <span style="color: #F78811;">&#123;</span>
	  <span style="color: #0000ff; font-weight: bold;">if</span> <span style="color: #F78811;">&#40;</span><span style="color: #000080;">!</span>myMap.<span style="color: #000000;">contains</span><span style="color: #F78811;">&#40;</span>kv.<span style="color: #000080;">_</span>1<span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
	    <span style="color: #0000ff; font-weight: bold;">false</span>
	  <span style="color: #F78811;">&#125;</span> <span style="color: #0000ff; font-weight: bold;">else</span> <span style="color: #F78811;">&#123;</span>
	    myMap<span style="color: #F78811;">&#40;</span>kv.<span style="color: #000080;">_</span>1<span style="color: #F78811;">&#41;</span>.<span style="color: #000000;">contains</span><span style="color: #F78811;">&#40;</span>kv.<span style="color: #000080;">_</span>2<span style="color: #F78811;">&#41;</span>
	  <span style="color: #F78811;">&#125;</span>
	<span style="color: #F78811;">&#125;</span>
&nbsp;
    <span style="color: #0000ff; font-weight: bold;">def</span> keys <span style="color: #000080;">=</span> myMap.<span style="color: #000000;">keys</span>
&nbsp;
     <span style="color: #0000ff; font-weight: bold;">def</span> values<span style="color: #000080;">:</span> Iterator<span style="color: #F78811;">&#91;</span>Set<span style="color: #F78811;">&#91;</span>B<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#93;</span> <span style="color: #000080;">=</span> myMap.<span style="color: #000000;">values</span>
&nbsp;
    <span style="color: #0000ff; font-weight: bold;">def</span> getOrElse<span style="color: #F78811;">&#40;</span>key<span style="color: #000080;">:</span> A, elval<span style="color: #000080;">:</span> Collection<span style="color: #F78811;">&#91;</span>B<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#41;</span><span style="color: #000080;">:</span> Collection<span style="color: #F78811;">&#91;</span>B<span style="color: #F78811;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #F78811;">&#123;</span>      
      myMap.<span style="color: #000000;">getOrElse</span><span style="color: #F78811;">&#40;</span>key, elval<span style="color: #F78811;">&#41;</span>
    <span style="color: #F78811;">&#125;</span>
&nbsp;
    <span style="color: #0000ff; font-weight: bold;">def</span> apply<span style="color: #F78811;">&#40;</span>key<span style="color: #000080;">:</span> A<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> myMap<span style="color: #F78811;">&#40;</span>key<span style="color: #F78811;">&#41;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #F78811;">&#125;</span></pre></div></div>

<p>Usage:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;">&nbsp;
   <span style="color: #0000ff; font-weight: bold;">var</span> theMultiMap <span style="color: #000080;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> MultiMap<span style="color: #F78811;">&#91;</span>String, Int<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span>
&nbsp;
   theMultiMap +<span style="color: #000080;">=</span> <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;george&quot;</span>, <span style="color: #F78811;">1</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>
   theMultiMap +<span style="color: #000080;">=</span> <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;george&quot;</span>, <span style="color: #F78811;">3</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>
   theMultiMap +<span style="color: #000080;">=</span> <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;bob&quot;</span>, <span style="color: #F78811;">2</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>
   theMultiMap -<span style="color: #000080;">=</span> <span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;george&quot;</span>, <span style="color: #F78811;">1</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/an-immutable-multimap-for-scala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A wikipedia of algorithms</title>
		<link>http://www.monomorphic.org/wordpress/a-wikipedia-of-algorithms/</link>
		<comments>http://www.monomorphic.org/wordpress/a-wikipedia-of-algorithms/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 01:21:52 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Software development]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[reuse]]></category>
		<category><![CDATA[social media]]></category>
		<category><![CDATA[software engineering]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=429</guid>
		<description><![CDATA[Here&#8217;s something I&#8217;ve wanted to see for some time, but probably don&#8217;t have time to work on myself. It would be nice if there was a wikipedia-like web site for code and algorithms. Just the common ones to start with, but perhaps more specialised ones over time. Of course the algorithms should be available in [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s something I&#8217;ve wanted to see for some time, but probably don&#8217;t have time to work on myself.</p>
<p>It would be nice if there was a wikipedia-like web site for code and algorithms. Just the common ones to start with, but perhaps more specialised ones over time. Of course the algorithms should be available in lots of different languages. This would in fact be one of the main points, so that people could compare good style and see how things should be done for different languages. In addition, there should be an in-browser editor, just like on Wikipedia (but perhaps with syntax highlighting) so people can make changes easily.</p>
<p>Furthermore, there should be unit tests for every algorithm, and these should be user-editable in the same way as the main code. In an ideal world, the web site would automatically run the unit tests every time there&#8217;s a change to some algorithm and check in a new version of the code to a versioned repository. People could then trust with reasonable confidence that the code is valid and safe. However, if the system were to be as open as Wikipedia is, such a system wouldn&#8217;t work, since users could write unit tests with malicious code. So I suspect volunteers would have to download, inspect, and run the unit tests regularly, and perhaps there would be a meta-moderation system of some kind, allowing senior members to promote changes to the official repository. In the meantime, everybody should be allowed to see and edit changes on the wiki immediately, but they would be marked as &#8220;untested&#8221; or &#8220;unsafe&#8221;.</p>
<p>User interface would be very important since this kind of site needs to be fun and easy to use regularly.</p>
<p>Has this kind of project already been carried out by someone? I can find some things by googling. <a href="http://www.thecodewiki.com/">The Code Wiki</a> appears to once have been a wikipedia of code, but it seems defunct, C# only, and now they&#8217;re selling a book with the contents of the site! <a href="http://www.algorithm-code.com/">Algorithm Wiki</a> has many algorithms in different languages, but the user interface is awkward and littered with obstructive advertising, the code is hard to browse, and it doesn&#8217;t make for a usable quick reference. They seem to have gotten off to a good start though. Any others?</p>
<p>Edit: <a href="http://rosettacode.org/wiki/Main_Page">Rosetta Code</a> seems to be the most mature and useful such site out there today.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/a-wikipedia-of-algorithms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
