Monday, October 15, 2007

COM attributes, C++, and MS's fail

Attributes... simplified programming model, hides the complexity of COM, allows easy specification without obscure syntax, must be a good idea, right? Nope, FAIL.

The problem lies in the failure of documentation and ubiquitous support for the other MS libraries. Specifically, are you using MFC (and really, most native C++ Windows programmers probably are, duh)? Sorry, attributing breaks your application. Not that you could tell, since converting to attributed leaves all the other files in the project, and creates new hidden files with the current interfaces. Um... UTTER FAIL.

Not to mention the attributes themselves. How do they work? Oh, don't worry about that. Where can I see the source? You can't, it's compiled into DLL's which inject it. How can I see what it's generating? Compile with a special flag, and look for the hidden, undocumented files it might generate. How can I debug issues? Um... online support forums maybe? UTTER FAIL.

Nothing pisses off native developers like not being able to see what's going on. Over 50% of why people stay native developers is a lack of faith in the ability to diagnose and fix problems because the lower level code will be too hidden to figure out what's going on. What could be better to convince these developers to go managed than introduce some managed-like syntax and show how easy things could be? Except the syntax (attributes) exemplifies the exact reasons why those programmers haven't adopted managed code, and solidifies their decision to stay native as the correct one. Two words for MS: UTTER FAIL.

I'm done with attributes for COM objects. Yes, IDL and ATL are hideous, but gobs of hard to read code is better than not being able to fix problems or understand what's going on. You can take that as a free mantra whenever you take the next pass at trying to convert native developers to the next big thing.

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:

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:

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
    virtual ~CBaseClass();

template< typename TYPE >
class CSubClass : public CBaseClass
    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
    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.