Tuesday, July 24, 2007

Xtreme Toolkit's TaskPanel

So Codejock has done what I thought someone should do, make a generic, all Windows versions version of the Task Dialog. It's not perfect (points off for putting your copy of the structure definitions in effectively the global namespace), but it's pretty good.

Monday, July 9, 2007

Bootstrapper for installs is cool

This is cool:

http://msdn.microsoft.com/msdnmag/issues/04/10/bootstrapper/
http://blogs.msdn.com/chrsmith/rss_tag_Bootstrapper+awesomeness.xml

Basically, it's a installer builder for Visual Studio with which you can set dependencies on other modules, which are packaged for the bootstrapper (eg: versions of the .NET framework). When your installer runs, the bootstrapper will verify the installation of the component (including version) you need, and if it's not present, automatically download and install it, before your installer even runs.

What's cool about it (versus just packaging in the MSI's for the dependent components) is that you don't bloat your installer very much (bootstrapper is about 500k), but you get virtually the same effect, due to auto-downloading. Very cool.

Friday, July 6, 2007

Some people are dumb

So the /. FotD is bashing on the MS proclamation that their vouchers for Novell to distribute linux do not entitle the redeemer to any software licensed under GPLv3. For reference, see:

http://www.microsoft.com/presspass/misc/07-05statement.mspx
http://linux.slashdot.org/article.pl?sid=07/07/06/1333257

Now for their part, MS is being fairly smart. The recognize that GPLv3 is crafted to screw them, and are trying to preemptively disclaim any distribution of GPLv3 code. Basically, if you get linux with a MS voucher, your not getting the right to use anything licensed under GPLv3; a perfectly valid condition to impose.

Enter the dumb zealots, claiming that this is tantamount to MS declaring the law itself invalid by fiat. It's kinda like the fanatics who don't understand that their religion is opposed to killing people... have you guys even read the GPL, or is it just the magic anti-Microsoft golden idol in your minds?

MS doesn't want to distribute GPLv3 code, cause GPLv3's patent provisions are counter to everything MS wants to preserve with their IP (on purpose). They cannot be forced to distribute GPLv3 code; the law just doesn't work that way, as much as the zealots at FSF would like to change it by fiat.

Thursday, July 5, 2007

Breaking polymorphism with templates

Intriguing title, huh?

So here's the issue. Say I want to have a collection of objects, each of which is an instance of a template class (with various template types). Not going to work, you say, cause each template typed version of the object is a different type, and you can't have a collection of different types, unless they are derived from a base type. Fine, no problem, I can have a non-templated base type as the pointer type for the list; something like this simplified example code. Now the fun starts...

class CBaseClass
{
public:
    virtual ~CBaseClass();
};

template< typename TYPE >
class CSubClass : public CBaseClass
{
public:
    TYPE m_tValue;
};

Say I want to get the value from an element in the list, where the type of the value is the template type of the subclass of the actual object instance. Simple enough conceptually, but wait... there's an issue. Iterating the list give me pointers to the base class, and I need to call a method which is explicitly or implicitly aware of the subclass type. And here we come to the quintessential example for polymorphism: CShape, CSquare, virtual void Draw(), etc.

So I just add a virtual method, specify the type I want to get out as a template parameter, override it in the subclass, return m_tValue, and we're done, right? Something like this, for example:

class CBaseClass
{
public:
    virtual ~CBaseClass();

    template< typename TYPE >
    virtual TYPE GetValue() = 0;
};

bool bHappy = pBaseClass->GetValue< bool >();

Um... see, here's where C++ is kinda broken. You can't have a template virtual method, it's not allowed.

... So how can we get m_tValue, when all we have is a CBaseClass*?

Coding gymnastics, using RTTI, explicit type lists, a whole crap load of ugly, runtime-check-only template code, and very limited extensibility / flexibility. Basically, breaking the whole point of templates and polymorphism. Seriously, the code is simpler if you have one class with a void*, a size, and an enum for the type in it, and you forget about virtual functions, templates, or anything fancy designed to eliminate the need for void*'s, sizes, and explicit runtime type storage.

Somebody in the C++ committee should seriously look at this, figure out a good solution, and fix the standard, cause it's broken.

Microsoft API's blow sometimes

So I'm calling UpdateLayeredWindow to do transparency effects, and it's failing with no error code set. Turns out it seems to be an issue with running the app through Terminal Services. Would have been nice for Microsoft to actually produce a useful error code, like, say, I dunno, "this API is broken with Terminal Services cause our coders didn't finish it" or something. Kinda like the multi-threaded apartment version of the IShell interface in Windows XP (oops, we ran out of time, sorry).

Seriously, people... documentation, it's what makes a platform usable for developers.