On the train, beyond reach of the interweb and without my collection of books on C++ (including 3 beginners books and Bjarne Stroustrop's), I decided to rewrite my Hilbert Curve perl module in C++, after all I did C++ in university as together with C and I have been learning it on and off since before I started university.
The perl implementation I put together for Hilberts space-filling curve is object oriented and doesn't use many perl idioms, its not c-style, but its not got any currying or shwartzian transforms -- it doesn't even use map or grep! By rights I should be able to make a good start on porting it to C++ in the hour or two I had spare on the train after I caught up on work for $dayjob.
I knocked together a skeleton class, with attributes and methods that the perl module used - I could have used autodia or one of the many diagram to code generators, but there is something very satisfying about elegance of a clean new C++ class. Of course this satisfaction was short-lived when I realised that my perl code takes arbitary non-uniform data-structures for granted. This is the usual reason, I don't end getting far in my adventures with strict typing languages -- perl makes it easy to concentrate on solving the problem without having to deal with finding the right classes in the right libraries and deriving them to build a managable data structure.
I mean, who knows how big an array will be at runtime? In the case of the points on a curve, it depends entirely on the size of the area covered by the curve, which could be anything from 2^2 points 2^32. Obviously I don't want to kill the machine so the curve can't just go eating the whole system memory, but I don't want to set an arbitary limit.
So I plan to spend the next couple of weeks getting back up to speed on C and C++ and the joys of using pointers and iterators, I have learnt it all before - I even managed to write a gnarly GTK front end to my final year client/server project with Trees of files, versions, etc that required dynamic arrays of arrays and recursion. Once I relearn what perl has allowed me to take for granted I will be able to start writing some applications in QT so that they run on windows.
That would mean the rest of my family can actually use the software I write, starting with a crop/resource management application for my father-in-law. An interesting problem - he has x ammount of greenhouse space, he needs to use this space effectively to grow and store hundreds of thousands of plants (from 2 inch grass plugs to 3 litre azalea and banana plant pots), all of which is affected by the season, how fast he can pot, split or take cuttings and prepare the plants for wholesale. Any re-arrangement of plants can take a matter of hours, cleaning and packing can take days, and sometimes he only gets a few days warning before a large order is to be collected by the buyer. A very complex problem, but good planning should make it more managable, also an interesting exersize to stretch my C++ and analysis/design skills.
edited:
..and there you go - within 5 mins of getting the interweb and goodle, I can do what i need with new and a pointer.. easy.
This C++ lark might be fun if everything is as easy as that.. for my next trick -- using STL templates, or not.