Is there any uglier code than windows C++ code?
It just gives me a headache every time I have to look at it. And when did this great wide character conversion happen? All this code I am trying to use won't compile because the calls are now all wide instead char.
At least they're not using "Hungarian" notation any more, right?
Yeah, I think "Hungarian" notation leads to some ugly code.
You should be using the _T macros to deal with the wide-chars.
And yes, you're right. It's really ugly.
March 23rd, 2007 1:49pm
The complete lack of elegance pervades many Microsoft APIs as well. Compare OpenGL with DirectX as a good example.
Pfft! "Lack of elegance" indeed. They're clunky, with too many structures, which are too large. And most calls have a "security" structure associated with them, which may or may not be required, and may or may not even be used.
And all those 'hidden' side-effects. And you sum this up as "Lacks elegance"? Well, sure it lacks elegance, whatever that means.
Sheesh, it's 16:00, I'm gettin cranky.
I have never coded in C++ for Windows (other platforms, yes, but never Windows). Everytime I try and start I just look at all the bullshit and just think "fuck it" and fire up Visual Basic.
It amazes me sometimes that the most popular operating system in the world has seemingly the worst possible API.
"Compare OpenGL with DirectX as a good example."
Your point would only be valid for older versions of Direct3D, as it has got a hell of a lot better over the years. John Carmack (aka Mr. OpenGL) himself, who once publically stated that he would not develop in DirectX and would use OpenGL instead, said this in a recent interview:
"GI: Since you’re moving ahead with the new technology within the Doom 3 engine, you’re not worried about adopting that for DX10?
Carmack: No, because the DX9 stuff—actually, DX9 is really quite a good API [application programming interface] level. Even with the D3D [Direct3D] side of things, where I know I have a long history of people thinking I’m antagonistic against it. Microsoft has done a very, very good job of sensibly evolving it at each step--they’re not worried about breaking backwards compatibility--and it’s a pretty clean API. I especially like the work I’m doing on the 360, and it’s probably the best graphics API as far as a sensibly designed thing that I’ve worked with."
I do C++ for windows every day. I'm used to it now, I even appreciate the small amount of elegance in MFC and COM, but my initial reaction was the same - I couldn't believe how godawful ugly it was.
>Your point would only be valid for older versions of Direct3D, as it has got a hell of a lot better over the years.
Well, sure - DirectX got better over the years, eventually achieving an 1997 OpenGL-like straightforward elegance by DirectX 10 (and no, elegance doesn't need to be defined, or "quoted". It's pretty fucking clear when something is elegant, and when something is layers of obtuse layers atop layers for no advantage). So yeah, I guess I am wrong.
> I couldn't believe how godawful ugly it was.
It's pure and total line noise. I see code like _tprintf. TEXT(). LCW whatever. I total lack of encapsulation. Doe anyone in MS land ever use string? It's all buffers sprintf. It's all plumbing code and very little useful encapsulation.
"Well, sure - DirectX got better over the years, eventually achieving an 1997 OpenGL-like straightforward elegance by DirectX 10 (and no, elegance doesn't need to be defined, or "quoted"."
Actually, DirectX 8 vs. OpemGL was essentially a wash, and started to get better by DirectX 9 - long before 10. Also DirectX 10 is not nearly as straightforward as OpenGL circa 1997 (i.e. 1.1), as it has more features and uses a shader pipeline, as opposed to the fixed-function pipeline of the old days. One of the main reasons OpenGL progressively lost ground is because its extension mechanism, along with the long standard approval process, made it difficult to support advanced features across cards by different vendors in a single code path.
As for the several "obtuse layers" in DirectX, you have to remember that OpenGL is a graphics API and nothing more, while DirectX really is a multimedia application development API. They really were designed with different goals in mind. This for example explains why the DirecX distribution includes goodies for optimized 3D math, model loading, etc., which would not be included if the API was intended for pure graphics work.