Confessions of a Wall Street Programmer

practical ideas (and perhaps some uncommon knowledge) on software architecture, design, construction and testing

Who Knows What Evil Lurks …

Pity the poor Shadow! Even with the recent glut of super-heroes in movies, games and TV, the Shadow is nowhere to be seen.

But I guess that’s the whole point of being the Shadow.

According to this, the Shadow had “the mysterious power to cloud men’s minds, so they could not see him”. Hmmm, that sounds like more than a few bugs I’ve known.

Read on to learn how to get your compiler to help you find and eliminate these “shadow bugs” from your code.

Building clang on RedHat

clang is a great compiler, with a boatload of extremely helpful tools, including static analysis, run-time memory and data race analysis, and many others.  And it’s apparently pretty easy to get those benefits on one of the supported platforms – basically Ubuntu and Mac (via XCode).

That’s fine, but if you get paid to write software, there’s a good chance it’s going to be deployed on RedHat, or one of its variants.  And, getting clang working on RedHat is a huge pain in the neck.  The good news is that I did the dirty work for you (ouch!), so you don’t have to.

Into the Void

I keep reading talk of the sort “I don’t know why anyone bothers with C++ — real programmers use C. C++ is for wussies”, or words to that effect.

Well, a while ago I had to go back to C from working exclusively in C++ for a while, and I have to say that I think the C fanboys are just nuts.

Repent, Sinner!

When I was a kid I went to Catholic school, and back in those days the nuns would indeed rap your knuckles with a ruler if you misbehaved. That doesn’t happen so much any more, but when I see someone making use of the copy-paste anti-pattern, I’m tempted to reach for a ruler myself. (I know, probably not a good career move ;-)

Short of rapping someone’s knuckles with a ruler, though, how do you show some poor sinner the error of his ways?

Status Meetings

One of the banes of corporate life is the status meeting. It would be nice to get rid of them, but then it would be nice to get rid of all the lawyers too1, and I don’t see that happening either.

So, how do we make them better? Well, for starters we could make them shorter. Here’s a way to do that.

Guess What Day It Is!

No, not that – it’s Perl day. (Well, actually it’s just Wednesday, but you get the idea).

Sometimes it seems that everybody likes to hate on Perl, but I think their animus is misdirected. It’s not Perl that’s the problem, it’s those \^\$(.#!)?$ regular expressions.

Or, as Jamie Zawinski once said “Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems.”.

Well, I’m here to tell you that it’s possible to write whole Perl programs that actually accomplish useful work, without any regular expressions at all! And, if you do that, you can actually read the code!

It turns out that Perl is a dandy scripting language, and while some may take issue with its flexibility (“There’s more than one way to do it”), others (including me) find that flexibility very useful.

Where Am I?

From Robinson Crusoe to Gilligan’s Island to Lost, tales of being stranded on a desert island seem to resonate with people in a special way. Some of that likely has to do with the exotic locales, and the practical challenges of getting water, food and shelter.

But an even more basic part is the unanswered question: “Where am I?” that makes things so – well, mysterious.

Shell scripting can be pretty mysterious too at times, but in this installment we’ll learn how to answer that basic question of “Where am I?” to make shell scripting a little less mysterious.

Visualizing Latency

I’m a visual thinker (I think I may have mentioned that before ), so when I’m analyzing performance, latency, etc. I find it really helpful to be able to visualize what is going on on the machine.

As a result, I had gotten reasonably good at using Excel to produce charts, which sometimes helped to correlate observed behaviors like latency spikes with other events on the machine.

For a bunch of reasons I wanted to move away from Excel, though, and find another tool that would give me the same or better functionality.

A Picture is Worth 1K Words

You know those mutiple-choice tests that put you in one of four quadrants based on your answers to a bunch of seemingly irrelevant questions? We’ve all taken them, and if you’re like me they’re kind of like reading your horoscope – it all seems so right and true when you’re reading it, but you wonder if it would still seem just as right and true if the horoscopes got jumbled at random?

Well, I took one of these tests a while back that actually told me something about myself – it was the “Learning-Style Inventory” test, and what it said about me is that I’m waaaayyy over at the end of the scale when it comes to visual thinking. That gave me an insight into the way my brain works that I’ve found really helpful ever since. So, this next bit was right up my alley, but I’m guessing you’ll like it too.

We read a lot lately about NUMA architecture and how it presents a fundamental change in the way we approach writing efficient code: it’s no longer about the CPU, it’s all about RAM. We all nod and say “Sure, I get that!” Well, I thought I got it too, but until I saw this web page, I really didn’t.

See the full discussion at http://overbyte.com.au/index.php/overbyte-blog/entry/optimisation-lesson-3-the-memory-bottleneck.

Using clang’s Address Sanitizer (without clang)

Valgrind has been an indispensable tool for C/C++ programmers for a long time, and I’ve used it quite happily – it’s a tremendous tool for doing dynamic analysis of program behavior at run time. valgrind1 can detect reads of uninitialized memory, heap buffer overruns, memory leaks, and other errors that can be difficult or impossible to find by eyeballing the code, or by static analysis tools. But that comes with a price, which in some cases can be quite steep, and some new tools promise to provide some or all of the functionality valgrind provides without the drawbacks.