Create a WMI Application - Refined

I recently had the need to be able to query the WMI via WQL (which are very fascinating and helpful technologies, actually) from C++. WQL essentially provides an SQL interface for querying system properties of a running computer.



Creating Bad Code That's Still Great

There are plenty of opinions out there about how to write great code ranging from styles and techniques to code formatting and programming languages. Inevitably when discussing great code someone will say, “But what if you need code right now, and you are willing to sacrifice quality in order to get work done faster?”



Google Chrome 2.0 Beta Released

OS News announced yesterday that Google Chrome 2.0 Beta was just released. I’ve been searching for the perfect browser for my new Acer Aspire One for a couple of weeks now and ended up settling on the stable version of Chrome. It works well because:



Simple C++ String Conversions

The boost::lexical_cast<> utility is a handy way of converting objects to and from strings, providing a mechanism that many scripting languages have built in. lexical_cast works with any C++ type that has ostream and istream operators defined for it, that is, any object that cout << object; or cin >> object; would work with. This boost facility also does intelligent things such as throwing a bad_cast exception if the operation causes an error flag on the stream to be set. I use boost::lexical_cast<> throughout my code at work for things like serialization of objects for human readable communications. It is also sprinkled liberally throughout my code for handling things like quick debug logging:



Reflections on Trusting Trust - by Ken Thompson

In 1984 the Communications of the ACM published an article, Reflections on Trusting Trust. Which is an amazing, and disturbing read about software trust. The article begins with the exercise, “create a program which can replicate itself.” This leads deftly to the idea of modifying a compiler such that every time code is compiled it adds a security vulnerability. The author points out that this kind of problem in a compiler could and would be found rather quickly. However, it takes a compiler to compile a new compiler.



Formatting a Comma Delimated List Redux

A few weeks back, I posited the question, “What is the best way to format a comma delimited list?” After seeing all of the succinct ways to accomplish this in other languages, I got a little jealous and decided to write this C++ algorithm which acts about the same. I feel like there must be a c++ standard library way of doing this that I’m some how overlooking.



Real World Haskell: Chapter 4

Chapter 4 of Real World Haskell begins with some details about functions with side effects and interacting with the outside world. Normally, a Haskell function is pure and may not have any side effects outside of itself. However, it is necessary to allow for side effects for reading and writing files, including standard input and output. The “do” keyword is used when we may have interactions with the outside world.



Programming Puzzle: What is the best way to format a comma delimited list?

Say you have a list, array, vector, storage format doesn’t matter:



Templated Constructors in C++: Using the "explicit" Keyword

Sometimes, in the course of C++ template based programming it might be desirable to have a constructor that is templated, like the following contrived exampled:



Prefer .at() to [ ] When Accessing C++ Vectors

I’m sure I will get some dissenting views posted in comments regarding this, but I just came to this conclusion while trying to track down a memory bug in the past few days. First of all, what’s the difference? Take the follow code to set up our scenario: