Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. c++ .net

c++ .net

Scheduled Pinned Locked Moved The Lounge
csharpquestionc++performance
26 Posts 13 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D dave2k

    what's this all about then? if all the .net languages compile down to the same intermediate language, i assume that a similar program written in c++ .net and lets say c# runs at the same speed? so then what is the point in using c++ with it's added complexities (admitedly not as comlpex as unmanagaed c++) to keep the older developers happy?

    J Offline
    J Offline
    Judah Gabriel Himango
    wrote on last edited by
    #5

    if all the .net languages compile down to the same intermediate language, i assume that a similar program written in c++ .net and lets say c# runs at the same speed? .NET languages all compile down to an intermediate language. However, each compiler emits different IL codes. This was demonstrated a few months ago when a J#, VB.NET, and C# app compiled code that was functionally identical, however, C#'s optimizing compiler was able to produce a more highly optimized, and therefore faster, resulting bytecodes. The new C++/CLI, as it's referred to, produces a highly compact and optimized IL. There was an article on MSDN recently regarding this, along with benchmarks. Furthermore, the new C++ compiler provides Bottom-Up, Top Down analysis for both managed and unmanaged code. The long-awaited Profile Guided Optimizations (POGO) part of the 2005 compiler also works on managed and unmanaged code. And of course, C++/CLI is the only .NET language that can mix managed and native code, allowing you to reuse existing native codebases and still take advanatage of the .NET framework class library if you need. Finally, C++/CLI is the only .NET language that will be able to use C++ templates or CLR generics, which is a powerful feature and makes using managed code more natural to C++ developers. Some good articles on this here[^] and here[^].

    Tech, life, family, faith: Give me a visit. I'm currently blogging about: Homosexuality in Christianity Judah Himango

    O 1 Reply Last reply
    0
    • C CP Visitor

      dave2k wrote: so then what is the point in using c++ with it's added complexities (admitedly not as comlpex as unmanagaed c++) Managed C++ adds, no multiplies, the complexities of C++ and C#. I don't see a point using it besides for re-using code that is now deemed 'legacy' by Microsoft.

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #6

      Agreed, and I think Microsoft realized this when they decided to create C++/CLI. It's quite the improvement to the cumbersome Managed Extensions to C++.

      Tech, life, family, faith: Give me a visit. I'm currently blogging about: Homosexuality in Christianity Judah Himango

      1 Reply Last reply
      0
      • C CP Visitor

        dave2k wrote: so then what is the point in using c++ with it's added complexities (admitedly not as comlpex as unmanagaed c++) Managed C++ adds, no multiplies, the complexities of C++ and C#. I don't see a point using it besides for re-using code that is now deemed 'legacy' by Microsoft.

        B Offline
        B Offline
        basementman
        wrote on last edited by
        #7

        C++ was "deemed" legacy by Microsoft when VB 4 came out... now it is legacy again? Guess I've been a dinosaur for the last 8 years or so...  onwards and upwards...

        1 Reply Last reply
        0
        • J Jim Crafton

          Anna-Jayne Metcalfe wrote: mix and match managed and unmanaged code in the same project - and indeed in the same file. I thought you could do this with C# by calling/importing in un managed functions? ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!

          N Offline
          N Offline
          Nemanja Trifunovic
          wrote on last edited by
          #8

          C# can import external modules written in C or C++. With MC++ you can actually write both managed and native code in the same module.


          My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

          1 Reply Last reply
          0
          • C CP Visitor

            dave2k wrote: so then what is the point in using c++ with it's added complexities (admitedly not as comlpex as unmanagaed c++) Managed C++ adds, no multiplies, the complexities of C++ and C#. I don't see a point using it besides for re-using code that is now deemed 'legacy' by Microsoft.

            N Offline
            N Offline
            Nemanja Trifunovic
            wrote on last edited by
            #9

            CP Visitor wrote: Managed C++ adds, no multiplies, the complexities of C++ and C#. Have you ever actually used Managed C++?


            My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

            C S R 3 Replies Last reply
            0
            • J Jim Crafton

              Anna-Jayne Metcalfe wrote: mix and match managed and unmanaged code in the same project - and indeed in the same file. I thought you could do this with C# by calling/importing in un managed functions? ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!

              A Offline
              A Offline
              Anna Jayne Metcalfe
              wrote on last edited by
              #10

              You can, but not in the same file. i.e. a C++ file can switch between managed and unmanaged code at pretty much any point - even within a single function. That allows easier interop between CLR and native code than is possible with other languages - even C# can't do this. Take a look at #pragma managed/unmanaged[^]. It's no mistake that Microsoft have been calling C++ the "most powerful of the .net languages". :cool: Anna :rose: Riverblade Ltd - Software Consultancy Services Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

              1 Reply Last reply
              0
              • N Nemanja Trifunovic

                CP Visitor wrote: Managed C++ adds, no multiplies, the complexities of C++ and C#. Have you ever actually used Managed C++?


                My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                C Offline
                C Offline
                CP Visitor
                wrote on last edited by
                #11

                Nemanja Trifunovic wrote: Have you ever actually used Managed C++? No, it's too complex for me :-D

                N 1 Reply Last reply
                0
                • N Nemanja Trifunovic

                  CP Visitor wrote: Managed C++ adds, no multiplies, the complexities of C++ and C#. Have you ever actually used Managed C++?


                  My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                  S Offline
                  S Offline
                  S Senthil Kumar
                  wrote on last edited by
                  #12

                  I've been playing around with the VC++ 2005 Express beta, the new syntax is much better. Also, it has cool things like RAII with ref classes, separate set and get methods for properties with the ability to have different access modifiers and the for each statement. But I get this feeling that it is just C++ catching up with C#. Also, everytime I use a managed C++ construct, I feel I'm losing my grip on pure C++ (especially with C++0x coming up). Regards Senthil _____________________________ My Blog | My Articles | WinMacro

                  N 1 Reply Last reply
                  0
                  • C CP Visitor

                    Nemanja Trifunovic wrote: Have you ever actually used Managed C++? No, it's too complex for me :-D

                    N Offline
                    N Offline
                    Nemanja Trifunovic
                    wrote on last edited by
                    #13

                    :-D It is not that complex, and the new version (C++/CLI) is really simpler to use than C#. The problems I had with (original) MC++ were caused by bugs in the implementation (like virtual bool one), not "complexity".


                    My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                    1 Reply Last reply
                    0
                    • S S Senthil Kumar

                      I've been playing around with the VC++ 2005 Express beta, the new syntax is much better. Also, it has cool things like RAII with ref classes, separate set and get methods for properties with the ability to have different access modifiers and the for each statement. But I get this feeling that it is just C++ catching up with C#. Also, everytime I use a managed C++ construct, I feel I'm losing my grip on pure C++ (especially with C++0x coming up). Regards Senthil _____________________________ My Blog | My Articles | WinMacro

                      N Offline
                      N Offline
                      Nemanja Trifunovic
                      wrote on last edited by
                      #14

                      S. Senthil Kumar wrote: Also, it has cool things like RAII with ref classes, separate set and get methods for properties with the ability to have different access modifiers and the for each statement. The thing I like best about C++/CLI is the way compiler automatically implements the Dispose Pattern[^] :cool: . With all other languages, the burden is on developers.


                      My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                      1 Reply Last reply
                      0
                      • A Anna Jayne Metcalfe

                        With C++, you can mix and match managed and unmanaged code in the same project - and indeed in the same file. No other language offers that capability. Anna :rose: Riverblade Ltd - Software Consultancy Services Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

                        T Offline
                        T Offline
                        TheGreatAndPowerfulOz
                        wrote on last edited by
                        #15

                        can't you do the same in C# using the "unsafe" keyword?

                        J 1 Reply Last reply
                        0
                        • T TheGreatAndPowerfulOz

                          can't you do the same in C# using the "unsafe" keyword?

                          J Offline
                          J Offline
                          Judah Gabriel Himango
                          wrote on last edited by
                          #16

                          No. The unsafe keyword symbolizes a class, method, or block of code that uses pointers. It's still managed code (it's being "managed" by the .NET Common Language Runtime (CLR)), however, it is unsafe, meaning it's unverifiable, non-CLS compliant, and can't be run in a partial trust scenario, such as over the internet via a C# 'applet'. Unmanaged code is code that doesn't get touched by the .NET CLR. As an example, a C++/CLI app could use MFC's CString, show and MFC dialog, dabble on a low, unmanaged level with some COM component, then return the CString as a .Net System::String object. C#'s unsafe can only do unsafe memory manipulation, such as using pointers or native stack allocation.

                          Tech, life, family, faith: Give me a visit. I'm currently blogging about: Homosexuality in Christianity Judah Himango

                          A A 2 Replies Last reply
                          0
                          • N Nemanja Trifunovic

                            CP Visitor wrote: Managed C++ adds, no multiplies, the complexities of C++ and C#. Have you ever actually used Managed C++?


                            My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                            R Offline
                            R Offline
                            realJSOP
                            wrote on last edited by
                            #17

                            I've been programming for 25 years, and programming C/C++ for 15 years. I don't feel that my code needs to be "managed". ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                            J N 2 Replies Last reply
                            0
                            • R realJSOP

                              I've been programming for 25 years, and programming C/C++ for 15 years. I don't feel that my code needs to be "managed". ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                              J Offline
                              J Offline
                              Judah Gabriel Himango
                              wrote on last edited by
                              #18

                              Doesn't have to be, no one's forcing you. If you want memory management or access to the framework for even part of your code, it's there if you want it.

                              Tech, life, family, faith: Give me a visit. I'm currently blogging about: Homosexuality in Christianity Judah Himango

                              1 Reply Last reply
                              0
                              • J Judah Gabriel Himango

                                No. The unsafe keyword symbolizes a class, method, or block of code that uses pointers. It's still managed code (it's being "managed" by the .NET Common Language Runtime (CLR)), however, it is unsafe, meaning it's unverifiable, non-CLS compliant, and can't be run in a partial trust scenario, such as over the internet via a C# 'applet'. Unmanaged code is code that doesn't get touched by the .NET CLR. As an example, a C++/CLI app could use MFC's CString, show and MFC dialog, dabble on a low, unmanaged level with some COM component, then return the CString as a .Net System::String object. C#'s unsafe can only do unsafe memory manipulation, such as using pointers or native stack allocation.

                                Tech, life, family, faith: Give me a visit. I'm currently blogging about: Homosexuality in Christianity Judah Himango

                                A Offline
                                A Offline
                                Anna Jayne Metcalfe
                                wrote on last edited by
                                #19

                                You beat me to it. Good explanation. :) Anna :rose: Riverblade Ltd - Software Consultancy Services Anna's Place | Tears and Laughter "Be yourself - not what others think you should be" - Marcia Graesch "Anna's just a sexy-looking lesbian tart" - A friend, trying to wind me up. It didn't work.

                                1 Reply Last reply
                                0
                                • J Jim Crafton

                                  Anna-Jayne Metcalfe wrote: mix and match managed and unmanaged code in the same project - and indeed in the same file. I thought you could do this with C# by calling/importing in un managed functions? ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!

                                  T Offline
                                  T Offline
                                  Tom Archer
                                  wrote on last edited by
                                  #20

                                  With other .NET languages you have to specifically use something like COM interop or PInvoke. With C++, it's completely transparent to you. As an example, I can create an MFC application that uses any .NET class and looking at the code, you can't seen any difference - hence the term of the underlying mechanism - IJW (It Just Works) Cheers, Tom Archer - Visual C++ MVP Archer Consulting Group "So look up ahead at times to come, despair is not for us. We have a world and more to see, while this remains behind." - James N. Rowe

                                  1 Reply Last reply
                                  0
                                  • D dave2k

                                    what's this all about then? if all the .net languages compile down to the same intermediate language, i assume that a similar program written in c++ .net and lets say c# runs at the same speed? so then what is the point in using c++ with it's added complexities (admitedly not as comlpex as unmanagaed c++) to keep the older developers happy?

                                    T Offline
                                    T Offline
                                    Tom Archer
                                    wrote on last edited by
                                    #21

                                    It has nothing to do with keping "older developers happy". It's about keeping large customers happy. If you're running a company with millions spent on training and development, you don't want to have to retrain your developers and then have them redo everything just because Microsoft has a new language du jour. Porting most of the "mainstream languages" to .NET allows companies to continue using current employees and not having to rewrite their systems. Specifically, Managed C++ allows a company to move "piece-meal" over to .NET by rewriting small bits at a time or simply by writing the new bits with the .NET BCL. Cheers, Tom Archer - Visual C++ MVP Archer Consulting Group "So look up ahead at times to come, despair is not for us. We have a world and more to see, while this remains behind." - James N. Rowe

                                    1 Reply Last reply
                                    0
                                    • R realJSOP

                                      I've been programming for 25 years, and programming C/C++ for 15 years. I don't feel that my code needs to be "managed". ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                                      N Offline
                                      N Offline
                                      Nemanja Trifunovic
                                      wrote on last edited by
                                      #22

                                      John Simmons / outlaw programmer wrote: I've been programming for 25 years, and programming C/C++ for 15 years. I don't feel that my code needs to be "managed". I have been programming for only 21 years, and C/C++ for 11 years, but I feel the same. However, if I am required to write managed code, better give me a good programming language. I want power, not "simplicity".


                                      My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                                      J 1 Reply Last reply
                                      0
                                      • N Nemanja Trifunovic

                                        John Simmons / outlaw programmer wrote: I've been programming for 25 years, and programming C/C++ for 15 years. I don't feel that my code needs to be "managed". I have been programming for only 21 years, and C/C++ for 11 years, but I feel the same. However, if I am required to write managed code, better give me a good programming language. I want power, not "simplicity".


                                        My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

                                        J Offline
                                        J Offline
                                        Judah Gabriel Himango
                                        wrote on last edited by
                                        #23

                                        I want power, not "simplicity". I want power and simplicity. Power without simplicity: being able to skim a dollar off the checking accounts of every person in the world, provided you remember the checking account numbers in your head. Power with simplicity: having every checking account number in your database. :)

                                        Tech, life, family, faith: Give me a visit. I'm currently blogging about: Homosexuality in Christianity Judah Himango

                                        1 Reply Last reply
                                        0
                                        • J Judah Gabriel Himango

                                          if all the .net languages compile down to the same intermediate language, i assume that a similar program written in c++ .net and lets say c# runs at the same speed? .NET languages all compile down to an intermediate language. However, each compiler emits different IL codes. This was demonstrated a few months ago when a J#, VB.NET, and C# app compiled code that was functionally identical, however, C#'s optimizing compiler was able to produce a more highly optimized, and therefore faster, resulting bytecodes. The new C++/CLI, as it's referred to, produces a highly compact and optimized IL. There was an article on MSDN recently regarding this, along with benchmarks. Furthermore, the new C++ compiler provides Bottom-Up, Top Down analysis for both managed and unmanaged code. The long-awaited Profile Guided Optimizations (POGO) part of the 2005 compiler also works on managed and unmanaged code. And of course, C++/CLI is the only .NET language that can mix managed and native code, allowing you to reuse existing native codebases and still take advanatage of the .NET framework class library if you need. Finally, C++/CLI is the only .NET language that will be able to use C++ templates or CLR generics, which is a powerful feature and makes using managed code more natural to C++ developers. Some good articles on this here[^] and here[^].

                                          Tech, life, family, faith: Give me a visit. I'm currently blogging about: Homosexuality in Christianity Judah Himango

                                          O Offline
                                          O Offline
                                          ogrig
                                          wrote on last edited by
                                          #24

                                          Judah Himango wrote: However, each compiler emits different IL codes. This was demonstrated a few months ago when ... nice reply (you already got my 5), but do you really feel a demonstration is: 1. required 2. possible (I've read a lot of articles, some of them on CP, discussing how C# and VB.NET evolve towards the generation of identical code) OGR

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups