Friday, May 27, 2005

I seem to keep heading over to the Boost website, reading about some of the libraries, but never actually using anything. After reading about the lambda library, I think that's going to change. It seems so deliciously evil that I don't think I can say I have C++ experience without trying it out. Perhaps if I learnt Lisp like I intended to, then I wouldn't be as impressed; from what I've read, Boost's lambda functionality, although mighty impressive, is nowhere near as expressive as the equivalent in functional languages. But still, it seems a valiant effort, and it amazes me how they managed to extract so much out of templates (which are a nice idea, but I never expected that it could allow for such a level of extension).

Now, although these advanced parts of C++ are interesting, are they significantly helpful? Do they help one be more productive? I seem very much to be in a state of ignorance when it comes to software, don't I? Alas, I seem unable to determine the metric that other people (seemingly) employ to decide when to use C++ or Java, or vice-versa for a "normal" program where portability is not an issue (so perhaps I mean "simple" rather than "normal"). These parts of C++ are certainly a striking difference to Java, but I can't honestly say that I think that yes, they will increase productivity dramatically. It seems to be personal preference from where I'm standing, but surely there has to be more to it than that?

After a long struggle, I managed to install the Boost libraries for use with Cygwin. I thought I'd do it yesterday, but I should've known better than to do anything that requires mental effort past bedtime; I ended up installing Boost for Visual C++ instead of gcc, because I downloaded the Windows version of BoostJam! It was quite unforgiving in that the installation took at least an hour, and after a lot of patient waiting, I was puzzled as to why nothing seemed to be working. Of course, this morning things became painfully clear, and I set about installing it all over again. The installation isn't as friendly as I'd like, but it's a C++ library, so I think they expect a minimal degree of technical competence. Anyhow, it it installed now, so I am able to write perverse wonders such as

vector v (5);
for_each (v.begin (), v.end (), boost::lambda::_1 = 1);
for_each (v.begin (), v.end (), cout << "Element: " << boost::lambda::_1 << "\n");

Wow!

Of course, the point is made here that such things would read much more cleanly as something like

for_each (w in v)
cout << w;

similar to how it's done in C#/Java 5. Anyhow, it seems that Boost's lambda library pushes C++ to its limit, and I'm interested in seeing what that limit is.

No comments: