Feeds

C++/CLI: a paradigm too far

Microsoft's new albino jumbo

Providing a secure and efficient Helpdesk

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. ®

New hybrid storage solutions

More from The Register

next story
'Windows 9' LEAK: Microsoft's playing catchup with Linux
Multiple desktops and live tiles in restored Start button star in new vids
Not appy with your Chromebook? Well now it can run Android apps
Google offers beta of tricky OS-inside-OS tech
New 'Cosmos' browser surfs the net by TXT alone
No data plan? No WiFi? No worries ... except sluggish download speed
Greater dev access to iOS 8 will put us AT RISK from HACKERS
Knocking holes in Apple's walled garden could backfire, says securo-chap
NHS grows a NoSQL backbone and rips out its Oracle Spine
Open source? In the government? Ha ha! What, wait ...?
Google extends app refund window to two hours
You now have 120 minutes to finish that game instead of 15
Intel: Hey, enterprises, drop everything and DO HADOOP
Big Data analytics projected to run on more servers than any other app
prev story

Whitepapers

Secure remote control for conventional and virtual desktops
Balancing user privacy and privileged access, in accordance with compliance frameworks and legislation. Evaluating any potential remote control choice.
Saudi Petroleum chooses Tegile storage solution
A storage solution that addresses company growth and performance for business-critical applications of caseware archive and search along with other key operational systems.
High Performance for All
While HPC is not new, it has traditionally been seen as a specialist area – is it now geared up to meet more mainstream requirements?
Security for virtualized datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.
Providing a secure and efficient Helpdesk
A single remote control platform for user support is be key to providing an efficient helpdesk. Retain full control over the way in which screen and keystroke data is transmitted.