Slashdot Mirror


Stan Lippman On Version 2 Of Managed C++

Lansdowne writes "Stan Lippman, one of the founding fathers of C++ and currently a language architect at Microsoft, has prepared an exhaustive translation guide, comparing old Managed C++ to the revised CLI/.NET version of C++. According to Lippman, "There are a number of significant weaknesses in the original language design (Version 1), which we feel are corrected in the revised language design (Version 2).""

40 comments

  1. better colors by Anonymous Coward · · Score: 2, Insightful
  2. Managed C++ and Mono by Qwavel · · Score: 1

    I hope the Mono project will support this?

    I believe that this is a real standard, whereas VB.NET (which Mono supports) is not a standard at all.

    1. Re:Managed C++ and Mono by chochos · · Score: 2, Informative

      I think Mono doesn't even support the current Managed C++ version... only C# and VB.NET. There's mcs, the Mono C# compiler, and mbas, the Mono VB.NET compiler, but there's no Managed C++ compiler, and I think mcs can't compile C++ code...

  3. Ungh, what horrible timing by Dr.+Sp0ng · · Score: 1

    I'm in the middle of a project using a rather large amount of Managed C++ glue to bridge a native C++ library with .NET. Obviously I can't wait until VS2005 is out to use the new syntax, but I'm going to have to redo a lot of it in the future.

    I'm not complaining about the new syntax, though - what I've read about it seems like it's much cleaner and better thought out than the current stuff. I just wish it was here now so I could use it instead of having to rewrite it down the road.

    1. Re:Ungh, what horrible timing by gbjbaanb · · Score: 1

      I'm not so sure anymore, it all looks like a bit of a bodge based on their experiences with V1.

      I mean, things like this:

      In effect, under the revised language design, destructors are once again paired with constructors as an automated acquisition/release mechanism tied to a local object's lifetime. This is a significant and quite astonishing accomplishment and the language designers should be roundly applauded for this.

      If it was so goddamn simple, why didn't they do it in the first fskuing place. Even I thought the compiler could manage this for us, without all that Java-braindead Finalise rubbish, and the IDispose b*ll*cks.

      The spaced keywords and gcnew keyword both sound like nonsense. If the old way of using new and letting the compiler decide whether it was a gc new or a native new worked, why change it now? Which is really interesting as they decided to remove the special keywords in favour of more intuitive ones (which is why the spaced keywords are with us).

      I think this isn't as good as it sounds, and I like C++ and MS development. I wish they'd done it properly (ie by not stealing Java) in the first place.

  4. I don't understand by QuantumG · · Score: 3, Interesting

    Why can't they just change their compiler to generate managed code? Why do they need to change the syntax of C++ at all? In the open source project I work on we use the Boehm garbage collector for C++. So the number one reason to use managed code, automatic memory management, is already available to us. It would be nice if we could just recompile with some settings under VC++ and get a managed version to compare against Boehm. Of course, we'll need to be able to mix safe and unsafe code as our project is a little heavy on the bit manipulation side.

    --
    How we know is more important than what we know.
    1. Re:I don't understand by ConceptJunkie · · Score: 0, Troll

      It's all about Microsoft lock-in. Don't kid yourself otherwise.

      --
      You are in a maze of twisty little passages, all alike.
    2. Re:I don't understand by Anonymous Coward · · Score: 2, Informative

      Why can't they just change their compiler to generate managed code? Why do they need to change the syntax of C++ at all? In the open source project I work on we use the Boehm garbage collector for C++. So the number one reason to use managed code, automatic memory management, is already available to us. .Net is not just about garbage collection. There are many other facets to consider, like properties, value objects, etc. And let's not forget that these enhancements allow you to use either GC or non-GC, depending on your needs.

    3. Re:I don't understand by QuantumG · · Score: 1

      umm.. that's all shit you don't have in the C++ language.. so I guess we could say these are .NET extensions to C++, but can you just recompile C++ to .NET?

      --
      How we know is more important than what we know.
    4. Re:I don't understand by Dr.+Sp0ng · · Score: 3, Interesting

      Why can't they just change their compiler to generate managed code? Why do they need to change the syntax of C++ at all?

      Because running a program under the CLR is quite a bit different than running under a native CPU, and stock C++ doesn't really lend itself to the environment (for example, the CLR does not provide deterministic destructors). Rather than try to shoehorn C++ into a place it doesn't really fit, Microsoft did the right thing and extended the language in a way that makes it fit in with the other .NET languages.

      Plus, without new keywords, how would you specify which classes are garbage collected and which are manually managed? How would you specify class attributes? What about boxing/unboxing? The CLR is a very powerful environment, and I'd rather C++ have the ability to use this power.

    5. Re:I don't understand by Foolhardy · · Score: 5, Insightful
      Maybe because "Managed C++" and "ISO C++" are two entirely different languages? Sure, they may have some syntax in common, but they have almost nothing in terms of purpose, design philosiphy or capibilities in common.

      Managed C++ has less features than ISO C++, namely templates and multiple inheritance.

      You cannot mix code from the two in many ways, like having a class from one inherit from another.

      Sizeof of managed classes is impossible. Managed classes cannot use const or volaitle.

      Managed objects cannot be passed by value; only references or value types. (ISO C++ objects are structs that can always be passed by value)

      Operator delete doesn't work if no user-defined destructor exists in a managed object.

      Managed classes cannot override operator& or operator new.

      A managed object cannot be used as a member in a union.

      Managed c++ does not use unions; instead a complicated field offset system.

      Pointers to objects cannot always be casted in managed C++, pointers of the same size can always be casted in ISO C++.

      Data in managed C++ is zero-initialized. Data in ISO C++ has arbitrary values unless explicitly initialized.

      Managed C++ adds certain members to all classes (as derived from Object), like GetType; all classes derive from System::Object. ISO C++ classes can have no parent class.

      Static sized arrays are illegal in .net

      C-style multiple parameters are not supported; use param array instead

      Normal c++ supports static-only typing. Managed c++ requires dynamic typing, at least to some extent.

      Pointers to members are not supported in any way in managed c++; delegates replace them.

      Normal C++ makes absolutely no library requirements on outputted code; not even the startup library is necessary. Managed c++ requries the entire .net runtime, and requries you to include mscorlib.

      Classes cannot be defined inside of functions in managed C++.

      Any class can be derived from in normal C++. Sealed classes cannot be derived from in managed C++.

      Conversion functions are always static in managed c++. The naming convention is different.

      RTTI is not supported in managed c++.

      Only public inheritance is supported in managed c++.

      Normal c++ explicitly has no garbage collector as part of the language; if you want one, use a library. Managed c++ requires you to use .net's GC.

      The layout of members in a class or struct in normal c++ can always be known at runtime. Managed makes them permanently opaque.

      Removing anything from C++, espescially something as important as templates or multiple inheritance, makes managed C++ a distinctly different language. And this is just a list of some of the things that normal c++ has that managed doesn't. The list of extensions is much longer.

    6. Re:I don't understand by Anonymous Coward · · Score: 0

      Most of these criticisms relate to the fact that Managed C++ runs in a managed environment, meaning that you have to accept the fact that there is a GC provided for you, and the whole baggage of the .Net runtime is required. Anyone who has decided to code Managed C++ should have accepted the baggage before they begin developing. The point of MC++ isn't to completely duplicate C++, but to make it easier for C++ developers to transition to the managed environment, which they've done a pretty good job of.

      I don't think you lose as much functionality going to Managed C++ as you make it sound. Some of the criticisms aren't true (templates are in the latest MC++), or are misleading (C++ style RTTI isn't supported, but Reflection is far more powerful). The biggest missing feature is Multiple Inheritance, though this is somewhat offset by interfaces and delegates. The rest of the differences can be worked around pretty easily, or are features of C++ that were dropped because they are too low level. For the types of apps that MC++ developers will be working on (desktop, server), MC++ is a better fit than C++.

    7. Re:I don't understand by Foolhardy · · Score: 1
      Put up and shut up about the environment? One of my favorite things about normal C++ is that you never have to do that; like C you could write an entire OS kernel in C++, with a few assembly helpers.

      Type templates are going to be available in .NET 2.0 and VS2005. There are no plans to support non-type template parameters.
      I also forgot to mention that pointers to pointers (a pointer to a __gc reference) are illegal in managed C++. That was a pretty big feature of C and C++. (this is due to the fact that .NET references are not objects)
      It's nice that reflection is more powerful but it is still incompatible.
      [...] or are features of C++ that were dropped because they are too low level.
      One of the reasons for programming in normal C++ is because it is very low level. (ever heard 'high level assembly'?)

      I'm not saying that managed C++ is bad, but that it is very different from normal C++. Are managed C++ and C# (.NET) often better for writing your standard Windows app? Yes. Is converting a normal C++ app to managed C++ easy in many cases due to the similarity? Yes.
    8. Re:I don't understand by jgrahn · · Score: 1
      Maybe because "Managed C++" and "ISO C++" are two entirely different languages? Sure, they may have some syntax in common, but they have almost nothing in terms of purpose, design philosiphy or capibilities in common.

      Yeah, but this story was about the C++/CLI language which (unlike "Managed C++"!) is supposed to be compatible with C++ -- until you use one of the .NET-specific extensions, something which will happen pretty soon, I'm afraid.

      One person's positive view here.

      I still don't like this at all. Pascal, here we come!

    9. Re:I don't understand by ConceptJunkie · · Score: 1

      It seems, from what everyone is saying, the answer is no.

      Leave it up to Microsoft who never saw a technology they couldn't "improve" by bloating it beyond all reason.

      Everything MS comes out with is only easier when you use it exactly the way they do. Anytime you want to branch off into something new, you're suddenly faced with practically reverse engineering it to figure out what the heck is going on.

      I've never understodd the need to keep cramming new more and more levels of stuff between the code and what you're trying to do. But I think template metaprogramming is just a "stupid code trick" and worth little more than proving how clever you are, so you shouldn't ask me. I'm too busy getting work done.

      --
      You are in a maze of twisty little passages, all alike.
    10. Re:I don't understand by Anonymous Coward · · Score: 1, Informative

      managed C++ is so different to C++ that it's a different language.

      what MS have done is invent 2 new languages, managed C++ and C#. one of them is ok, the other is an abomination.
      They didn't need to invent managed C++, all the interopability could have been provided by some library helper classes and COM. I've never heard of an explanation for manC++, and never heard of a new project using it. to link up with existing C++ codebase it's used, but should have been done as a library, not a new language.

      Stan Lippmann really should have known a lot better. maybe they wouldn't let him in the C# team and made him work on the C++ stuff. He's bright enough to know that he's wasting his time on this pointless bastard language.

  5. What's happening to C++?! by Anonymous+Brave+Guy · · Score: 4, Insightful

    Someone remarked the other day, possibly on this very board, along the lines of "the C++ standardisation committee is now full of template-loving metaprogramming fans" who are more concerned with fixing their pet superlibraries than they are with fixing the more glaring flaws in C++ as a modern programming language. I'm sure anyone who follows developments around the language, particularly the serious Usenet groups, will see at least an element of truth in that claim.

    This is almost worse, though. We now have at least two of the biggest names in C++ -- Stan Lippman and Herb Sutter -- following the Microsoft banner. At first, I figured that would be good for the language, driving up standards compliance in one of the most popular implementations, Visual C++. Now I begin to suspect that it's just another Embrace And Extend(TM) manoeuvre.

    The first round of "Managed C++" needed horrible syntax kludges, because C++ is simply too flexible a language to become another .Net language clone like C# or VB.Net. At least it was fairly standard-compliant before, though. Now, if you thought VC++ 6's for loop scoping bug was annoying (and having fixed numerous bits of code broken in that way that failed on other compilers, I promise you it can be very annoying) that's going to be nothing: at Microsoft, they care about standards compliance, but not so much that they won't add random extra keywords to the language! I fail to see how this will be any better than back when Borland used to add properties and such, and then anybody wanting to move away from their component libraries was screwed.

    C++ sucks if you want to use .Net anyway; if that's the sort of programming environment you want, why not just use C# and be done with it? For all Microsoft's banter about interoperability, no-one who's got 100,000 lines of MFC code and a workforce trained to maintain it is really going to change to .Net overnight. Technologies like that are for new projects, started from scratch and able to match the architecture from the ground up, not for random porting exercises of existing code.

    Ultimately, managed C++ is just another lock-in technique, but it's sad that it's apparently being supported so enthusiastically by people who used to know better.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:What's happening to C++?! by QuantumG · · Score: 1, Troll

      Unfortunately the C++ standards commitee has always been a corrupt bunch of language lawyers. You just have to look at all the money that Plum Hall make selling updates to their test suite and then trace back who on the commitee actually proposed and championed the changes to the standard in the first place to see that.

      --
      How we know is more important than what we know.
    2. Re:What's happening to C++?! by Anonymous Coward · · Score: 0

      That's not very convincing. Why not provide is all with some evidence, eh?

    3. Re:What's happening to C++?! by makapuf · · Score: 1

      I'd assume any professionnal in the ISO commitee updates its products based on the standard. And then, sell them. So what ?

    4. Re:What's happening to C++?! by QuantumG · · Score: 1

      Heh, see Plum Hall sell the test suites that everyone has to buy if they want to claim that their compiler is standards compilant. So by forcing changes to the standard Plum Hall make a heap of cash from people buying their updates. The more changes, the more cash. Of course, all those changes to C++ are necessary and there are SO many standard C++ compilers.

      --
      How we know is more important than what we know.
    5. Re:What's happening to C++?! by alex_tibbles · · Score: 1

      But nothing prevented anyone else from writing another test suite...

    6. Re:What's happening to C++?! by alex_tibbles · · Score: 1

      "C++ sucks if you want to use .Net anyway;"

      It does seem strange. I don't think I would voluntarily use managed C++, only native C++ wrapped in C# (or even VB.NET!). The sheer annoyance of using a language that looks superficially familiar but is fundamentally different (all RAII code would break, IIUC etc.) would make it easier to learn a separate language for .NET-CLI work (like Java for JVM work).

      But I like reading and writing as portable code as possible. I find reading code that uses eg. GCC extensions (PDF) unpleasant.

    7. Re:What's happening to C++?! by QuantumG · · Score: 1

      Well how's that going to stop Plum Hall adding bloat to the language just to force an upgrade?

      --
      How we know is more important than what we know.
    8. Re:What's happening to C++?! by kraut · · Score: 2, Insightful

      That's very offensive - I know a couple of people on the committee, and they are hardworking people that largely volunteer their time and efforts for the benefit of the C++ community. Corrupt? I doubt it, but of course it's easy to make unfounded allegations on slashdot.

      BTW, has it occured to you that the implementor of a library test suite might just have extremely good understanding of the library and its flaws, and hence recommends more changes to it than committee members who focus on other parts of the language? And do you really think that if someone suggested gratuitous changes for nefarious purposes the other people on the committee wouldn't notice?

      --
      no taxation without representation!
    9. Re:What's happening to C++?! by gbjbaanb · · Score: 1

      But nothing prevented anyone else from writing another test suite.

      Sure, but unless you can get that test suite recognised as testing C++ standards compliance, its totally useless.

      I could write one, the FOSS community could write one, but then what? Unless the standards committee ratified it, anyone who used it to test their compiler might as well use their own tests.

    10. Re:What's happening to C++?! by Anonymous+Brave+Guy · · Score: 1

      When did the standards committee ratify the Plum Hall tests? I never saw anything about that.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    11. Re:What's happening to C++?! by mrak+and+swepe · · Score: 1

      Now, if you thought VC++ 6's for loop scoping bug was annoying (and having fixed numerous bits of code broken in that way that failed on other compilers, I promise you it can be very annoying)

      #define for if(false);else for

    12. Re:What's happening to C++?! by gbjbaanb · · Score: 1

      didn't they? then who says the test is worth anything? (you can tell I don't keep up with these things)

      I have a test, that once you're run your compiler against it, will allow you to say it is 'standards compliant'.

      That's optional actually, the real test is that you pay me some money. Then you can say you're standards compliant. :)

    13. Re:What's happening to C++?! by QuantumG · · Score: 0, Offtopic

      Heard of backwards compatibility? The C++ standardization commitee certainly hasn't. There is a big long set of rules which have been codified to decide when something should be standardized. One of those rules is that the changes should be in common use (that is, a lot of compilers should have similar features) before they are standardized. Every single time there is a suggestion to add a new feature to C++ this rule is brought up and then subsequently disregarded because if they only added features that were in common use they couldn't drive the development of the language. So they blantantly disregard the rules and make changes to the specification that break existing implementations. There's a reason why there are so few C++ standards compliant compilers available.

      --
      How we know is more important than what we know.
    14. Re:What's happening to C++?! by ConceptJunkie · · Score: 1

      Here's the question you have to ask vis-a-vis Microsoft's extensions of the language and libraries:

      What does Microsoft use to write its OS and applications? From everything I've heard it's all C and Win32. Now if they don't use, why should we?

      My experience with all these new technologies is that you are trading one set of headaches for another. You can either write the piece of functionality yourself, or you can beat yourself senseless trying to figure out how to use Microsoft's tools that supposedly provide that functionality.

      A good example is a simple Internet connection. In the pre-.NET days, doing a simple FTP transfer took about 200 lines of cookbook MFC code. This is ludicrous. I adapted some socket code many years ago, so it takes about 5 lines of code to do an ftp transfer. In fact all the socket code and ftp code in my class library probably didn't add up to the code needed to _use_ MFC ftp support. I thought the whole point of providing libraries and extensions was to make things simpler. If that's the case then why do so many of MS's sample programs, which are generally only simple examples, exceed hundreds of lines of code.

      Granted I haven't played with .NET, since the only thing it seems to be useful for is integrating with a bunch of other stuff. Since memory management is pretty easy if you understand it, I don't see the need for garbage collection, and I don't need to integrate with C# or J# or Bb or whatever the hell they're pet langauge is these days, it seems I'm taking on a huge amount of bloat and headache for little in return. Hence I continue developing productively without it.

      --
      You are in a maze of twisty little passages, all alike.
    15. Re:What's happening to C++?! by Animats · · Score: 0, Troll
      Someone remarked the other day, possibly on this very board, along the lines of "the C++ standardisation committee is now full of template-loving metaprogramming fans" who are more concerned with fixing their pet superlibraries than they are with fixing the more glaring flaws in C++ as a modern programming language. I'm sure anyone who follows developments around the language, particularly the serious Usenet groups, will see at least an element of truth in that claim.

      Yes. The top priority of the C++ standards committee is adding obscure template features few would trust in production code. There's active hostility to any attempt to increase the safety of the language. There's denial, led by Strostrup, that C++ has major problems.

      The latest thing over there is to introduce a really clever lock-free thread synchronization concept. It improves performance slightly at the cost of making concurrent programming as complex as distributed multiprocessor cache design.

      Some serious effort should be given to working through the IEEE to redirect, or remove if necessary, the existing C++ committee.

    16. Re:What's happening to C++?! by Anonymous Coward · · Score: 0

      Plum Hall is not the only test suite for C++. Other people who write test suites work on the standards committee. The C++ committe publishes a language standard on paper(or pdf), and that's it. In particular they have no role in ratifying Plum Hall's test suite, or any other test suite for that matter. Plum Hall's web site does claim, or even imply, that there products are "ratified" by the committe, and the web site for the C++ committee does not do this either. So, I am very curious what exactly gave you the impression that this was the case?

    17. Re:What's happening to C++?! by pthisis · · Score: 1

      What does Microsoft use to write its OS and applications? From everything I've heard it's all C and Win32.

      Very little is written in C, it's mostly C++.

      --
      rage, rage against the dying of the light
  6. founding fathers ? by Anonymous Coward · · Score: 0

    I thought the founding fathers of C++ were Bjarne Stroustrup.

    1. Re:founding fathers ? by Anonymous+Brave+Guy · · Score: 3, Interesting
      I thought the founding fathers of C++ were Bjarne Stroustrup.

      Stroustrup is the original creator of C++, but several of the other big names were involved pretty much from the start, and a lot of them have worked together over the years. Stan Lippman is one such person.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    2. Re:founding fathers ? by MarkusQ · · Score: 1

      I thought the founding fathers of C++ were Bjarne Stroustrup.

      Stroustrup is the original creator of C++, but several of the other big names were involved pretty much from the start, and a lot of them have worked together over the years. Stan Lippman is one such person.

      Ok, my memory may be faulty, but I'd have to agree with the grandparent post. I don't recall much from Stan before the mid-nineties, while (again, IIRC) Bjarne sired it in the early 80's. "Founding Father" seems a little bit of a stretch if he wasn't in the picture much for the first 60% of the history.

      One of C++'s "Favorite Uncles" maybe?

      -- MarkusQ

  7. Love the syntax! by Anonymous Coward · · Score: 1, Funny
    C++:
    namespace Foo {
    }
    Microsoft Managed C++:
    public ref class Foo abstract sealed {
    }
    Far be it from me to dare to consider accusing them of pointless, nay indeed redundant or tautologous, verbosity, but I do think they're using too many words.
  8. Microsoft has destroyed C++ by Anonymous Coward · · Score: 3, Insightful
    It wasn't enough that they had to extinguish Java out, now they've done the same thing to C++.

    Look at the .NET versions of Visual Studio, and see how the C++ has been rammed right to the bottom in terms of features, while visual basic and C# (ACK) have all the actual useful stuff. (Forms designer, for one).

    I mean, I love writing C++ and having to remember a million different __gc __huhwhut __whynotthistoo in front of all the declarations. Completely *unportable* code.

    Microsoft is attempting to end the usefulness of C++ on Windows, and I think with VS2003 they did it.

  9. Need a different name by Anonymous Coward · · Score: 0

    I really think they should of called it something better than managed C++, pick an animal or something.