Time in a database

For some applications, the ability to be able to trace the different states during the lifetime of data can be very important. Especially when it comes to debugging. This is mostly relevant for data stored in a database, but could potentially also be interesting for in memory data structures. Luckily many databases today support this as change data capture. I would add to the article that the capturing the user as part of the change can be very effective.

I have recently been involved in the development of two systems where this pattern has been employed to great success. One where this was implemented in hand, and one where CDC in SQL server was used. The hand implemented solution had some special requirements that meant we did this in hand, and it also doesn’t tie us to a particular db. While not free at all, once it is up and running, it provides an invaluable tool for reasoning about the data.

I was very pleasantly surprised when datomic was announced with a time model as one of the core concepts. I really think that in this age where storage is so cheap, that we can’t afford to threat data as mutable.

Donation links

I really love the kickstarter concept, flattr and in general other great free projects, such as wikipedia and wikileaks. Then there are smaller projects such as The Project Hate MCMXCIX trying to fund the recording of their latest album. Or the interesting, but maybe a bit top low budget TV series Pioneer One. Or the excellent free android mod cyanogen.

I donated to the recording of Obscura’s demo collection this month, what did you donate to?

A digital dictionary

One of the nice things about reading is that it enhances ones vocabulary, but only if one can learn the new words that one meets. I’ve always dreaded using a dictionary because one has to manually find the right page, and for them to contain all relevant words they need to be huge. When one is used to computers, this just seems terribly inefficient. Luckily now there are many online dictionaries. Sadly they don’t help very much when one is lying on the sofa or in bed and reading. This is where I think the kindle really shines. When reading a book on the kindle, one can instantly look up a new word without leaving the page. This alone is often compelling reason enough to buy it as an ebook than to buy it in paperback.

And if the book you’re reading is a physical book, you can still use the Oxford dictionary that comes with the device to look up words just by typing them in. And because the device is very power efficient, one never has to worry about it running out of power any time soon.

Read my review of the kindle for more information on the device.

Learning from the web

While Paul Graham and many others have pointed out the virtues of web compared to normal desktop software. For Nemo Documents, working as a file manager for local files, it was quite clear that we needed a desktop application. Given this how could we then apply as much of the good things about the web into developing a Windows application?

We quickly decided on WPF as it allows one much greater freedom in designing the application. We wanted something visually appealing and in this I think we succeeded (whether that is the case, is of course not up to me to decide :-)). But at least it is not the ordinary ugly grey programs that are so common in the Windows world. As for WPF as a framework I’m quite torn. On one side, it allows one to do a lot of fancy stuff, but on the other side there is way too-much architecture astronauting in the framework and that really hurts when you’re just trying to get something done. jQuery is a good example of how to do this right.

Another thing to learn from the web is to watch the error log and quickly fix problems people are seeing. There is nothing more frustrating as a user than software that is not working, so we made it virtue to respond quickly to errors and to get new versions into the hands of people. With the build-in auto-update feature of Visual Studio, it’s quite easy to keep already installed versions updated. It’s not quite as smooth as updated code on a server, but it goes a long way. And I really think that providing excellent customer support is key these days. When it’s so easy to go “next-door” one has to provide exceptional service to retain users.

The last point also goes hand-in-hand with agile. Getting software out and into the hands of people to get early feedback and use that to better shape the software to fit real needs. We try to release new features when we consider them stable enough for ourselves to use. And that doesn’t have to be every half year 🙂 We recently did this with the google calendar and google docs integration. A feature we coded and rolled out a month after the initial release.

A messy desktop

Earlier this week we released a new version of Nemo Documents, the biggest addition is that we integrated google into the desktop. How this improves things have been documented on the official nemo documents blog, so instead of writing more about that I want to focus on a more personal angle, namely the subject of a messy desktop versus an organized one.

My windows desktop is quite messy. You can see how it looks below. Then again, it’s mostly used to store temporary stuff. Projects we are working on always go into a neat folder structure inside our version control system.

Finding stuff in a messy desktop can sometimes be a bit tedious, but on the other hand so is cleaning up. Furthermore it might not even be a good idea to clean up too much. No matter what your mother tells you 😛 Another thing is that the urge to clean up is lessoned by the fact that you know 90% of the stuff are most likely not to be used again. But you keep it around just in case. This is where I think Nemo Documents really shines. It gives you a structured view of your files based on time and allows one to organize as much or little as needed using labels, while still maintaining the folder structure already in place. I map both my structured folders and my desktop into this view.

While talking to people about how they organize their files and documents I tend to meet two types of persons: people, like me with a messy or semi-messy structure and people in the other end with a big folder hierarchy to structure their files. The question then becomes, if Nemo Documents is only for messy people? After releasing the software we have gotten feedback from a lot of people, including the same people that are big on organizing, and from what we are hearing they are very fond of the system as well. The thing is they love structure, and this is exactly what Nemo Documents gives them. Free file organizing is always welcome I guess 🙂

Amazon Kindle review

I’ve recently bit the bullet and bought a kindle. I’ve been wanting to see the display of an ebook reader for a while but never had the chance, but the reviews of the display were all very good so I wasn’t too worried about that. With the recently announced 3rd generation kindles at a much more reasonable price I decided that it was time to see what all the fuss was about.

