This is a read-only archive!


If only I had a dime for every time Stroustrup used the phrase "This would be disastrous". It can refer to everything from misuse of pointers, to making your destructors non-virtual in a class that will be a base class for some derived class, to all sorts of other C++ pitfalls. I got my copy of Effective C++: 55 Specific Ways to Improve Your Programs and Designs today, and Meyers seems to use the same phrase a lot too. Maybe that says something about C++.

Maybe it's my twisted sense of humor, but I really get a kick out of that kind of over-the-top hyperbole though. The other thing I get a kick out of is programs that insult their users. You can't beat that for a laugh. Scott Meyers has already insulted the average uninformed C++ programmer a bunch of times in his book, and I'm only on chapter 1. Clearly good times are ahead.

Although I'm theoretically "done" reading Stroustrup, I've resolved to go back through the book and do all the end-of-chapter exercises. I figure that's a good place to start before trying any kind of larger project in C++. He must've included all those problems in there for a good reason. I can already think of something at work I'm going to try to redo in C++ to try to speed it up a bit compared to the Ruby version I have now. (I doubt I could make it any slower than Ruby if I tried.)

Tonight though I was distracted by a really fun site called Project Euler, which is a collection of small mathematical-type programming problems that you can try to solve for fun. I finished 15 of the 159 problems after work tonight. All in Ruby, of course. But I think I did the easy ones. Some are harder than others. But according to the FAQ, all problems on the site are meant to be able to be solved in less than a minute of runtime on a modern computer. Some of the problems are brute-force solvable but some others require some sophisticated algorithms to have any chance of solving before the universe ends. Coming up with an algorithm for a problem that has a nice big-O runtime is by far one of my weakest areas, so this is good practice.

You can register on the site, write a solution, submit it and it'll tell you if you're right. It also collects statistics (if you choose to give them) about who's using what programming language to solve the problems, and what country you're from. And then it ranks how many people use each language, and how successful each languages' users are (going by how many problems they've solved). So in that sense the whole site is a kind of programming language battle to the death. (Did some people really solve these problems in Tcl?)

If that site is any judge, C and C++ (lumped together perhaps inappropriately, according to Stroustrup anyways) is/are the most popular language(s), followed by Python and Java. Ruby made a good showing, which makes me happy. Ruby's immense standard libraries make many of the problems there trivial no-brainers. Either way, this seems to indicate that there are a lot of C programmers out there. Or it may be that the number-crunching mathematical nature of these problems lends itself well to C, which is why so many people picked C to solve it.

July 25, 2007 @ 2:06 PM PDT
Cateogory: Book Reviews

1 Comment

David Grant
Quoth David Grant on July 27, 2007 @ 9:35 AM PDT

Thanks for the Project Euler link. I did about 5 of them last night and was fun!