<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>daniel's devel blog</title>
	<atom:link href="http://danielkaes.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://danielkaes.wordpress.com</link>
	<description>Just another developer blog</description>
	<lastBuildDate>Mon, 17 Jan 2011 21:28:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='danielkaes.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>daniel's devel blog</title>
		<link>http://danielkaes.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://danielkaes.wordpress.com/osd.xml" title="daniel&#039;s devel blog" />
	<atom:link rel='hub' href='http://danielkaes.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Simple Multi-Threaded Application in Haskell</title>
		<link>http://danielkaes.wordpress.com/2010/07/27/multithreaded-haskell/</link>
		<comments>http://danielkaes.wordpress.com/2010/07/27/multithreaded-haskell/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 21:42:01 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[code snippets]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[multithreading]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=247</guid>
		<description><![CDATA[Haskell has a powerful concurrency library which is surprisingly easy to use. The Control.Concurrent library is shipped with the standard installation of ghc and provides everything needed to get started. As a small test I want to write a programme which reads numbers from stdin, spawns a new process to calculate the Fibonacci number for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=247&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Haskell has a powerful concurrency library which is surprisingly easy to use. The <a href="http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Concurrent.html">Control.Concurrent</a> library is shipped with the standard installation of ghc and provides everything needed to get started.</p>
<p>As a small test I want to write a programme which reads numbers from stdin, spawns a new process to calculate the Fibonacci number for each input on a different CPU and prints the result to stdout.</p>
<p>First we need a function which is called when spawning a new process, which should calculate the result and print it to the console. In my case this is a simple IO Monad, which gets a MVar as it&#8217;s first argument. The function will wait for input from the MVar and then call the Fibonacci function.</p>
<p>This <a href="http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Concurrent-MVar.html">MVar</a> can be thought of as a synchronised box where a thread can store a value and another thread can read from it. So MVars are just the poor men&#8217;s message channel which can hold one value at the time only. Of course there are also real channels in Haskell which act like the message queues in Scala or Erlang, see Control.Concurrent.Chan for more informations.</p>
<pre class="brush: plain;">
printResult mvar =  do
	value &lt;- takeMVar mvar
	print $ &quot;fib(&quot; ++ show value ++ &quot;)=&quot; ++ show (fib value)

fib 0 = 0
fib 1 = 1
fib n =  fib (n - 1) + fib (n - 2)
</pre>
<p>Now we need to read the input from stdin, create a MVar object and invoke the printResult function. The cool thing about Haskell is the forkIO function which is really convenient. It takes an arbitrary IO expr and invokes it in a new thread:</p>
<pre class="brush: plain;">
import Control.Monad -- needed for &quot;forever&quot;
import System.Exit     -- needed for exitSuccess

main = forever $ do
	line &lt;- getLine
	when (line == &quot;quit&quot;) exitSuccess
	mvar &lt;- newEmptyMVar
	forkIO $ printResult mvar
	putMVar mvar (read line :: Integer)
</pre>
<p>Now we have to compile our programme with the &#8220;-threaded&#8221; flag:</p>
<pre class="brush: bash;">ghc -threaded fib.hs -o fib</pre>
<p>The RTS allows us now to define the number of processors the application runs on with the -N<em>num</em> flag. If I want to use three processors for parallelisation I can run the programme simply with: </p>
<pre class="brush: bash;">./fib +RTS -N4</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danielkaes.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danielkaes.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danielkaes.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danielkaes.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danielkaes.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danielkaes.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danielkaes.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danielkaes.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danielkaes.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danielkaes.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danielkaes.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danielkaes.wordpress.com/247/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=247&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/07/27/multithreaded-haskell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Writing A Synthesizer With Brainfuck</title>
		<link>http://danielkaes.wordpress.com/2010/06/02/writing-a-synthesizer-with-brainfuck/</link>
		<comments>http://danielkaes.wordpress.com/2010/06/02/writing-a-synthesizer-with-brainfuck/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 20:57:57 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[review]]></category>
		<category><![CDATA[brainfuck]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=244</guid>
		<description><![CDATA[Brainfuck is a small esoteric programming language which comes with just eight commands and Turing completeness (given enough time or memory). And that is just enough to write a small synthesizer in it. Some people have definitely too much time ;-)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=244&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Brainfuck">Brainfuck</a> is a small esoteric programming language which comes with just eight commands and Turing completeness (given enough time or memory). And that is just enough <a href="http://probablyprogramming.com/2009/08/06/a-brainfuck-synthesizer/">to write a small synthesizer in it</a>. Some people have definitely too much time ;-)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/244/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danielkaes.wordpress.com/244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danielkaes.wordpress.com/244/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danielkaes.wordpress.com/244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danielkaes.wordpress.com/244/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danielkaes.wordpress.com/244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danielkaes.wordpress.com/244/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danielkaes.wordpress.com/244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danielkaes.wordpress.com/244/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danielkaes.wordpress.com/244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danielkaes.wordpress.com/244/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danielkaes.wordpress.com/244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danielkaes.wordpress.com/244/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=244&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/06/02/writing-a-synthesizer-with-brainfuck/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Easter Eggs in Open Source Software</title>
		<link>http://danielkaes.wordpress.com/2010/03/16/easter-eggs-in-open-source-software/</link>
		<comments>http://danielkaes.wordpress.com/2010/03/16/easter-eggs-in-open-source-software/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 11:52:49 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=240</guid>
		<description><![CDATA[Some programmers definitely have to much time, see this link to an arstechnica article: Cracking open five of the best open source easter eggs<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=240&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Some programmers definitely have to much time, see this link to an arstechnica article:</p>
<p><a href="http://arstechnica.com/open-source/news/2010/03/cracking-open-five-of-the-best-open-source-easter-eggs.ars">Cracking open five of the best open source easter eggs</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danielkaes.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danielkaes.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danielkaes.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danielkaes.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danielkaes.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danielkaes.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danielkaes.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danielkaes.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danielkaes.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danielkaes.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danielkaes.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danielkaes.wordpress.com/240/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=240&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/03/16/easter-eggs-in-open-source-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Reinventing Human-Computer Interaction</title>
		<link>http://danielkaes.wordpress.com/2010/02/19/reinventing-human-computer-interaction/</link>
		<comments>http://danielkaes.wordpress.com/2010/02/19/reinventing-human-computer-interaction/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 19:29:07 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[review]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=233</guid>
		<description><![CDATA[Many of you probably remember &#8220;Minority Report&#8221;, a mediocre science fiction film inspired by a short story of good old Philip K. Dick. The only thing I really remember well about this movie is the huge multi-touch computer used by the police force (or something). Although such sci-fi devices look great they are a total [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=233&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Many of you probably remember &#8220;Minority Report&#8221;, a mediocre science fiction film inspired by a short story of good old Philip K. Dick. The only thing I really remember well about this movie is the huge multi-touch computer used by the police force (or something). Although such sci-fi devices look great they are a total nightmare for every day use. Just imagine you have to lift your arms every time you try to switch to another tab page of your browser. That is not really a solution. But how can we use awesome looking multi-touch devices in combination with our other hardware? Here is a small video which came up with some cool and fresh ideas:</p>
<p><a href='http://vimeo.com/6712657'>reinventing desktop human-computer interaction: <strong>10/GUI</strong></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danielkaes.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danielkaes.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danielkaes.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danielkaes.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danielkaes.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danielkaes.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danielkaes.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danielkaes.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danielkaes.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danielkaes.wordpress.com/233/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danielkaes.wordpress.com/233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danielkaes.wordpress.com/233/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=233&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/02/19/reinventing-human-computer-interaction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Java &amp; Multicore</title>
		<link>http://danielkaes.wordpress.com/2010/02/15/java-multicore/</link>
		<comments>http://danielkaes.wordpress.com/2010/02/15/java-multicore/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 21:54:47 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[multithreading]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=220</guid>
		<description><![CDATA[Recently I needed to run some very CPU intensive calculations in Java. In order to harvest the full power of my multicore machine I took a look at Java&#8217;s concurrent package. I never used this package before. Either I had some convenient third party library functions at my hand which successfully were able to hide [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=220&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I needed to run some very CPU intensive calculations in Java. In order to harvest the full power of my multicore machine I took a look at Java&#8217;s concurrent package. I never used this package before. Either I had some convenient third party library functions at my hand which successfully were able to hide all the multithreading stuff from me, sometimes I struggled with Thread, Runnable and synchronized statements or &#8230; I just used another language :P</p>
<p>So here are my results from a short trip into the adventurous realm of multicore programming in Java. To make things a little bit simpler in this post I will demonstrate to run several functions calculating a high Fibonacci number instead of using a more complicated real world example. The calculations will be distributed via a thread pool and all classes used in this example belong to the Java standard library, so there won&#8217;t be a need to install any extra packages.</p>
<p><span id="more-220"></span></p>
<p>The first thing we will need is a class implementing the <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Callable.html">java.util.concurrent.Callable</a> interface in which <em>fib(int n)</em> will be a static function returning an integer:</p>
<pre class="brush: java;">
class FibTask implements Callable&lt;Integer&gt; {
  private int n;
  public FibTask(int n) {
    this.n = n;
  }

  @Override
  public Integer call() throws Exception {
    return fib(this.n);
  }
}
</pre>
<p>Before we start to build our thread pool we can retrieve the amount of CPUs/cores of our system from the Java runtime:</p>
<pre class="brush: java;">
int cpus = Runtime.getRuntime().availableProcessors();
</pre>
<p>OK, so the next step is building a thread pool. If you are looking for a pool with specific parameters and behaviour you can build one by using the <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html">ThreadPoolExecutor</a> class. But luckily the concurrent package already offers a nice short cut to create a pool with a fixed size:</p>
<pre class="brush: java;">
ExecutorService pool = Executors.newFixedThreadPool(cpus);
</pre>
<p>To execute functions in the pool you can either use it&#8217;s <em>execute</em> method or even more convenient: <em>invokeAll</em>. This method takes a list of tasks which have to implement the <em>Callable</em> interface executes them and returns a list of <em>Future</em> objects which hold the results of the <em>Callable</em> objects. The cool thing about <em>invokeAll</em> is it makes sure all tasks are executed before returning anything. So for all elements in the returned list <em>Future.isDone()</em> will be true:</p>
<pre class="brush: java;">
List&lt;FibTask&gt; tasks = new ArrayList&lt;FibTask&gt;();
for (int i = 0; i &lt; cpus; i++) {
  tasks.add(new FibTask(45));
}
List&lt;Future&lt;Integer&gt;&gt; results = pool.invokeAll(tasks);
</pre>
<p>The results list holds the <em>Future</em> values now. If the pool is no longer needed, it should be closed properly by calling it&#8217;s <em>shutdown()</em> method. Before we can retrieve and print out the results we need to check for any errors occurred during the calculation:</p>
<pre class="brush: java;">
for (Future&lt;Integer&gt; result : results) {
  if (result.isCancelled()) {
    System.err.println(&quot;Life is a bitch&quot;);
  } else {
    try {
      System.out.println(&quot;result: &quot; + result.get());
    } catch (ExecutionException e) {
      System.out.println(e.getCause());
    }
  }
}
</pre>
<p>And this is all you need to run your code on multiple cores. Couldn&#8217;t be easier!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danielkaes.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danielkaes.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danielkaes.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danielkaes.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danielkaes.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danielkaes.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danielkaes.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danielkaes.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danielkaes.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danielkaes.wordpress.com/220/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danielkaes.wordpress.com/220/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danielkaes.wordpress.com/220/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=220&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/02/15/java-multicore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Struggling with HTML or How To Use Vertical And Horizontal Alignment In CSS</title>
		<link>http://danielkaes.wordpress.com/2010/01/28/struggling-with-html-or-how-to-use-vertical-and-horizontal-alignment-in-css/</link>
		<comments>http://danielkaes.wordpress.com/2010/01/28/struggling-with-html-or-how-to-use-vertical-and-horizontal-alignment-in-css/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 19:08:39 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[user interface]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=197</guid>
		<description><![CDATA[HTML wasn&#8217;t invented to write interactive, application-like web pages, it just offers a convenient way to create really simple documents containing links. Maybe that&#8217;s why programming web pages nowadays feels a little bit like writing a GUI in LaTeX. But maybe I am just complaining because I am not used to it &#8230; I am [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=197&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>HTML wasn&#8217;t invented to write interactive, application-like web pages, it just offers a convenient way to create really simple documents containing links. Maybe that&#8217;s why programming web pages nowadays feels a little bit like writing a GUI in LaTeX. But maybe I am just complaining because I am not used to it &#8230; I am a software developer, not a web designer.</p>
<p><span id="more-197"></span></p>
<p>Hopefully HTML5 will make everything a little bit simpler. Anyway &#8230; I just want to create a simple box containing text centred in the middle of it. This box will be used as a button on a website. So what I need is to specify vertical and horizontal alignments. The horizontal alignment attribute is called &#8220;text-align&#8221; which I guess is a relict from the good old days when people where used to browse hyper<strong>text</strong> documents. But to put the text in the centre of the box I had to shoot myself into the foot &#8230; twice!</p>
<p>First I needed to create a table with one row and one entry and then I was able to <del datetime="2010-01-28T18:26:39+00:00">use</del> misuse the table alignment options to centre the text vertically with an attribute called &#8220;vertical-align&#8221;. Why is there no &#8220;horizontal-align&#8221;? I don&#8217;t know. Why do I have to use a table? I don&#8217;t know. Don&#8217;t ask questions when writing CSS/HTML code. Never!</p>
<p>Here is the result:</p>
<pre class="brush: xml;">
&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;

&lt;div style=&quot;background-color:grey;width:10%;height:10%;position:absolute;top:10%;left:40%&quot;&gt;
  &lt;table style=&quot;width:100%;height:100%&quot;&gt;
    &lt;tr&gt;&lt;td style=&quot;vertical-align:middle;text-align:center&quot;&gt;
      This is a test
    &lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
&lt;/div&gt;

&lt;/body&gt;&lt;/html&gt;
</pre>
<p>Hooray! Please don&#8217;t ask me how long I needed to figure this out :/<br />
I wonder if there is a more elegant solution &#8230; </p>
<p>The style of the div element can be used to define the box, Mozilla&#8217;s Gecko engine supports some really cool CSS features like round edges, shadows and gradients (in the case of Firefox 3.6). But of course it won&#8217;t work with other browsers, it would be to easy if just everyone could write CSS/HTML code without studying computer science first. However, if you have Firefox just look and be amazed of my mighty text box:</p>
<div style="background-color:rgb(230,230,230);width:100px;height:100px;-moz-border-radius:3px;-moz-box-shadow:grey 5px 2px 2px;">
<table style="width:100%;height:100%;">
<tr>
<td style="vertical-align:middle;text-align:center;">
      This is a test
    </td>
</tr>
</table>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danielkaes.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danielkaes.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danielkaes.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danielkaes.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danielkaes.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danielkaes.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danielkaes.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danielkaes.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danielkaes.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danielkaes.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danielkaes.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danielkaes.wordpress.com/197/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=197&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/01/28/struggling-with-html-or-how-to-use-vertical-and-horizontal-alignment-in-css/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>What is the most popular programming language?</title>
		<link>http://danielkaes.wordpress.com/2010/01/26/what-is-the-most-popular-programming-language/</link>
		<comments>http://danielkaes.wordpress.com/2010/01/26/what-is-the-most-popular-programming-language/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 21:12:56 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=190</guid>
		<description><![CDATA[Well, the answer is Java &#8230; according to the TIOBE Programming Community Index. Other statistics also announce Java as the most popular one. C/C++ is following closely but is still behind Java. Surprisingly PHP is in many charts on the next place while Perl and Python are struggling for being the most popular scripting language. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=190&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, the answer is Java &#8230; according to the <a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html">TIOBE Programming Community Index</a>. <a href="http://www.devtopics.com/most-popular-programming-languages/">Other</a> <a href="http://langpop.com">statistics</a> also announce Java as the most popular one. C/C++ is following closely but is still behind Java. Surprisingly PHP is in many charts on the next place while Perl and Python are struggling for being the most popular scripting language. However Ruby seems to continue it&#8217;s rise to conquer the world, although slowing down in the last months.</p>
<p>Here is a chart showing the long term trend of programming languages:</p>
<p><img class="alignnone" title=" Long term trends" src="http://www.tiobe.com/content/paperinfo/tpci/images/tpci_trends.png" alt="from http://www.tiobe.com" width="640" height="480" /></p>
<p>OK, so Java and Perl are slowly dying out. But who is replacing these languages? On the one hand Python and Ruby finally seem to get the attention they deserve. C# is also becoming more popular and is growing in a very stable rate. I think the development of C is interesting. The rapidly growing mobile market may be one reason why this language is still that popular. In the time of web application, plugins and powerful CPUs I would expect C to lose &#8220;market share&#8221; among the programmer community, but that doesn&#8217;t seem to happen.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danielkaes.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danielkaes.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danielkaes.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danielkaes.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danielkaes.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danielkaes.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danielkaes.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danielkaes.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danielkaes.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danielkaes.wordpress.com/190/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danielkaes.wordpress.com/190/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danielkaes.wordpress.com/190/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=190&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2010/01/26/what-is-the-most-popular-programming-language/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>

		<media:content url="http://www.tiobe.com/content/paperinfo/tpci/images/tpci_trends.png" medium="image">
			<media:title type="html"> Long term trends</media:title>
		</media:content>
	</item>
		<item>
		<title>Java: Casting to Array</title>
		<link>http://danielkaes.wordpress.com/2009/12/10/java-casting-to-array/</link>
		<comments>http://danielkaes.wordpress.com/2009/12/10/java-casting-to-array/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 12:35:09 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[code snippets]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=183</guid>
		<description><![CDATA[OK, here&#8217;s the problem: I want to convert a List to an Integer[]: List&#60;Integer&#62; intList = ... Integer[] intArray = (Integer[]) intList.toArray(); throws: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer; This code doesn't work, because of type incompatibility. The method toArray() returns an Object[] array but I want to have an Integer[] array instead. The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=183&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>OK, here&#8217;s the problem:</p>
<p>I want to convert a List to an Integer[]:</p>
<pre class="brush: java;">
List&lt;Integer&gt; intList = ...
Integer[] intArray = (Integer[]) intList.toArray();
</pre>
<p>throws: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer;</p>
<p>This code doesn't work, because of type incompatibility. The method <em>toArray()</em> returns an Object[] array but I want to have an Integer[] array instead. The solution is a little bit ugly:</p>
<pre class="brush: java;">
List&lt;Integer&gt; intList = ...
Integer[] intArray =  intList.toArray(new Integer[0]);
</pre>
<p>It&#8217;s interesting, I never stumbled over this issue before, however I want <em>toArray()</em> to work as expected for generic types and already returning an integer array :/</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danielkaes.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danielkaes.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danielkaes.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danielkaes.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danielkaes.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danielkaes.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danielkaes.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danielkaes.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danielkaes.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danielkaes.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danielkaes.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danielkaes.wordpress.com/183/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=183&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2009/12/10/java-casting-to-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding a Pidgin Trayicon to DWM</title>
		<link>http://danielkaes.wordpress.com/2009/12/03/adding-a-pidgin-trayicon-to-dwm/</link>
		<comments>http://danielkaes.wordpress.com/2009/12/03/adding-a-pidgin-trayicon-to-dwm/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 23:26:32 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[dwm]]></category>
		<category><![CDATA[dynamic window manager]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=174</guid>
		<description><![CDATA[I am using dwm as a window manager for a long time. I hacked a few things into it which I felt were missing back then when I started to use dwm and got used to it so much that I hesitate to switch to awesome or even a newer version of dwm. Tiled window [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=174&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am using <a href="http://dwm.suckless.org/">dwm</a> as a window manager for a long time. I hacked a few things into it which I felt were missing back then when I started to use dwm and got used to it so much that I hesitate to switch to <a href="http://awesome.naquadah.org/">awesome</a> or even a newer version of dwm.</p>
<p>Tiled window managing is really a great idea but conflicts with programs which are design to be used in a more &#8220;traditional&#8221; desktop environment. One of those application is my instant messenger. I gave up using <a href="http://blog.mypapit.net/2007/10/centerim-and-finch-ncurses-based-instant-messenger-for-linux.html">ncurses based messengers</a> due to their lack of drag&#8217;n'drop capabilities, so I  started using pidgin.</p>
<p>What I always wanted to have is some kind of tray icon which informs me about new incoming messages. The cool thing about pidgin and the whole underlying purple library is their great support for <a href="http://www.freedesktop.org/wiki/IntroductionToDBus">dbus</a>. So instead of ripping off code from awesome to get full freedesktop compliant tray icons I wrote a small python script to add an icon to my dwm status bar.</p>
<p>The dwm status bar reads a string from stdin (passed to it by xinit) and displays it in the upper right corner of the screen. To do that it uses a loop in .xinitrc like this:</p>
<pre class="brush: bash;">
while true
do
	date=`date +'%d.%m.%Y %H:%M'`
	echo $date `pidginProbe.py`
	sleep 3
done | dwm
</pre>
<p>OK, so I need a script named pidginProbe.py which is just looking for an incoming message on the libpurple dbus interface, prints out a small notification and then terminates.</p>
<p>Here is how I connect to the purple dbus:</p>
<pre class="brush: python;">
bus = dbus.SessionBus()
purple_service = bus.get_object(&quot;im.pidgin.purple.PurpleService&quot;, &quot;/im/pidgin/purple/PurpleObject&quot;)
purple = dbus.Interface(purple_service, &quot;im.pidgin.purple.PurpleInterface&quot;)
</pre>
<p>Asking for an incoming message is not possible without installing a callback to a ReceivingChatMessage signal. But there is the option to ask for all active conversations which includes open chat windows and newly received messages.</p>
<pre class="brush: python;">
def incomingMessageExists(purple):
    convs = purple.PurpleGetConversations()
    return len(convs) &gt; 0
</pre>
<p>This function can be used to print <code>[ ]</code> to the screen when no message was received or <code>[M]</code> otherwise.</p>
<p>Of course much more is possible, nearly all important features can be used via dbus. See the <a href="http://developer.pidgin.im/wiki/DbusHowto">developer documentation</a> to find out about the other calls and signals.<br />
I also added a notification which informs me about specific people going online (like my girlfriend ^^), here is the code example (that&#8217;s the simple version without error handling):</p>
<pre class="brush: python;">
purple = dbus.Interface...
myid = # my ICQ/Jabber/... account id
contactid = # contact's ICQ/Jabber/... account id
myaccount = purple.PurpleAccountsFind(myid, '')
buddy = purple.PurpleFindBuddies(myaccount, contactid):
if purple.PurpleBuddyIsOnline(buddy[0]) == 1:
    print contactid, &quot;is online&quot;
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danielkaes.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danielkaes.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danielkaes.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danielkaes.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danielkaes.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danielkaes.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danielkaes.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danielkaes.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danielkaes.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danielkaes.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danielkaes.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danielkaes.wordpress.com/174/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=174&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2009/12/03/adding-a-pidgin-trayicon-to-dwm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
		<item>
		<title>My Dream Programming Language</title>
		<link>http://danielkaes.wordpress.com/2009/11/24/my-dream-programming-language/</link>
		<comments>http://danielkaes.wordpress.com/2009/11/24/my-dream-programming-language/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 21:13:51 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://danielkaes.wordpress.com/?p=161</guid>
		<description><![CDATA[If one day a fairy would appear in front of me and grant me three wishes, one of them would probably be a new programming language. Here is a list of some features I really want to have in one single language. In a future post I will probably look at some already existing programming [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=161&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If one day a fairy would appear in front of me and grant me three wishes, one of them would probably be a new programming language. Here is a list of some features I really want to have in one single language. In a future post I will probably look at some already existing programming languages and examine how much current languages are able to meet my desired features.</p>
<ol>
<li>Simple &amp; Readable Syntax</li>
<li>Static, Strong Typing &amp; Type-Inference</li>
<li>Functional Programming Support</li>
<li>REPL &amp; Compiler</li>
<li>Easy module/packaging system</li>
<li>Garbage Collection</li>
<li>Immutable Data Types</li>
</ol>
<p><span id="more-161"></span></p>
<p><strong>1. Simple &amp; Readable Syntax</strong></p>
<p>This should be obvious, unfortunately many language totally fail on this one. I guess the problem is to invent a syntax which is powerful <strong>and</strong> simple. There seems to be some kind of trade off between such features. The <a href="http://en.wikipedia.org/wiki/Just_another_Perl_hacker">syntax of Perl</a> is quite powerful but also ugly as hell. And although it is possible to write good, readable code with C/C++ the syntax also allows to create a terrible mess. Maybe this is only a question of personal taste. But I want a language which does not allow developers to write messy code. I personally think Python does a great job on this. Ruby is nice too, although the way anonymous functions are written is a little bit awkward. Another good example for a powerful and simple syntax can be find in <a href="http://clojure.org/">Clojure, a Lisp dialect for the JVM</a>. One advantage of Lisps in general is the ability to write macros, the disadvantage is usually the representation of formulas. However, I wouldn&#8217;t mind the fairy to give me a new Lisp dialect.</p>
<p><strong>2. Static, Strong Typing &amp; Type-Inference</strong></p>
<p>Dynamic programming languages are great! Dynamic programming languages are fun! Dynamic languages are a nightmare if you reach the 1000 LOC barrier and want to refactor your code without a decent test suite. OK, I admit, refactoring without a good test suite is always a stupid idea, but it is definitely more painful with a dynamic language than with a static one where the compiler warns you before running the code. Programming using a dynamic type system allows us to write code much faster, but actually there are very few situations where you really want to have dynamic types. Just look at a random piece of code written in a language like Python or Ruby, in most cases programmers use the language like it had static types. So do we really need dynamic typing? I don&#8217;t see the advantage except for coding speed. Static types make a program much more robust, the compiler can warn us about a lot of mistakes we would usually only find after testing our code. So instead of giving up robustness for faster coding we should find a way to write programs more faster.</p>
<p>In many cases it is obvious what type a variable has, so the compiler should be able to figure out the type of variable declarations on it&#8217;s own. Two good examples for languages where type-inference is used are <a href="http://en.wikipedia.org/wiki/Objective_Caml">OCaml</a> and <a href="http://www.scala-lang.org/">Scala</a>. Just look at the two following code excerpts:</p>
<p>(* OCaml *)<br />
let average a b =<br />
  (a +. b) /. 2.0;;</p>
<pre class="brush: scala;">
def average(a : Float, b : Float) = (a + b) / 2
</pre>
<p>It should be clear that <em>average</em> is a function receiving two float values and returning a float value. No explicit type declaration must be done, the compiler can figure it out. This allows to write concise code in a short time without loosing the power of a static type system. Of course this leads to a lot of other language design question. While in OCaml there are two different plus operators <em>+</em> and <em>+.</em> for adding integer or float values, Scala defines the function <em>+</em> on Integer and Float objects. That&#8217;s why Scala needs a type declaration in the method header and OCaml don&#8217;t.<br />
Anyway, type inference makes code cleaner and improves coding speed. I believe this is a good compromise for the dynamic vs. static issue.</p>
<p><strong>3. Functional Programming Support</strong></p>
<p>I am sick of writing the same code over and over again. I don&#8217;t know how many times I wrote a Java loop like this:</p>
<pre class="brush: java;">
public List&lt;element&gt; filterMyList(List&lt;element&gt; myList) {
   ArrayList&lt;element&gt; newList = new ArrayList&lt;element&gt;();
   for (Element elem : myList) {
       if (elem.meetsSomeCondition()) {
           Elem result = doSomethingUseful(elem);
           newList.add(Elem);
       }
   }
   return newList;
}
</pre>
<p>Instead I want to write something like this (with type inference ;-):</p>
<pre class="brush: scala;">
def newList = myFancyList.filter(elem : Element =&gt; meetsSomeCondition).map(doSomethingUseful)
</pre>
<p>or even just:</p>
<pre class="brush: scala;">
def newList = myFancyList.foreach(elem : Element =&gt; meetsSomeCondition, doSomethingUseful)
</pre>
<p>At the first glance functional programming only seems to offer shorter, concise code, but there is much more functional programming can do. Many (object-oriented) programming pattern just disappear when using functional programming. Typically features of functional programming languages help to avoid clumsy pattern and help to write cleaner code. For example pattern matching is a great deal to avoid <a href="http://en.wikipedia.org/wiki/Visitor_pattern">Visitor</a> patterns or think of the <a href="http://en.wikipedia.org/wiki/Observer_pattern">Observer</a> design pattern! It is a pain in the a*** to implement observer and observable objects all the time. Even in a language like Java where already interfaces and abstract classes for such pattern exist it can be quite challenging to build them into your code because Java doesn&#8217;t allow multiple parent classes (Observable is an abstract class). This can also be solved by using another design pattern like <a href="http://en.wikipedia.org/wiki/Delegation_pattern">Delegation</a>. But it seems like design pattern are often just solutions for bad language design. In a functional language a callback function is delivered to the observable and it just needs to call this function to update the observer. Absolutely simple! Further more many problems can be solved elegantly when using functions like every other type, so this is a definitely a must-have feature. Advanced functional features like <a href="http://en.wikipedia.org/wiki/Currying">Currying</a> would also be nice, but I can live without them.</p>
<p><strong>4. REPL &amp; Compiler</strong></p>
<p>I need a language having an <a href="http://en.wikipedia.org/wiki/REPL">interpreter which can be used interactively</a>, this makes it much more simple to just try out a few things outside the usual compile-wait-run cycle. Also a compiler which assembles the code into native machine code (maybe through intermediate C code) is necessary. If I want to write some small scripts or test things I would use the interpreter. But before deployment the code will be compiled to improve execution speed. There are just a few languages which actually have an interpreter AND a (native machine code) compiler. Most of them can be found in the Lisp and Scheme scene, the OCaml compiler is also absolutely wicked when it comes to speed. I think it is thrilling to see the good performance of compiled <a href="http://sbcl.sourceforge.net/">Common Lisp</a>, <a href="http://ikarus-scheme.org/">Ikarus</a> or OCaml code especially because these languages feel mostly like scripting languages.</p>
<p><strong>5. Easy module/packaging system</strong></p>
<p>Recently a friend pointed out that one indicator of bad language design is the disability of a programming languages to be usable without a proper development environment. And that&#8217;s true! I want a language which allows me to easily write programs with just a text editor and a console window. Of course there are benefits of using IDEs, but the standard UNIX environment provides already a lot powerful commands to search text files, so it shouldn&#8217;t be too difficult to write code with my dream language. One feature which allows to live without an IDE is an easy syntax. The other feature would be a simple module/packaging system. Just imagine how simple it is to import a library into Python and how painful this task is in Java. Maybe Java is the best example of how to not implement a library system. It is absolutely impossible to remember package names and the fact that there is no, absolutely no similarity between library names and JAR file names makes it nearly impossible to write (or even run) Java code without a decent IDE and a build system like Ant or Maven. Here is an example of how to parse RSS feeds with Python and Java and print the title of the first feed&#8230; I hope you&#8217;ll understand what I mean ;-)</p>
<p>Here is the Java code, to use the code like this <a href="http://wiki.java.net/bin/view/Javawsxml/Rome">rome.jar</a> and <a href="http://www.jdom.org/">jdom.jar</a> must be in your classpath:</p>
<pre class="brush: plain;">
&gt; javac -cp ./lib/rome-1.0.jar;./lib/jdom-1.0.jar FeedTest.java
&gt; java -cp ./lib/rome-1.0.jar;./lib/jdom-1.0.jar FeedTest
</pre>
<pre class="brush: java;">
import java.net.URL;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
...
   URL feedUrl = new URL(&quot;http://danielkaes.wordpress.com/feed/&quot;);
   SyndFeedInput input = new SyndFeedInput();
   SyndFeed feed = input.build(new XmlReader(feedUrl));
   System.out.println(feed.getEntries().get(0).getTitle());
</pre>
<p>And the same piece of code in python (just put the code into a file names &#8220;feed.py&#8221; chmod it and type &#8220;./feed.py&#8221; into the console and there you are)</p>
<pre class="brush: python;">
#!/usr/bin/env python
import feedparser
feed = feedparser.parse(&quot;http://danielkaes.wordpress.com/feed/&quot;)
print feed['entries'][0]['title']
</pre>
<p><strong>6. Garbage Collection</strong></p>
<p>OK, that is not a surprise. Computers are much better than human beings in finding unused memory chunks, so they should do it all the time. Alternatively it can make sense to switch off the garbage collector and do the dirty job for yourself. But the small performance loss of automatic garbage collection compared to the huge gain of cognitive resources which are now free to be used for more important stuff should always lead to the decision of implementing a garbage collector. Thanks to new multi-processor systems it could also make sense to run a collector in another process, but I leave the implementation details to the little, friendly fairy.</p>
<p><strong>7. Immutable Data Types</strong></p>
<p>In a multi-processor environment immutable data types are really a blessing. They allow programmers to just write code and don&#8217;t think about possible problems which can occur when two processes are manipulating the same list of items at the same time. I especially like the way Scala solved the implementation of this problem. For every type of collection (List, Map, Set, etc &#8230;) there is an immutable and a mutable type which both have the same method names. The only difference is that the methods of the immutable types returning the result, while their mutable counterparts have no return type and just change the object they are called upon. However, implementing such a feature is not an easy task, normally a copy of the original data structure is to expensive, that&#8217;s why functions returning a copy of a immutable type need to do a lot of intelligent pointer acrobatic.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/danielkaes.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/danielkaes.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/danielkaes.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/danielkaes.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/danielkaes.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/danielkaes.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/danielkaes.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/danielkaes.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/danielkaes.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/danielkaes.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/danielkaes.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/danielkaes.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/danielkaes.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/danielkaes.wordpress.com/161/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=danielkaes.wordpress.com&amp;blog=6944510&amp;post=161&amp;subd=danielkaes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://danielkaes.wordpress.com/2009/11/24/my-dream-programming-language/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/71186d038a40f752bd65e56b7f73d94e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dank</media:title>
		</media:content>
	</item>
	</channel>
</rss>