I have been using the device for about two weeks and so far the overall impression is very positive. I haven’t recharged the device yet and it’s still about half full. I usually read at night before going to sleep. I’ve also used the built-in Oxford dictionary the first week. This was while I was finishing off a “normal” book, The Day Of the Triffids (excellent book btw). Even just as a dictionary it also works very well because of the keyboard, the screen and the fact that you don’t need to think about charging.

I have started reading Cory Doctorow’s latest novel for the win. The book can be downloaded for free in kindle format (DRM free). It’s wonderful to see Doctorow standing by his principles and embracing the future. In the past I would download his latest work and read it on my computer, waiting for the physical book to arrive in the mail. Now I can just download it right away, read it on a very nice screen, and donate if I like the book.

Living in Denmark I must confess that I haven’t given much thought about using it to read Danish books. I mostly read books in English anyway, but at some point I’ll have to check out if and how one can borrow ebooks from the library. But that is a subject for another blog post 🙂

The good:

  • The screen. It’s better than paperback. Yes it’s that good.
  • The dictionary (I’m quite surprised of how much I’m using it)
  • Battery life
  • Very light and can fit in a ton of books

The bad:

  • Ebook prices. Why are a paperback version sometimes cheaper than the digital version?
  • DRM on books
  • PDF files can be viewed, but one really needs a bigger version as the kindle will not format the text to fit the screen properly. Hopefully this will be fixed in a firmware update sometime in the future.

And the ugly:

  • It’s not too shabby looking with the graphite 🙂

Nemo Documents released!

Today I’m pleased to announce something we at IOLA have been working on for quite a while. In essence it deals with how one can create a more humane interface for managing files an documents. By humane I mean an interface that is build with people in mind instead of computers. I’ve written a bit more elaborately on the official blog about how and why we have designed the system in the way we did. If this short teaser was enough of an appetizer, you can also just go ahead and try our beta version of Nemo Documents right now for free.

Language design

When talking to people about the benefits of clojure often people point out that most modern languages have evolved to “support” the functional paradigm with lambda functions. The argument is that one can stay in the familiar safe environment of imperative programming and use the functional constructs when they fit the problem better. That is a very valid and good strategy but I’ll show in the following that it brings a whole lot of accidental complexity with it. Some of this is specific to the way .NET is implemented and some are a clash of the functional paradigm with the imperiative.

Exhibit 1:

My favorite example is what has been known in the office as the lambda bug. Coming from a background of having been coding in C++ for a couple of years, we switched to python in the last semesters of University. The lambda bug manifests itself when one combines two classical constructs of two different programming models: for-loop iteration and closures:

foreach (var i in list)
save_callback_function_for_later_use(x => System.Console.WriteLine(i));

Given that list contains the numbers 1,2,3,4,5 guess what the code will print when all the callback functions are called?

Exhibit 2:

In C# events seems to have been programmed to a pre-functional model and never updated when they added functional constructs. The interface for an event is += for adding events and -= for removing. This is all fine for point-and-click GUI programming. Meaning it works good on something like event += somefunc; and not event += delegate { use_the_power_of_closures_Luke ) 🙁

To add injury to insult, events doesn’t even support something like clear().

Exhibit 3:

In clojure all the seq library is lazy. Thus once one has figured that out (I must say it took a little while for me), everything behaves as would be expected. In C# some things are lazy (linq) while others are not. Imagine list contains 1,2,3. Then the following works:

var changed = list.ConvertAll(x => x * 2);
list.Clear();
list.Add(something)
list.AddRange(rest);

But the following doesn’t work because it behaves lazy:

var rest = observablelist.where(x => x != 1);
observablelist.Clear();
observablelist.Add(something)
observablelist.AddRange(rest);

Try guessing what the outcome of running the code above will be. I’ll confess that it was different from what I expected it to be.

Again it’s mixing two styles of programming, functional lazy code with imperative mutable objects.

Finally, my argument is that a language with clean design principles, even with relatively steep learning curve, far outweights the complexity of industry standard languages in the long run.

Concurrency the other way around

Clojure is built around concurrency and it clearly shows in the abstractions the language makes available. I would say that concurrency is pervasive in the language. The good thing about that it that it’s a bit harder to shoot yourself in the foot when doing programming with multiple threads. But the bad side is that it adds quite a bit of mental overhead in situations where concurrency is undesirable.

As an example in mucomp, there is a certain part of the code that deals with the audio player. This is inherently a resource that should only be handled by one thread at a time. Clojure comes with a very good abstraction for exactly this problem, agents. An agent is simply some state, that is manipulated by only thread. Using an agent is done by through sending a function to the agent that will take the old state and return a new state. So with that one gets everything that is needed to write an audio player: serialized access and safely mutable state.

The only bad thing about agents is that if one forgets to return something from a function that run on the agent, then the new state of the agent will be nil. After being bit by this two times I decided that enough was enough. One of the very nice things about languages in the lisp family, is that one can mold your own abstractions to make code better (easier to read and with less bugs in this case).

The following macro creates a new way to define functions. Functions defined in this way will check for nil on return, and return the old state instead. The only change that is needed in code is to use defa instead of defn 🙂