<?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 engineering</title>
	<atom:link href="http://www.monomorphic.org/wordpress/tag/software-engineering/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>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>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>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>
		<item>
		<title>Scala and actors</title>
		<link>http://www.monomorphic.org/wordpress/scala-and-actors/</link>
		<comments>http://www.monomorphic.org/wordpress/scala-and-actors/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 13:15:03 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Software development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=298</guid>
		<description><![CDATA[Programming with actors was a new concept to me until I tried it out in Scala. It&#8217;s appears to be one of Scala&#8217;s most celebrated features, judging by the official blurb. Actors was a daunting word at first but it really ends up being a very simple concept. Actors are a programming model for concurrent [...]]]></description>
			<content:encoded><![CDATA[<p>Programming with <em>actors</em> was a new concept to me until I tried it out in Scala. It&#8217;s appears to be one of Scala&#8217;s most celebrated features, judging by the official blurb. Actors was a daunting word at first but it really ends up being a very simple concept.</p>
<p>Actors are a programming model for concurrent programming. With conventional mutex/monitor based programming in Java, say, programmers hold and release locks (the <code>synchronized</code> keyword) to achieve safe concurrency. Condition variables are used for thread communication (the <code>wait</code> and <code>notify</code> family of functions on java.lang.Object). Communication is synchronous: a typical case would be that you change some condition, invoke <code>notifyAll</code> to wake up threads waiting on that condition, and then they can take over the relevant lock and proceed to do some processing.</p>
<p>An actor is a unit of execution with an asynchronous message queue. Actors can receive messages from other actors or send messages to other actors at any time, however, the messages wait in the receiving actor&#8217;s &#8220;mailbox&#8221; until the actor has time to receive it.</p>
<p>As a simple example, let&#8217;s develop a program that converts text files to upper case using actors. The program will have an &#8220;Input&#8221; actor, an &#8220;Output&#8221; actor, and a number of &#8220;UpperCase&#8221; actors that do the processing. First the Input actor:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">import</span> scala.<span style="color: #000000;">actors</span>.<span style="color: #000080;">_</span>
<span style="color: #0000ff; font-weight: bold;">import</span> java.<span style="color: #000000;">io</span>.<span style="color: #000080;">_</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">class</span> Input<span style="color: #F78811;">&#40;</span>in<span style="color: #000080;">:</span> BufferedReader<span style="color: #F78811;">&#41;</span> <span style="color: #0000ff; font-weight: bold;">extends</span> Actor <span style="color: #F78811;">&#123;</span>
	<span style="color: #0000ff; font-weight: bold;">def</span> act<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
	  <span style="color: #0000ff; font-weight: bold;">while</span><span style="color: #F78811;">&#40;</span><span style="color: #0000ff; font-weight: bold;">true</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
	    receive <span style="color: #F78811;">&#123;</span>
	      <span style="color: #0000ff; font-weight: bold;">case</span> Next <span style="color: #000080;">=&amp;</span>gt<span style="color: #000080;">;</span> <span style="color: #F78811;">&#123;</span> sender <span style="color: #000080;">!</span> Line<span style="color: #F78811;">&#40;</span>in.<span style="color: #000000;">readLine</span><span style="color: #F78811;">&#40;</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>
	  <span style="color: #F78811;">&#125;</span>
	<span style="color: #F78811;">&#125;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>

<p>It&#8217;s worth noting that the Actor system is implemented completely in the libraries, outside of the core language. Actors are not first class constructs, but sometimes look as if they were. The <code>act</code> method is where actors begin their execution. The receive method causes them to block and wait for a message, which we may pattern match on. The sender variable corresponds to whoever sent the last message received, and the &#8216;!&#8217; operator sends a message. So whenever this actor receives the <code>Next</code> message, it will respond with the next line from a buffered reader.</p>
<p>Then, the UpperCase actor:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">import</span> scala.<span style="color: #000000;">actors</span>.<span style="color: #000080;">_</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">case</span> <span style="color: #0000ff; font-weight: bold;">class</span> Next
<span style="color: #0000ff; font-weight: bold;">case</span> <span style="color: #0000ff; font-weight: bold;">class</span> Line<span style="color: #F78811;">&#40;</span>x<span style="color: #000080;">:</span> String<span style="color: #F78811;">&#41;</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">class</span> UpperCase<span style="color: #F78811;">&#40;</span>input<span style="color: #000080;">:</span> Actor, out<span style="color: #000080;">:</span> Actor<span style="color: #F78811;">&#41;</span> <span style="color: #0000ff; font-weight: bold;">extends</span> Actor <span style="color: #F78811;">&#123;</span>
	<span style="color: #0000ff; font-weight: bold;">def</span> act<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
		<span style="color: #0000ff; font-weight: bold;">while</span><span style="color: #F78811;">&#40;</span><span style="color: #0000ff; font-weight: bold;">true</span><span style="color: #F78811;">&#41;</span>
		<span style="color: #F78811;">&#123;</span>
			input <span style="color: #000080;">!</span> Next
			receive <span style="color: #F78811;">&#123;</span>
			<span style="color: #0000ff; font-weight: bold;">case</span> Line<span style="color: #F78811;">&#40;</span>x<span style="color: #000080;">:</span>String<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&amp;</span>gt<span style="color: #000080;">;</span> <span style="color: #F78811;">&#123;</span> out <span style="color: #000080;">!</span> x.<span style="color: #000000;">toUpperCase</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#125;</span>
			<span style="color: #F78811;">&#125;</span>
		<span style="color: #F78811;">&#125;</span>
	<span style="color: #F78811;">&#125;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>

<p>This actor is created with in- and output actors as its constructor parameters. It continually asks the input actor for a new line, converts it to upper case, and sends it to the output actor. Also note the <em>case classes</em> here, which are for pattern matching only. They are a bit like algebraic data types in Haskell.</p>
<p>Finally, the Output actor:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">import</span> scala.<span style="color: #000000;">actors</span>.<span style="color: #000080;">_</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">class</span> Output <span style="color: #0000ff; font-weight: bold;">extends</span> Actor <span style="color: #F78811;">&#123;</span>
	<span style="color: #0000ff; font-weight: bold;">def</span> act<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span>
		<span style="color: #0000ff; font-weight: bold;">while</span><span style="color: #F78811;">&#40;</span><span style="color: #0000ff; font-weight: bold;">true</span><span style="color: #F78811;">&#41;</span>
		<span style="color: #F78811;">&#123;</span>
			receive <span style="color: #F78811;">&#123;</span>
			<span style="color: #0000ff; font-weight: bold;">case</span> x<span style="color: #000080;">:</span>String <span style="color: #000080;">=&amp;</span>gt<span style="color: #000080;">;</span> <span style="color: #F78811;">&#123;</span> println<span style="color: #F78811;">&#40;</span>x<span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#125;</span>
			<span style="color: #F78811;">&#125;</span>
		<span style="color: #F78811;">&#125;</span>
	<span style="color: #F78811;">&#125;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>

<p>And then we have to tie it all together:</p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">import</span> java.<span style="color: #000000;">io</span>.<span style="color: #000080;">_</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">object</span> Demonstration <span style="color: #F78811;">&#123;</span>
&nbsp;
  <span style="color: #0000ff; font-weight: bold;">val</span> reader <span style="color: #000080;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> BufferedReader<span style="color: #F78811;">&#40;</span><span style="color: #0000ff; font-weight: bold;">new</span> InputStreamReader<span style="color: #F78811;">&#40;</span>System.<span style="color: #000000;">in</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span>
&nbsp;
  <span style="color: #0000ff; font-weight: bold;">def</span> main<span style="color: #F78811;">&#40;</span>args<span style="color: #000080;">:</span> Array<span style="color: #F78811;">&#91;</span>String<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;">val</span> in <span style="color: #000080;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> Input<span style="color: #F78811;">&#40;</span>reader<span style="color: #F78811;">&#41;</span>
    in.<span style="color: #000000;">start</span>
&nbsp;
    <span style="color: #0000ff; font-weight: bold;">val</span> out <span style="color: #000080;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> Output<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span>
    out.<span style="color: #000000;">start</span>
&nbsp;
    1.<span style="color: #000000;">to</span><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">5</span><span style="color: #F78811;">&#41;</span>.<span style="color: #000000;">foreach</span><span style="color: #F78811;">&#40;</span>x <span style="color: #000080;">=&amp;</span>gt<span style="color: #000080;">;</span> <span style="color: #F78811;">&#123;</span>
      <span style="color: #0000ff; font-weight: bold;">val</span> tr <span style="color: #000080;">=</span> <span style="color: #0000ff; font-weight: bold;">new</span> UpperCase<span style="color: #F78811;">&#40;</span>in, out<span style="color: #F78811;">&#41;</span>
      tr.<span style="color: #000000;">start</span>
    <span style="color: #F78811;">&#125;</span><span style="color: #F78811;">&#41;</span>
  <span style="color: #F78811;">&#125;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>

<p>Here I abuse the foreach notation slightly to create 5 parallel text processors. Each actor runs on its own thread (though there are ways to prevent this if one wants very large numbers of actors). Now of course, the lines will probably be output in the wrong order. Another obvious shortcoming is that there is no clean shutdown protocol that terminates all the actors when the input stream is fully read. Solving these problems is outside of the scope of this article.</p>
<p>Some other interesting resources on actors: <a href="http://www.scala-lang.org/node/242">the official tutorial</a>, <a href="http://lamp.epfl.ch/~phaller/actors.html">the papers</a> (slightly more academic but accessible to the <em>monomorphic</em> reader, I imagine). Debasish highlights how actors can be used to get <a href="http://debasishg.blogspot.com/2006/11/threadless-concurrency-on-jvm-aka-scala.html">threadless concurrency</a>, Erlang-style.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/scala-and-actors/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Searching and creating</title>
		<link>http://www.monomorphic.org/wordpress/searching-and-creating/</link>
		<comments>http://www.monomorphic.org/wordpress/searching-and-creating/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 11:17:34 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[intellectual property]]></category>
		<category><![CDATA[metaphors]]></category>
		<category><![CDATA[programmer psychology]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=195</guid>
		<description><![CDATA[We distinguish between inventions and discoveries. You can own the intellectual property rights to an invention, but not to a discovery (you can&#8217;t patent the discovery of mercury or selenium, for instance). Inventions are meant to be created, and discoveries are meant to be sought for.Â But sometimes, the line between invention and discovery is blurry. [...]]]></description>
			<content:encoded><![CDATA[<p>We distinguish between inventions and discoveries. You can own the intellectual property rights to an invention, but not to a discovery (you can&#8217;t patent the discovery of mercury or selenium, for instance). Inventions are meant to be <em>created</em>, and discoveries are meant to be<em> sought for</em>.Â But sometimes, the line between invention and discovery is blurry.</p>
<p>We cannot own the rights to mathematical structures or theorems, since they follow directly from axioms. Anyone with a mathematical education would come to the same results within the same axiomatic system. The creation of a mathematical theorem can be said to be a search process, hence the term &#8220;discovery&#8221; and not &#8220;invention&#8221;.</p>
<p>We can own the rights to music and paintings, since these are considered to be inventions. But isn&#8217;t the process that leads to a painting or work of music being created also a search process? Doesn&#8217;t the artist search for possible combinations that work together, in a &#8212; albeit very large and continuous &#8212; search space? But this is considered to be creation/synthesis rather than search.</p>
<p>The software developer is, at least sometimes, somewhere in between. A vision of a user interface that interacts with end users in a certain way can perhaps be said to come from the same large, continuous space as music and paintings come from. But given the constraints imposed by such a vision, and by the platform on which the system is to be built, the available libraries, the languages, etc, I would say that the construction of much of desktop/consumer software is a search problem. We look for combinations of components that fit the constraints, and when we have decided on this combination, we must connect the pieces together correctly. The space of possible solutions here, at least for someone who follows good design principles, is in essence much smaller than the music/painting search space. Of course there are considerations of taste and style, but they are completely irrelevant to the compiled product. They are a programmer aid.</p>
<p><a href="http://www.kurzweilai.net/brain/frame.html?startThought=Artificial%20Intelligence%20(AI)">Artificial intelligence</a> problems are defined as search problems. But what are search problems, and what are &#8220;creational&#8221; problems, precisely? Is it merely a question of the size of the search/design space?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/searching-and-creating/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The ego fallacy</title>
		<link>http://www.monomorphic.org/wordpress/the-ego-fallacy/</link>
		<comments>http://www.monomorphic.org/wordpress/the-ego-fallacy/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 08:41:44 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Software development]]></category>
		<category><![CDATA[fallacies]]></category>
		<category><![CDATA[programmer psychology]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=130</guid>
		<description><![CDATA[A senior manager at a company I used to work at once said that (making) software is a very social activity. I didn&#8217;t have much experience, and was very surprised at the time, since I had never thought about the human aspect of software development. But of course this aspect is extremely important. For example, [...]]]></description>
			<content:encoded><![CDATA[<p>A senior manager at a company I used to work at once said that (making) software is a very social activity. I didn&#8217;t have much experience, and was very surprised at the time, since I had never thought about the human aspect of software development. But of course this aspect is extremely important. For example, in any setting with more than one programmer working on a project, the need for well functioning communication is huge, as much as in any other job I suspect. Projects often fail due to a lack of communication.</p>
<p>Another human side to software development is that some developers, this author included, easily start seeing the code they write as their own intellectual turf. If somebody challenges the developer&#8217;s practices or code, offering a better solution, it will be met with massive resistance. Partly out of laziness, but partly, I think, out of a desire to protect their territory and their legacy.</p>
<p>I do this myself more often than I would like. And it leads to bad results because it creates obstacles to communication and means that team members pull in different directions. Thus, somehow the incentives are wrong. If everybody&#8217;s goal were to allow the team to deliver a good product quickly, this would not happen. Why is it that your goal after some time with a project sometimes becomes to defend what you have created? Why do we identify with the code we wrote, and not with the bigger project?</p>
<p>This doesn&#8217;t mean that looking to your own interests or to your ego is a bad thing &#8211; rather that it&#8217;s easy to be shortsighted about what is in your best interests.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/the-ego-fallacy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Software roundup</title>
		<link>http://www.monomorphic.org/wordpress/software-roundup/</link>
		<comments>http://www.monomorphic.org/wordpress/software-roundup/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 16:36:55 +0000</pubDate>
		<dc:creator>johan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[software engineering]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.monomorphic.org/wordpress/?p=116</guid>
		<description><![CDATA[I enjoy experimenting with new software Â just to see what people come up with. There&#8217;s just so much unknown software to discover. I suspect most people find something they like and then stick with it until it doesn&#8217;t work anymore, but there&#8217;s something to be said for proactively replacing your software and searching for better [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">I enjoy experimenting with new software Â just to see what people come up with. There&#8217;s just so much unknown software to discover. I suspect most people find something they like and then stick with it until it doesn&#8217;t work anymore, but there&#8217;s something to be said for proactively replacing your software and searching for better things. Here are some things I&#8217;ve taken a liking to recently.</p>
<p><strong>New iPhone OS</strong>: Apple released version 3.0 a few days ago. It&#8217;s been all positive so far. I get spotlight search for the phone, the keyboard feels more responsive, it finally has copy and paste, Youtube appears to have higher quality, and a slew of other features. (Also MMS which I don&#8217;t really need in Japan).</p>
<p><strong><a href="http://code.google.com/webtoolkit/">GWT</a></strong><strong>: </strong>I started playing with the Google Web Toolkit just for fun. For those who don&#8217;t know, it&#8217;s an API for developing AJAX based web applications using pure Java, which is then compiled to client side Javascript and a Java servlet. It turns out I can be extremely productive with it &#8211; I found that it lets me develop fairly advanced web applications using my existing skills. There&#8217;s a very high reward/effort ratio that makes me excited. It feels like I don&#8217;t need to learn Ruby on Rails properly when I have GWT given that I&#8217;m very comfortable developing in Java.. but we&#8217;ll see.</p>
<p><strong><a href="http://fluidapp.com/">Fluid.app</a>: </strong>A web browser enhancement for the Mac that allows you to create separate &#8220;applications&#8221; from web sites you visit often. This means they will show up in the task bar and application switcher, have their own icon, and occupy less screen space. It sounds simple, but it&#8217;s a revelation. (And if you&#8217;re like me, you tend to have 15+ tabs open in your web browsers constantly, which is a poor way of managing windows).</p>
<p><img style="display: block; margin-left: auto; margin-right: auto; border: 0px initial initial;" title="Chandler on the Mac desktop" src="http://chandlerproject.org/pub/Projects/ProductTour/mac_triagelist.png" alt="" width="400" height="260" /></p>
<p><strong><a href="http://chandlerproject.org/">Chandler</a>: </strong>Like many others, I found out about this little calendar and note manager by reading Scott Rosenberg&#8217;s <em><a href="http://www.dreamingincode.com/">Dreaming in Code</a> , </em>which chronicled the misfortunes of an open source startup project. It went 1.0 last year after many years of development. The impression you get from the book is that the developers had a lot of bad luck despite setting out with the right ambitions. This is now an old debate, but the tool is actually usable today &#8211; I&#8217;ve been using it every day to manage myself for 3 months. Aside from slight bugs, it feels very smart sometimes, thanks to its unique user interface and features.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monomorphic.org/wordpress/software-roundup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
