News for hackers. Stuff that matters.
Re:C++ killed my grandpappy - Is C++ hard and where are the ... by strlen on Tuesday June 29, 2010 @05:33AM (#1470908)
There's many reasons to criticize C++. None of them have to do with whether it's "managed" or not. Whether to use a "managed" (i.e., garbage collected and unable to perform unsafe memory access) language is an orthogonal issue; applicability of either approaches depends on the problem at hand. Some problems can't be solved without raw memory access, other problems can be solved but only at great performance and reliability cost, others don't benefit significantly from either approach yet others are dangerous or difficult to solve without memory management.

The real criticism of C++ is that it's an accidentally complex language (1) built by multiple warring tribes: one that wanted object orientation, the other that wanted static typing, yet another that wanted generic programming. What happened is that all of them won. Nonetheless, there is likely more than just a social reason no other language emerged for (relatively) high-level systems (2) programming (not that it hasn't been tried e.g., Modula-3 and most recently -- and promisingly -- Go). The only real alternative seems to be "C with objects" (e.g., glib or VFS layer in the Linux kernel).

That, however, still has nothing to do with what the article is about: is it me, or are the Windows C++ APIs just horribly designed? Qt, while far from perfect, is a just a lot easier to program to.

(1) It's fine for a language to be complex for a reason. Haskell is complex, yet that's because it's based on a very different paradigm which brings many advantages to the table. C is necessarily more complex than Python because it's meant to make systems programming possible.

(2) Nonetheless the domain of systems programming (which I'm going to ad-hoc define as something that requires dealing with memory addresses, the OS kernel and physical hardware) is shrinking. It's now possible (in terms of getting great performance) to write a database or a distributed lock manager in Java or a web server in Python or Ruby. So I am going to use "systems programming" here to mean operating system, driver, embedded, etc... development.

Re:C++ killed my grandpappy - Is C++ hard and where are the ... by ComputerGuru on Tuesday June 29, 2010 @06:29AM (#1470971)
> is it me, or are the Windows C++ APIs just horribly designed?

There's your problem right there! Windows does NOT have an C++ APIs (if you put COM aside). They're all legacy plain-C APIs and they're difficult to fathom in our increasingly object-oriented world.

Keeping in mind backwards compatibility and isolation of memory management (no objects or memory allocations are passed across memory boundaries due to architectural reasons in the Windows platform itself and not due to the design of the API) between libraries, the Win32 API is actually remarkably well designed.

You've got C-based declarations for literally a hundred thousand functions, each with varying functionality depending on what you want to use it to accomplish. And it preserves backwards compatibility. And it has managed to keep up with the latest tech and features. Plus, half-way through, they went ahead and re-implemented each and every function in a Unicode version while keeping the old ASCII version fully available.

I used to think the same. I used to look at Win32 and groan. But when I realized the extent of its complexity, the domain constraints it was under (OS design, DLL isolation, etc) the requirements (backwards compatibility, static functions for literally everything).. it all made sense.

What gets me is new languages that have way worse problems without the same good reasons. Take a look at PHP and its strlen vs str_pad (why _ sometimes and sometimes no?) and its str_replace(needle, needle, haystack) vs strstr(haystack, needle)... that's uncalled for, badly designed, and with no excuse.

Re:C++ killed my grandpappy - Is C++ hard and where are the ... by alextingle on Tuesday June 29, 2010 @06:59AM (#1471008)
The WinAPI is horribly designed. The choice of language has nothing to do with it. A plain C API can be a joy to work with (e.g. pthreads, or any POSIX API). There is just no excuse for the myriad of WinAPI functions that take 13 parameters in random order, most of which need to be set to 0, -1 or NULL to get it to work.
Re:C++ killed my grandpappy - Is C++ hard and where are the ... by ajuc on Tuesday June 29, 2010 @08:25AM (#1471135)
The excuse is backward compatibility, and it is also why linux binaries from 3 years ago doesn't work on new linux, and win32 binaries does (or at least did before vista age).

PS I prefer linux way (clean the api, no matter old binaries), but that's because I'm programmer, as a user I would love to just download old binary from net and have it work without worrying about dependencies.

Re:C++ killed my grandpappy - Is C++ hard and where are the ... by jussij on Tuesday June 29, 2010 @08:41AM (#1471169)
I was amazed to find that a version of the Zeus editor dating back to 1995 still runs fine on Windows 7 and that software is not even Win32. It's written in Win16.

And here is the link to prove it: http://www.zeusedit.com/z300/zeus-v103.zip

Re:C++ killed my grandpappy - Is C++ hard and where are the ... by ajuc on Tuesday June 29, 2010 @08:53AM (#1471194)
My last windows was xp, bu I've heard win7 was supposed to have virtual machine with winXP to run older program. If so, this is cheating :)
Re:C++ killed my grandpappy - Is C++ hard and where are the ... by ComputerGuru on Tuesday June 29, 2010 @10:28AM (#1471494)
Not really. You need to separately install the XP Virtual Machine software on Windows 7. He means it actually runs "out of the box."

(Windows 7's XP emulation mode is nothing like the super cool Rosetta on OS X)

Re:C++ killed my grandpappy - Is C++ hard and where are the ... by angstrom on Tuesday June 29, 2010 @09:25AM (#1471286)
I worked on a popular medical imaging application that was released with Win95 support and still working with Vista/Win7. That's some impressive longevity. Mind you there were adjustments along the way to support newer DirectX libraries etc. but the rest of the application was able to compile fine.
Re:C++ killed my grandpappy - Is C++ hard and where are the ... by ajuc on Tuesday June 29, 2010 @02:31PM (#1472295)
To compile fine is one level, the other is to run fine without recompiling - it's easy to break binary compatibility - http://techbase.kde.org/Policies/Binary_Compatibility_Issues...
Re:C++ killed my grandpappy - Is C++ hard and where are the ... by daemin on Tuesday June 29, 2010 @07:47AM (#1471058)
Well while it may not have an explicit C++ interface, I've found that you can go very far using ATL & WTL. These form a very nice and thin C++ wrapper to the Win32 API and also give you some handy smart pointers and STL container adapters. I've used ATL & WTL with STL and Boost with no problems.
Re:C++ killed my grandpappy - Is C++ hard and where are the ... by DanielBMarkham on Tuesday June 29, 2010 @07:24AM (#1471036)
There's your problem right there! Windows does NOT have an C++ APIs (if you put COM aside). They're all legacy plain-C APIs

Ah. This brings back memories of checking to make sure the linker is de (or was it re) mangling the API names to make them work with C++

I've coded in C and C++ against the Win APIs. In fact, once I learned C, moved to windows (yay Petzold!) my first windows app was in Borland, home-grown C++ against the win api. Then I moved to OWL, then MFC.

One of the tough things about the C/C++/Win learning path is this: although it's probably 1/3 of the optimum shit to learn (functional programming, compilers, and algorithms are the another third, and set theory and databases the final third) it's also a freaking long haul from int a = 0; to Win COM programming. (And having said that I remain a C++ fan)