Three jewels

This one is, I guess, going to be another classic in a few years. Andrei Alexandrescu stated in comp.lang.c++.moderated:
Well, for my money, using iostreams already puts the code in a low quality bracket :o).

The thread was about how people are dogmatic regarding the goto statement, so here are two more links:


Subverting the GPL (again!)

If you use some GPL code in your program and you distribute that program, than you also must make the program source available. A fun thing would be to comply with the GPL, but publish the source code of the parts of the program that you wish to keep "secret" in obfuscated form.

Here's a relatively easy way to do it: put "proprietary" parts of your code into separate source files, compile them to object code and decompile the object code back to "source". "Nice" decompilation is of course impossible. But we don't want nice - we can just generate code full of gotos, primitive machine instructions, and variable "names" which correspond to the variable's address in memory after the program is loaded.

I think that it would work, because the license states only "Accompany it with the complete corresponding machine-readable source code..." Such source code is undeniably machine-readable (and even compileable!), and it seems that distributing a "proprietary" program in such form would comply with the license.



Another look on climate change

"This has been the warmest winter ever", "We must reduce CO2 at all costs", etc. You can hear such things pretty often today. But take another perspective: the global warming, which caused the warmest winter 'ever' (highly doubtful), also saved huge amounts of energy that would otherwise be spent on heating. Less energy used on heating means less generated CO2 this winter. Why doesn't anyone mention that?


Hungarian notation

You have probably heard that hungarian notation is awful and that it should be avoided. However, in most of the Windows APIs, the notation has been misused. The intention behind Simonyi's notation is akin to dimensional analysis. I recommend you to read this article as well as Simonyi's original paper.

While having a good intention behind it, the idea is actually just a fix for a defficient language, namely C and C++. If typedef were not a mere type alias, but a true new type, this convention would be (almost) unneccessary as the compiler could catch all errors. For example:

typedef int Temperature;
typedef int Volume;

int f(Temperature a, Volume b)
return a+b;

Although it is meaningless to add temperature and volume quantities, this is perfectly legal C and C++ code, because Temperature and Volume are mere aliases for int.

C++ templates have strict compile-time type-checking, but the syntax is unfortunately just horrendous.