Monday, June 11, 2007

BOOL != BOOLEAN != VARIANT_BOOL != bool

I have a background in Java and Linux system programming in C. Currently, though, I've been working in Windows on a USB driver.

I must say that Windows driver development in WDF isn't that bad. WDF is well documented and once you "get it", it is quite nice. I've also had a chance to directly ask question from engineers that built WDF and they are very smart people.

Then there's the not-so-smart-people. I think they designed Visual C++.

I just have to say that once you touch Visual C++, you cry back to Java! Documentation on MSDN regarding Visual C++ is incomplete, hard to navigate and poorly written. I found function calls that were not documented in MSDN and the ones that were, didn't compile (I have old code to work with and probably there is a "logical" explanation to this, but to me it seems very frustrating...).

And what's with the VARIANT data type!? It seems to be the greatest kludge of all time! A data type which type you define my setting a constant - I mean WTF! Just take a look at this: http://blogs.msdn.com/oldnewthing/archive/2004/12/22/329884.aspx

I get back to this topic once I manage to parse my XML and things seems to work :) Then I can probably say some nicer thing about, this so (in)famous, Visual C++.

5 comments:

Anonymous said...

If VARIANT is such a kludge, how would you have represented variable-type data? Even the Pascal language does it with a discriminant.

Kypeli said...

Hi Raymond,

Thanks for your comment! I would have represented variable-type data like I would in ANSI C or even Java; for example create an appropriate data structure/object class of what I want to represent if basic data types aren't enough :)

Anonymous said...

But what is "an appropriate data structure" for something that needs to be able to represent an integer, a floating point number, a boolean, a string, an array, or a timestamp (or any of the other dozens of types that can be stored in a VARIANT)? Remember, the purpose of a VARIANT is to represent a value in a loosely-typed language.

Kypeli said...

Aren't those kind of types exactly ones that are already defined elsewhere, outside VARIANT, like any other datatype? Why use VARIANT in the first place? Use of VARIANT just seems like bad design.

I am sorry, but as you probably can read, I am new to Visual C++. The problem I have with VARIANT is that C is also (even more so) a loosely-typed language and there is no need for a VARIANT typed structure there. If you call a function, or get a result, you should always know what to pass/what you get as result so the need for a type like VARIANT is questionable to me.

And if Visual C++ is C++ on some level, the whole idea seems evem more crazy to me because as far as I know, C++ has classes :)

Anonymous said...

You're taking a language-centric approach to a cross-language problem. Sure C++ classes are great if you're working with C++, but, as I noted, VARIANT is for representing values in a loosely-typed language. A language like JScript or VB. How would you represent a variable in JScript or VB?