Saturday, April 8. 2006

I updated the Serendipity software that runs this website for the first time ever. My main
intention was to block blog spam comments using captchas. This didn't
work at all though because "Warning: ImageTtfText: No TTF support
in this PHP build". Looks like I'll keep deleting spam comments manually in the near future.

Here's a list of things the upgrade broke or fixed:

- Some BBCodes/HTML tags broke in existing entries. I'll fix the problems as soon as I see them.- The search function works now. Google is still better though.- I now have a cool WYSIWYG editor to write my posts. This should take care of my earlier formatting problems.- I temporarily enabled the Top 10 referer list again. I promise it's going to take only a few days until it's filled up with porn spam links though.

If you find other problems with the website please post a comment to this entry.

Template meta-programming in D seems to be way superior to template meta-programming in C++. One major advantage is the ability to use string literals as template parameters. This is not possible in C++ (unless you mark the string literal as const extern, which makes it pretty much useless).

Why is this a major advantage? Because it allows me to write something I've wanted to write for a few years: A template meta-program which encrypts strings at compile-time. That way you have the readable string in the source code and the encrypted string in the binary.

D templates are furthermore significantly cleaner than C++ templates. Here's my crypt template. The encryption just adds a constant value. In the complete sample source code the value 13 is added. That makes the encryption kinda like ROT13, just without the rotation part. The static if is built into the language whereas you have to rely on template trickery to achieve the same thing in C++. That's another advantage I think.

The output of the program is the encrypted string Sv{nyyå9-üuvÇ-vÇ-ä|¦xv{t. This string can also be found in the binary.

Nevertheless template meta-programming in D has some weaknesses too. The makechar workaround (see the complete source code) which I took from here is necessary because you can't concatenate arrays in declarations. Let's see what other problems I'll face in the future.

D template meta-programming is moderately well documented. Additionaly to the link above you can check out this site too. Using Google you can search through the D newsgroups and find other related posts.