Archive for the 'review' Category

Functional Programming Principles in Scala

For everyone who is interested in having a closer look at Scala and functional programming:

Martin Odersky, the author of this programming language, is giving an introduction into the Scala on coursera. It will be a seven week long, free online class with weekly home-work assignments and a certificate at the end.

You can signup here.


Free MongoDB developer online class

During the past few years we saw a steady rise of NoSQL databases. While most of them are for very specialized scenarios there are a few multi-talents which can be a good replacement for a more traditional storage solution.

One of the more well-known is MongoDB, a document-oriented, schemaless database, which I started to like very much. MongoDB is easy to set up and allows me to store objects into the database right away, without thinking about table layout and hacking SQL installation scripts. Of course it also has its downsides, but later more on it.

Currently I take an online class on MongoDB for developers, which is provided by the makers of the database at for free. The online class consists of a couple of video lectures and regular home work assignments. After seven weeks the class will end with a final programming project and of course a 10gen MongoDB developer certificate.

The homework is easy and the course is progressing with a slow pace which is ideal if you cannot or don’t want to spend to much time on it.

I don’t think you can join the current class, but at the end of February (25th) a new course starts:

“M101J MongoDB for Java Developers”

So if you are interested in taking a closer look, then join the course. So far I like it. It gives a good introduction, talks not just about the programming API, but also about best practices in document design and performance tips. You will not be a professional mongo developer after the course, but I think it provides everything you need to start using MongoDB and is also a good starting point to dive deeper into the issue.


Writing A Synthesizer With Brainfuck

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 ;-)

Reinventing Human-Computer Interaction

Many of you probably remember “Minority Report”, 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:

reinventing desktop human-computer interaction: 10/GUI

What is the most popular programming language?

Well, the answer is Java … 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. However Ruby seems to continue it’s rise to conquer the world, although slowing down in the last months.

Here is a chart showing the long term trend of programming languages:


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 “market share” among the programmer community, but that doesn’t seem to happen.

A Deeper Look at the Scala Syntax

Scala is an object-oriented, statically-typed and functional programming language for the JVM. The strength of Scala lies in it’s powerful syntax which allows to write readable, manageable code which is short and concise – and it comes with great support for common design pattern (i.e. a special keyword for implementing the singleton design pattern).

There are plenty of good tutorials and introductions for learning Scala in the web, but only a few mention the great possibilities programmers have to extend Scala or even build an own domain specific language using Scala without being forced to use macros as seen in LISP-like languages.

One interesting feature of Scala are “blocks” which work quite different then code blocks in Java and C++ although they use the same syntax. A block in Scala is rather a sequence of expressions which is evaluated successively and it returns the value of the last expression. Just think of them as the “do” function in LISP. Blocks are surrounded by curly braces and the expressions they hold are separated by semicolons.

scala> {val x = 2; x + 5}
res0: Int = 7

Thanks to some syntactic sugar the semicolon can be replaced by a line break which becomes handy in larger blocks.

scala> {
  val x = 5
  x + 5
res1: Int = 10

Because blocks are just expressions they can be used, of course, like every other expression. They can be stored in variables, returned by functions and also be used as parameters for functions:

scala> println(2+5)

scala> println {
  val x = 2
  x + 5

The attentive reader might already have a glimpse of the potential power of such a syntax. This tiny, simple feature allows us to define functions which look and feel more like keywords of the language’s syntax. Just think of a function which measures the time a given piece of code needs to be executed. How would you write something like this in Java or even in a dynamic language like Python? In Scala this can easily be done by writing a function which expects a code block and handles it like a function which returns a value of any type to simulate lazy parameter evaluation.

def time(code: => Any):Any = {
  val time = System.currentTimeMillis
  val result = code
  println("time elapsed: " + (System.currentTimeMillis-time))

def fib(n:Int):Int = if (n < 2) 1 else fib(n-1)+fib(n-2)

scala> time {

time elapsed: 1020
res2: Any = 165580141

Creating HTML Documents from Files with Wiki Syntax

I want to create some simple HTML documents with some basic layouting like heading, images and links. Writing pure HTML can be a slow and painful procedure. Usually I’m working with a lot of wikis, so I want to have a file were I can write my document using a common wiki syntax and generate HTML code from this wiki file afterwards.

There some good Perl wiki-to-html converters out there, but since I don’t want to install Perl on my Windows machine at my laboratory, I rather want to have something written in Python.

I found a nice parser and html converter for the Creole Wiki Syntax, it works well with Linux and Windows.

Unfortunately Creole is not the most powerful wiki syntax, I didn’t found out how to create a table of content yet and there are some other drawbacks. If someone knows a good wiki2html tool which doesn’t have tons of dependencies and runs fine under Windows, feel free to leave me a message.