Blog Archives

I disagree with Linus Torvalds about C++

I heard about this note from Linus Torvalds from David Wolever yesterday. Here’s Torvald’s opinion of C++. C++ is a horrible language. It’s made more horrible by the fact that a lot of substandard programmers use it, to the point

Tagged with: ,
Posted in Software development

Has C++ jumped the shark?

Bjarne Stroustrup, creator of C++, wrote an article for Dr. Dobbs recently lamenting the decision to cut “concepts” from the upcoming revision of the C++ standard. His article left me with the feeling that C++ had jumped the shark. The

Tagged with: ,
Posted in Software development

Two perspectives on the design of C++

Here are two complementary (but not entirely complimentary!) blog posts about C++. Roshan James has a scathing article about C++. When asked to recommend books on C++, he replied that he doesn’t recommend C++. He explains how the best C++

Tagged with: ,
Posted in Software development

Troubleshooting C++ TR1 problem in Visual Studio 2008

Patrick Getzmann and I have been exchanging email about a problem he had using some sample code I’d written for working with regular expressions in C++. I wasn’t much help, but Patrick figured it out. I wanted to post his

Tagged with: ,
Posted in Software development

Functional programming in C++ with function objects

Here’s something I do all the time. I have a function of one variable and several parameters. I implement it as a function object in C++ so I can pass it on to code that does something with functions of

Tagged with: , ,
Posted in Math, Software development

Computing the inverse of the normal CDF

Someone asked me this week for C++ code to compute the inverse of the normal (Gaussian) distribution function. The code I usually use isn’t convenient to give away because it’s part of a large library, so I wrote a stand-alone

Tagged with: , ,
Posted in Math

Five tips for floating point programming

I have a new article on CodeProject: Five tips for floating point programming The article discusses how to avoid some of traps that people often fall into when working with floating point numbers.

Tagged with: ,
Posted in Software development

Free C# book

Charles Petzold is a highly respected author in Windows programming circles. For years, his book was THE reference for Win32 API programming. I knew he had since written several books on .NET programming but I didn’t realize until I listened

Tagged with: , , ,
Posted in Software development

How to compute standard deviation accurately

ThThe most convenient way to compute sample variance by hand may not work in a program. Sample variance is given by If you compute the two summations and then carry out the subtraction above, you might be OK. Or you

Tagged with: ,
Posted in Math

NaN, 1.#IND, 1.#INF, and all that

If you’ve ever been surprised by a program that printed some cryptic letter combination when you were expecting a number, you’ve run into an arithmetic exception. This article explains what caused your problem and what you may be able to

Tagged with: ,
Posted in Software development

Multiple string types: BSTR, wchar_t, etc.

This morning I listened to a podcast interview with Kate Gregory. She used some terms I hadn’t heard in years: BSTR, OLE strings, etc. Around a decade ago I was working with COM in C++ and had to deal with

Tagged with: , ,
Posted in Software development

Random number generation in C++ TR1

The C++ Standard Library Technical Report 1 (TR1) includes a specification for random number generation classes. The Boost library has supported TR1 for a while. Microsoft released a feature pack for Visual Studio 2008 in April that includes support for

Tagged with:
Posted in Software development

C++ templates may reduce memory footprint

One of the complaints about C++ templates is that they can cause code bloat. But Scott Meyers pointed out in an interview that some people are using templates in embedded systems applications because templates result in smaller code. C++ compilers

Tagged with: ,
Posted in Software development

Programming language subsets

I just found out that Douglas Crockford has written a book JavaScript: The Good Parts. I haven’t read the book, but I imagine it’s quite good based on having seen the author’s JavaScript videos. Crockford says JavaScript is an elegant and

Tagged with: , , ,
Posted in Software development

Porting Visual C++ code to Linux/gcc

Here are a few lessons learned from porting a numerical library recently from Windows/Visual C++ to Linux/gcc. Some of our code only runs on Windows, and only needs to run on Windows. Our first thought was to put #ifdef WIN32 directives around

Tagged with: , , ,
Posted in Python, Software development