tiistai 9. maaliskuuta 2010

Virtual desktops with content pull from update queue

I'd like to be able to quickly glance over all the content updates on my apps. For example, if I'm coding in one virtual desktop, and different friends would send me messages via IRC, and Skype. A widget should notice that there's certain kind of updates available, and I would be able to pull those updates to the current virtual desktop as a preview window. Just by pressing one key I could go through all the updates and quickly interact with them.

I think this would lead to some kind of efficiency improvements, and could be quite neat. Here's the idea in a bit more detailed way: http://personal.inet.fi/koti/egaga/ideas/desktop.html

lauantai 6. maaliskuuta 2010

The pure lie of Haskell (ghc)

When I stumbled upon Haskell, I was so impressed with the concept of its purity. Functions that don't have IO types in their signature, are guarenteed to be side effect free, and are called pure. You can trust that when you evaluate a pure function with the same arguments, you will always get the same result and that nothing suspicious happens under the hood, e.g. ejecting DVD out of your computer.

Here's a quote from Real World Haskell (which is great, btw).
Haskell strictly separates pure code from code that could cause things to occur in the world. That is, it provides a complete isolation from side-effects in pure code. Besides helping programmers to reason about the correctness of their code, it also permits compilers to automatically introduce optimizations and parallelism.

That is what most Haskellers brag about. But they don't mention that in the (only?) viable industrial strength compiler (GHC) let's you to by-pass this with evilness called unsafePerformIOhttp://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO-Unsafe.html

Its type is IO a -> a  
Basically, it let's you to perform an IO action in an pure context. Also, it's not even type safe as the documentation points out.

I must say I have been quite angry once I found about this, although it doesn't seem to concern others as it doesn't affect much the everyday use of the language.

I think it would be nice to have a compiler option for checking that unsafePerformIO or any other hack is not present in any used code path. This would be important for example when one setups a public environment to evaluate Haskell code. It also would drop the risk of getting malicious code from open source library you are including in your project without the need to manually check (or grep it).

Of course, I'm not denying the need for unsafePerformIO, it's just that it ruins the whole beautiful idea in one quick shot. There is no way to enforce pureness because of it.

One way to make the situation better would be to require modules to explicitly document functions that (transitively) are using backdoors. That way the type system would work as always, but at least people would know the risk via documentation.

At least, the morally right thing to do would be to mention unsafePerformIO when one introduces Haskell, as it's a little cheap to sell something that isn't there. Luckily, the separation of IO and pure code is still very useful in practice as it guides to better division of programs, and one needs to be explicitly aware when she's breaking the rules.

perjantai 5. maaliskuuta 2010

Introduction for the curious

Hi, I'm Henrik.

I'm quite enthusiastic about programming. Recently I've been studying Haskell, Clojure and Factor, which all are sophisticated functional programming languages. All of them have distinct philosophies behind them, and coding in them twist your mind into different dimensions. Haskell has powerful static type system. Clojure is dynamic in nature and has macro facilities. In Factor code operates on implicit stack.

So one thing what I'm going to talk about is features and quirks of those languages. Occasionally I probably will also discuss the current trends in software industry and maybe the possibility of alternative education. We shall see.

Lastly, I would like to suggest you some reading and videos: recommendations and advanced topics
You can also find more about me in my homepage.