Older blog entries for tmorgan (starting at number 1)

Functors in Haskell and C++

C++ is my language of choice for almost every project I do, not least for it's wide range of support language paradigms - OO, functional, generic etc. But I'd be the last person to say that it's a pretty language. Example: creating an object that will add 2 to a number:-

C++

std::binder1st<std::plus<int> > binder= std::bind1st(std::plus<int>(),2);

Now compare this with Haskell

(+2)

I haven't got very far with Haskell yet, I'm just trying to learn it to stretch my brain a bit, but this does highlight the hoops one has to jump to to make C++ behave like a functional language. That said, the boost people are making this easier with the boost::bind library, which I use a fair bit, and maybe the lambda library, though I haven't tried that yet.

I guess it's a testimony to the power of C++ that it can handle so many diverse paradigms, even if it isn't always pretty. And it can be taken far beyond what the original creators intended - witness what's been done with template meta-programming.

It also seem that the C++ compile-time language (i.e. template meta-programming) is a purely functional language, (see here, so we have this weird hybrid of a language that is OO and procedural at runtime, but functional at compile time. No wonder it takes so long to become truly skilled at using it.

slamb, , I'm also very glad I stumbled across scons. It's made maintaing cross platform library software vastly simpler than the ugly makefiles I was writing. It definitely should be publicised more, it's a very nice piece of work.

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!