I have written a lot of C++ code in the last year or so. The C family of languages have types that will vary in size depending on the OS and the CPU.

I thought my Macs had 32-bit CPUs because the “long” type uses 32 bits. Why would Intel sell 32-bit CPUs to Apple? I did not care for the answer.

However, my current work is very sensitive to the CPU word length. So I decided to look into the matter. Turns out that Apple is buying standard 64-bit processors from Intel. But somehow, the C compiler defaults to 32-bit binaries.

Thankfully, the fix is easy. Go from…

g++ -O2 -o test test.cpp

to…

g++ -O2 -m64 -o test test.cpp

For some code I wrote, this meant running twice as fast!

Disclaimers: 1) I have not checked whether the same thing is still true with MacOS 10.5. 2) You might encounter some difficulties if you try to link a 64-bit executable with 32-bit libraries. 3) I am not claiming that your software will run twice as fast with 64-bit words.

There is, I believe, a tension between management and innovation. Innovation is fundamentally disruptive. There is plenty of evidence that too much order is a bad idea:

However, complete chaos is not productive. What is needed is some form of partially controlled chaos. The solution? Embrace some chaos, seek diversity! But keep your basic sane routine intact.

If you are a researcher, I have a challenge for you: once a year, work on a project and publish a paper that is crazy. It can be a project outside of your normal field of expertise. In any case, it should raise some eye brows. If you have tenure or a similarly stable job, why would you not? You will not get fired for writing one crazy paper a year. But it may greatly enhance the biodiversity of your ideas.

If you are a software designer, design one totally crazy software application every year. Write a piece of software that has nothing to do with your own work, or that goes against all principles you normally apply. Finding time for a wild project is not so difficult. The project itself may not be productive, but it may keep you on your toes.

The idea is not to throw away the much-needed regularity that keeps us productive. But please, inject chaos in your life.

Note: Having kids counts as controlled chaos.

We just enrolled our oldest son in some karate lessons. I am not sure how useful this will be, but given that I got regularly in trouble with bad guys in school, I am hoping it will help him a bit.

Would you gang up on this kid?

Lohan fait du karaté

Imagine if you came to my blog and it would load all unread articles. New readers would get a list of 1000+ posts. You would then need to hide each post, one by one.

It would be annoying, wouldn’t it?

Likewise, I am seriously getting annoyed at email and RSS clients. I need a very simple function: if I have not read an email or a RSS post in x days, please take it off from my inbox. Move it into an auto-archive box.

I find it stressful to see all these emails waiting for me! Yes, I know about Inbox Zero, but I get so many emails that just archiving them manually takes too long!

OO helps us hide away the routine problems and the makes the code easier to use. Among the first things you learn with class-based object-oriented (OO) languages like Java and C++ is how to use inheritance. Inheritance is a form of taxonomy for programmers. It makes great-looking diagrams. Pedagogically, it makes type polymorphism easy to understand.

However, I will tell you a little secret: cool programmers do not use inheritance, except maybe to derive new classes from the standard classes provided by the language. Inheritance tends to make code more difficult to maintain. In some cases, inheritance makes software slower.

The better alternatives are:

C++ :
Use templates, they are both faster and easier to maintain than class inheritance.
Java :
Use interfaces. Java interfaces are a bit annoying to maintain, but they do not contribute any bugs.
Python, Ruby, Objective-C, Perl, JavaScript/ECMAScript :
Use duck typing.
« Previous PageNext Page »

Powered by WordPress