software

Busy working on Mesquite

I have been busy working on Mesquite with Robert lately. You can follow what we’ve been up to in our development blog!

Sunny Sunday Mill Valley Groove Day from the album Honeycomb by Frank Black

The joys of C++

I have been working on some C++ code lately at work (among lots of other things) and to put it mildly, it’s been a frustrating experience coming from the Java world. Sure, I studied C++ in school. However, there’s a big difference between having studied a language and actually practiced it. I never really did anything more significant than school projects with the language and wasn’t really complaining about it, being pretty happy with Java. Not that Java is perfect either but that’s a different story… :)

There are lots of annoying things in C++. At least, things that annoy me. I’m sure there are good reasons for things to be that way but to me some of the stuff is just downright ugly. Take the STL for example. How complicated does this needs to be? For one thing, it’s really not OO. Then looking at the documentation can be pretty intense unless you know your templates (which according to Wikipedia, allow the programmer to save time and space in source code by simplifying code through overloading functions with an arbitrary type parameter), inside and out. So, how simple does it really make your life? Turns out, it’s pretty neat once you figure how to use it. Figuring the stuff out is however rather painful.

The project I work on has three developers (including me), which for my group is pretty consequent. Only one of us really knows C++ (meaning he worked on real C++ projects before, while the other guy’s and my only exposure to the language was whatever we did with it in school). That developer worked on the most complicated part of our project (a graph structure, and related algorithm implementation, aimed at aligning multiple streams of words together) and first implemented a part of the structure using an STLmap. To finish the first iteration fast, we used strings as keys (to keep the code simple). These strings were generated from an int array (representing coordinates in the multi-dimensional alignment space). Obviously, this was far from optimal. We decided that switching to a (not quite standard but implemented in GCC and in Visual C++) hash_map would make things faster since we needed fast access to the the values given a key and that maps are not hashed associative arrays. However, making the switch proved to be more painful than what I was used to: in Java, it’s easy to switch between different implementations of associative collections (collectively referred to as Maps in Java). In C++: not so much! I am not sure what C++ experience our local “guru” has but what I know is that when we have a question (which, granted, probably have often obvious solutions to C++ experts), he usually has the answer. However, he couldn’t figure out how to easily switch our structure to use a hash_map instead of a map. Since it was optimization-related and others parts of the code required more attention, he moved on to working on some other things. I decided to take a shot at it today because I don’t like it when a language forces me to compromise on a design.

To keep this post from getting any longer, I’ll just say that I managed to make it work after some effort. How important was that refactoring? Considering that the version using hash_map is more than 18000 times (yes, you read correctly, 18000 times) faster than the previous version, I would say it’s pretty major, wouldn’t you? And it’s just sad that the complexity of C++ prevented us from making these changes sooner/faster. It says a lot about a language when a (moderately) experienced developer with that language has problems figuring out the standard collection framework. A programming language should help you implement the design you created and you shouldn’t have to compromise (too much) to make it work reasonably well… C++ is really static compared to Java and makes it difficult to experiment with different implementations. Case in point: the refactoring I did wouldn’t have taken more than a couple of minutes to implement in Java. A more proficient C++ coder than I am might not have spent as much time on it as we did but the fact remains that the STL (and C++) didn’t help…

World from the album Republic by New Order

Ditch IE already…

Digital Proof offers to collect articles and information on how IE is bad for you, your computer and kittens… So get on with the program and ditch IE already!

456 Berea Street

bad things from the album interstate 5 CD single by The Wedding Present

Del.icio.us user interface design

How do you approach user interface design?

Lots and lots of iterations until something feels right. Avoiding features until the interface for them is apparent. Seeing how users use the existing features to do things I didn’t expect, and then making those things easier.

Joshua Schachter, answering a question from Rands in A Del.icio.us Interview

If it doesn’t feel right, the job is not done. Until your software feels natural, until interacting with the computer just flows, without having to think about it, tweak the interface. And when you think you’re done, watch your users: nothing is more rewarding for a software developer than seeing users make the software their own and use it beyond what was originally envisioned.

I’m Amazed from the album Pixies by The Pixies

This post courtesy of Quicksilver

I tried to install 10.3.6 yesterday and for a reason or another, my laptop kernel panic’ed on me during the install. I had to reboot and wasn’t too hopeful that it would even work. Much to my surprise though, I was able to login without issue. Only noticeable problem though, no Finder, no menu bar, just floating icons at the top right of the screen and my empty Dock at the bottom right (I only use the Dock for the trash and to monitor running applications). Since I had Quicksilver installed though (and its icon was showing among the other icon where the menu bar would normally be), I was able to launch Terminal and other apps. I have been able to work with my system without any other issue so far.

