Feeds

C++/CLI: a paradigm too far

Microsoft's new albino jumbo

5 things you didn’t know about cloud backup

No denigration without substantiation

To see why, let us a take a step back. C++ is notoriously complex. Whereas smaller computer languages have features designed into them, C++ is unusual in having a whole swathe of functionality discovered, like a tract of 19th century Africa. Nobody intended that C++ should support template metaprogramming, a wildly clever but visually dismal technique that allows the programmer to write a program within the program. One day it was noticed that it could be done, and now it is done.

Microsoft has taken this giant of a language, clamped it down on the target platform of their linguistic accelerator, and bombarded it with .NET fragments travelling at 10,000mph. The resulting 'tuple' (to use Stan Lippman's word, perhaps chosen because Boost doesn't yet offer a 'chimera') is the aesthetic equivalent of the monster in the original Quatermass - a man with one arm melted into a cactus plant.

Consider the issue of pointers. Pardon me while I instruct you briefly in ovoid evacuation by vacuum, Grandma. C++ offers two basic kinds: the common-or-garden kind, represented by a *, and the reference kind, that you aren't supposed to think of as a pointer until you must, represented by a &. Famously a source of confusion for novice programmers, and, cough, their elders can occasionally come unstuck too. One problem is: two kinds is really one too many. The superfluity steams up the lens.

But these constructs don't work in the safety-scissors-and-glitter .NET world, where ordinary pointers are usually concealed beyond reach. So with C++/CLI you get two more kinds in the packet, represented by ^ and %, which approximately map .NETty things on to the traditional * and &. So suddenly you've got parallel sets of pointy things, governed by different rules. Oh, great.

But it's not just pointers. There are special declarations for all the .NET classes and structs and interfaces. There is a new kind of generic mechanism. There are arrays that nearly behave like std::vectors... but not quite. If you are fond of destructors, there's now an extra one with a ! in front of it that your object gets long after death, when it has served its term in purgatory. And heaps extra - well, one heap anyway. Go look for yourself.

Another thing. Here are some demonstrative fragments of code from the same Lippman article, comparing C# and C++/CLI syntax for class declaration.

abstract class Shape { ... } // C#
ref class Shape abstract { ... }; // C++/CLI
struct Point2D { ... } // C#
value class Point2D { ... }; // C++/CLI

Notice anything? The C++/CLI version is just a little bit more wordy and clumsy than its C# equivalent; because its 'spaced' keywords have to be squeezed into the cracks. Use a .NET feature, you pay a cruft tax.

C++/CLI isn't a natural extension of C++; rather it is a dual gauge system. The detritus from two incompatible programming models is crammed uncomfortably into one space. The thing to remember about dual gauges is that, while any fool can do a straight bit, it's the points that will eventually put paid even to a Brunel.

Microsoft must run on its dual gauge system if it is to make a success of Windows Vista. But we don't.

If you need to write for .NET in a curly brackets language, may I suggest you try C#? It's focused and elegant and fits snugly into its design hole - just right for those webby-databasey back end apps that define, to Microsoft's irritation, the .natural .NET .niche.

And if you need to come back to something that runs a little edgier, and is more widely scoped, and lets you blow your leg off whenever you want, then C++ will still be there for you out here in the real world. Promise. ®

Gartner critical capabilities for enterprise endpoint backup

More from The Register

next story
Why has the web gone to hell? Market chaos and HUMAN NATURE
Tim Berners-Lee isn't happy, but we should be
Linux turns 23 and Linus Torvalds celebrates as only he can
No, not with swearing, but by controlling the release cycle
Apple promises to lift Curse of the Drained iPhone 5 Battery
Have you tried turning it off and...? Never mind, here's a replacement
Sin COS to tan Windows? Chinese operating system to debut in autumn – report
Development alliance working on desktop, mobe software
Eat up Martha! Microsoft slings handwriting recog into OneNote on Android
Freehand input on non-Windows kit for the first time
This is how I set about making a fortune with my own startup
Would you leave your well-paid job to chase your dream?
(Not so) Instagram now: Time-shifting Hyperlapse iPhone tool unleashed
Photos app now able to shoot fast-moving videos
prev story

Whitepapers

A new approach to endpoint data protection
What is the best way to ensure comprehensive visibility, management, and control of information on both company-owned and employee-owned devices?
Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Maximize storage efficiency across the enterprise
The HP StoreOnce backup solution offers highly flexible, centrally managed, and highly efficient data protection for any enterprise.
How modern custom applications can spur business growth
Learn how to create, deploy and manage custom applications without consuming or expanding the need for scarce, expensive IT resources.
Next gen security for virtualised datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.