It goes without saying that I will re-install. However, without Quicksilver, I wouldn’t have been able to use my laptop in the mean time. It even allowed me to try and re-install from the full updater instead of Software Update (both from the GUI and command line since Installer would get stuck after showing the license). Though it didn’t work, at least, I could try! Thanks, Quicksilver! :)

Weblog editors and crashing

inessential.com

One of the benefits of using a desktop weblog editor is crash protection.

Say you’re writing a post in your browser, and your browser crashes. The post is gone.

Say you’re writing in MarsEdit instead. You can save as a draft periodically so you can prevent a crash from losing your post.

But—even more—MarsEdit automatically recovers your post in the event of a crash, even if you didn’t save it as a draft. When you re-launch MarsEdit it will re-open the post or posts you were working on.

I concur: MarsEdit has saved my posts a couple of times already. It’s not only a matter of MarsEdit crashing: if my mac crashes for some reason while I am working on a post (or have a post waiting to be posted in the background), MarsEdit saves the day. Brent has done a very good job with it.

Now the big question: why isn’t there more text-processing applications implementing auto-save?

Giving You Up from the album by Kylie Minogue

The Ruby on Rails conspiracy

Seems like there’s a conspiracy going on for me to look more closely at Ruby on Rails. It all started with Brian McCallister‘s post.

Then, while looking at the Rails website, I noticed that references were made to Basecamp, which I had previously put in a corner of my mind a while ago as something to look at, being in a similar application segment than Mesquite. Basecamp was developed using Ruby on Rails. The plot was thickening…

Just recently, I got to meet Brian personally and he tried to convince Robert and I to use Rails to develop Mesquite… :)

Finally, TextMate, a much hyped text editor for OS X, was officially released today. Looking at their website, I noticed a block on the right column called TextMate in Action pointing to a video none other than the one that was pointed to by Brian! And I’m like: WTF? This was getting scary!

Decided to not let coincidences take the better of me, I investigated some more and found that TextMate, Basecamp and Ruby on Rails were all developed by the same guy. Whew! There was a rational reason (there’s a pleonasm for you) behind this madness…

Man, the persecution never ends: Dion Almaer chimes in! This setup movie has become something of a blockbuster! :D

You Don’t Know Jesus from the album Rock Action by Mogwai

Making Stattraq work better with permalinks.

I am using Stattraq to keep track of the traffic on this weblog. I installed it back in August and recently installed the ViewCount plugin. However, much to my disappointment, Stattraq doesn’t play that nice if you use permalinks. The problem lies with the fact that Stattraq in its current version does not properly put the article id in its database if permalinks are enabled: it will use the id 0. Of course, ViewCount relies on the article id to work its magic hence the problem…

To solve this issue, I decided to improve how Stattraq was handling the article id and you can too! It’s fairly easy: open stattraq.php (it’s found in the wp-content/plugins directory of your WordPress root directory) in a text editor. Find the line that reads:

  1. $article_id = 0; // default/mixed page – not just for one article

and replace it by the following:

  1. //$article_id = 0; // default/mixed page – not just for one article
  2. if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])){
  3. $article_id = $wpdb->get_var(“SELECT ID FROM $tableposts WHERE 1=1″.$where);
  4. } else {
  5. $article_id = 0;
  6. }

The trick here is to use the url parsing magic found in wp-blog-header.php. That’s where the $where variable gets built. We then use it to retrieve the post id. The check on the server query is required because the index page needs to be processed differently. If the requested page is the index page, the query returns all the posts and get_var returns the id of the first record returned (which is your weblog’s first entry) which is not what we want.

Well, apparently this does not work though I am at a loss right now to figure out why. The code above, executed in the context of index.php, seems to return what I want. However, when executed in stattraq.php, it doesn’t work, resulting in the article_id field being empty… I guess I jumped the gun, thinking that I could use $where in Stattraq but it seems like it’s not going to happen without a fight. I’ll look at that when I get up.

Please note however that I haven’t fully tested this code so bad things might happen. Moreover, I’m both a WordPress and PHP newbie so chances are that my solution is neither elegant nor efficient. Also, smart readers will have noticed that this only addresses one side of the problem: the article id should now be correct in the Stattraq database. However, previous entries will still keep the “0″ article_id. How to fix this is left as an exercise to the reader.

Many thanks to Robert and Thomas for their help! :)

Obstacle 1 from the album Turn On the Bright Lights by Interpol