learn C++ or C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel James

    #16
    Re: learn C++ or C#

    In article news:<OZyOgzF6I HA.2260@TK2MSFT NGP03.phx.gbl>, Daniel wrote:
    If I haven't made substantial investment in either C++ or C#, which
    language would the experts recommend I become well acquainted with?
    It depends what you want to do, and where you want to do it.

    C++ is the more powerful language but there is more to learn, C# is
    relatively simple but less powerful. OTOH there are more productivity
    tools for C# (largely because it has a simpler syntax, so the tools are
    easier to write).

    C++ can be used to write software for a huge range of systems -- not
    only Windows but also Mac, linux and others (including mini and
    mainframe computers, and embedded systems). C# targets a virtual machine
    architecture, so C# programs can run only on computers for which such a
    runtime (a JIT compiler or an interpreter) is available -- that means
    Windows, certainly, and platforms that support Mono (an Open Source
    NET-compatible runtime); but not nearly so many as can run C++
    programs.

    C++ can be used to write system-level code: operating systems, device
    drivers, etc.. Although there are research projects and proof of concept
    implementation that use C# for these things, current C# implementations
    do not allow C# to be used for this kind of work with mainstream OSes --
    you can't write even a Windows device driver in C#. If you want to do
    driver work then choose C++ (or even C).

    A good implementation plan is to write your back-end code -- the
    business logic of your application -- in a fast portable language (such
    as C++) so that it can be built to run on the maximum possible number of
    platforms, and then to write a GUI wrapper around it for each platform
    on which you want to ship ... you might choose to write such a GUI
    wrapper in C# for a Windows version of your software, though other
    possibilities (including VB, Java, Python, etc) exist.

    Alternatively you could write your application logic in a webserver
    format and use your platform's browser for the GUI, which would save you
    writing any platform-specific GUI code at all.

    Personally, I usually write the application back-end in C++ and then
    write the Windows-specific GUI wrapper in C++ using MFC ... but then I'm
    from a C++ background and I just do what comes naturally.

    Cheers,
    Daniel.


    Comment

    • Giovanni Dicanio

      #17
      Re: learn C++ or C#


      "Daniel James"
      C# targets a virtual machine
      architecture, so C# programs can run only on computers for which such a
      runtime (a JIT compiler or an interpreter) is available -- that means
      Windows, certainly, and platforms that support Mono (an Open Source
      NET-compatible runtime);
      I've heard about Mono before. But I wonder: what is the level of
      implementation of Mono?
      Is Mono as robust as the Microsoft .NET framework implementation?
      Does Mono fully support C# 3?
      Does Mono fully support .NET Framework 3.5 ?

      Thanks,
      Giovanni


      Comment

      • Ken Foskey

        #18
        Re: learn C++ or C#

        On Fri, 18 Jul 2008 11:46:56 +0200, Giovanni Dicanio wrote:

        I've heard about Mono before. But I wonder: what is the level of
        implementation of Mono?
        Is Mono as robust as the Microsoft .NET framework implementation?
        A lot of the .net framework is directly from Microsoft. A lot is
        implemented a totally different way. I expect that it will be very
        compliant as time progresses just not now.
        Does Mono fully support C# 3?
        I cannot compile anymore:

        [Task:File=/home/ken/projects/Capture/Capture/inMatch.cs, Line=266,
        Column=32, Type=Error, Priority=Normal , Description=Fea ture `query
        expressions' cannot be used because it is not part of the C# 2.0 language
        specification(C S1644)]
        Does Mono fully support .NET Framework 3.5 ?
        definitely not.

        Mono is about portability you have to build with that in mind and you can
        be fully portable. I write my test classes on Console and run them on
        Linux as well. I have socket based tests and I need two machine to make
        it work.

        Ken

        Comment

        • David Wilkinson

          #19
          Re: learn C++ or C#

          Daniel wrote:
          If I haven't made substantial investment in either C++ or C#, which language
          would the experts recommend I become well acquainted with?
          Daniel:

          As you are posting in dotnet groups, you should know that there are actually
          three languages

          C++
          C#
          C++/CLI

          Up to now you have been using C++/CLI, which is the wrong choice if you want to
          write GUI Windows applications, because Microsoft no longer recommends C++/CLi
          for writing GUI .NET applications.

          Assuming that you want to write GUI applications for Windows, you need a library.

          If you use native C++, you will probably want to use the MFC library (which does
          not come with VC Express. by the way). MFC is old, and not very elegant, and has
          quite a learning curve. But there is a huge base of available code samples for
          it, and Microsoft is once again working on improving it (after many years of
          neglect). MFC is not portable to other platforms, but if you separate the
          back-end of your application from the GUI, you can port the back-end to other
          platforms such as MAC/linux. For me, one of the advantages of going the MFC
          route is that you can use static linking, which means that you can deploy
          without installing any components on the target machine.

          [Note that the main newsgroups for standard C++ are microsoft.publi c.vc.language
          and microsoft.publi c.vc.mfc]

          If you use C#, you will use the .NET library, which is more elegant, and
          probably easier to learn than MFC. If you go this route, you need to make sure
          that the appropriate version of the .NET framework is installed on the target
          system.

          There are also hybrid methods, where you write your back-end in standard C++,
          the GUI in C#, and build an interface layer using C++/CLI. This may be
          appropriate if you have a large amount of legacy C++ code, but it means you have
          to learn and understand three languages.

          Feel free to ask more questions. This is an important decision, and you should
          be sure you make the one that is correct for you.

          --
          David Wilkinson
          Visual C++ MVP

          Comment

          • Ben Voigt [C++ MVP]

            #20
            Re: learn C++ or C#

            Ken Foskey wrote:
            On Fri, 18 Jul 2008 11:46:56 +0200, Giovanni Dicanio wrote:
            >
            >
            >I've heard about Mono before. But I wonder: what is the level of
            >implementati on of Mono?
            >Is Mono as robust as the Microsoft .NET framework implementation?
            >
            A lot of the .net framework is directly from Microsoft. A lot is
            implemented a totally different way. I expect that it will be very
            compliant as time progresses just not now.
            >
            >Does Mono fully support C# 3?
            >
            I cannot compile anymore:
            >
            [Task:File=/home/ken/projects/Capture/Capture/inMatch.cs, Line=266,
            Column=32, Type=Error, Priority=Normal , Description=Fea ture `query
            expressions' cannot be used because it is not part of the C# 2.0
            language specification(C S1644)]
            Sounds like a command line option, or lack thereof, put you in C# 2
            compatibility mode. Certainly the compiler wouldn't be describing a feature
            such as LINQ query expressions if it didn't understand it.
            >
            >Does Mono fully support .NET Framework 3.5 ?
            >
            definitely not.
            >
            Mono is about portability you have to build with that in mind and you
            can be fully portable. I write my test classes on Console and run
            them on Linux as well. I have socket based tests and I need two
            machine to make it work.
            >
            Ken

            Comment

            • Ben Voigt [C++ MVP]

              #21
              Re: learn C++ or C#

              Assuming that you want to write GUI applications for Windows, you
              need a library.
              If you use native C++, you will probably want to use the MFC library
              (which does not come with VC Express. by the way). MFC is old, and
              not very elegant, and has quite a learning curve. But there is a huge

              ATL/WTL follow modern C++ principles much better than MFC, and should
              probably be the library of choice for C++ Windows-only GUI.
              base of available code samples for it, and Microsoft is once again
              working on improving it (after many years of neglect). MFC is not
              portable to other platforms, but if you separate the back-end of your
              application from the GUI, you can port the back-end to other
              platforms such as MAC/linux. For me, one of the advantages of going
              the MFC route is that you can use static linking, which means that
              you can deploy without installing any components on the target
              machine.
              [Note that the main newsgroups for standard C++ are
              microsoft.publi c.vc.language and microsoft.publi c.vc.mfc]
              >
              If you use C#, you will use the .NET library, which is more elegant,
              and probably easier to learn than MFC. If you go this route, you need
              to make sure that the appropriate version of the .NET framework is
              installed on the target system.
              >
              There are also hybrid methods, where you write your back-end in
              standard C++, the GUI in C#, and build an interface layer using
              C++/CLI. This may be appropriate if you have a large amount of legacy
              C++ code, but it means you have to learn and understand three
              languages.
              Feel free to ask more questions. This is an important decision, and
              you should be sure you make the one that is correct for you.

              Comment

              • Jon Skeet [C# MVP]

                #22
                Re: learn C++ or C#

                On Jul 18, 2:56 pm, "Ben Voigt [C++ MVP]" <r...@nospam.no spamwrote:
                [Task:File=/home/ken/projects/Capture/Capture/inMatch.cs, Line=266,
                Column=32, Type=Error, Priority=Normal , Description=Fea ture `query
                expressions' cannot be used because it is not part of the C# 2.0
                language specification(C S1644)]
                >
                Sounds like a command line option, or lack thereof, put you in C# 2
                compatibility mode.  Certainly the compiler wouldn't be describing a feature
                such as LINQ query expressions if it didn't understand it.
                Indeed, you need the command line option -langversion:lin q but to
                quote the documentation:

                <quote>
                This enables the C# 3.0 support. Only a few features of C# 3.0 have
                been implemented in the Mono C# compiler, so not everything is
                available.
                </quote>

                :(

                Jon

                Comment

                • Larry Smith

                  #23
                  Re: learn C++ or C#

                  >Assuming that you want to write GUI applications for Windows, you
                  >need a library.
                  >If you use native C++, you will probably want to use the MFC library
                  >(which does not come with VC Express. by the way). MFC is old, and
                  >not very elegant, and has quite a learning curve. But there is a huge
                  >
                  >
                  ATL/WTL follow modern C++ principles much better than MFC, and should
                  probably be the library of choice for C++ Windows-only GUI.
                  WTL still wasn't officially supported by MSFT the last time I worked with it
                  (3+ years ago now). There was also no documentation. A quick check and it
                  still doesn't appear to be supported. This may or may not affect someone's
                  decision to use it but it is a serious consideration. I do agree however
                  that it's better than MFC which I abandoned in favour of WTL. Note however
                  that ATL is incredibly arcane and very difficult to master. It's not for the
                  weak and most programmers can't handle it. People who care about the
                  integrity of their programs should seriously consider other choices before
                  choosing it (and there aren't many unfortunately).


                  Comment

                  • David Wilkinson

                    #24
                    Re: learn C++ or C#

                    Ben Voigt [C++ MVP] wrote:
                    ATL/WTL follow modern C++ principles much better than MFC, and should
                    probably be the library of choice for C++ Windows-only GUI.
                    Ben:

                    Yes, I think about this sometimes. But I am not sure that WTL provides as many
                    features as MFC, and it is not supported by Microsoft, which makes me nervous. I
                    also have a huge investment in MFC, both in knowledge and code base. I wish MFC
                    were more elegant, but I have gotten used to it.

                    If this old programmer is going to learn something new, I think it's going to be
                    C# and .NET.

                    --
                    David Wilkinson
                    Visual C++ MVP

                    Comment

                    • Daniel

                      #25
                      Re: learn C++ or C#

                      I had forgotten the proper terminology. I meant to ask whether C# was a low
                      level language to the same extent as C++.

                      Daniel

                      "Peter Duniho" <NpOeStPeAdM@nn owslpianmk.comw rote in message
                      news:op.ueg1rnw 48jd0ej@petes-computer.local. ..
                      On Thu, 17 Jul 2008 21:28:11 -0700, Daniel <newsonly@cable one.netwrote:
                      >
                      >Does C# have as much meticulous control over the micro matters as C++
                      >does?
                      >
                      "Meticulous control" and "micro matters" are not well-defined terminology
                      in the field of programming. It's not possible to answer that question
                      without you providing it in a more detailed, less ambiguous way.
                      >
                      In any case, I doubt that's a question you really need an answer to. As
                      has been explained previously, it really has more to do with what you're
                      trying to write. While there are specific differences between each
                      language, with only some exceptions what you can do in one, you can do in
                      the other. But C# is generally better-suited to dealing with .NET, while
                      C++ is likely to be better suited if you're having to deal with unmanaged
                      APIs.
                      >
                      So the proper choice of language has more to do with what you're going to
                      use it for than in differences between the languages in the abstract.
                      >
                      Pete

                      Comment

                      • Daniel

                        #26
                        Re: learn C++ or C#

                        ok. Thanks.

                        "Giovanni Dicanio" <gdicanio@_NOSP AM_email_DOT_it wrote in message
                        news:uyIJu8K6IH A.1592@TK2MSFTN GP04.phx.gbl...
                        >
                        "Arne Vajhøj" <arne@vajhoej.d kha scritto nel messaggio
                        news:487fdc67$0 $90274$14726298 @news.sunsite.d k...
                        >
                        >First I will make a prediction: the .vc guys will suggest C++ and
                        >the .csharp guys will suggest C#.
                        >>
                        >:-)
                        >
                        I'm a .vc guy :-)
                        >
                        >
                        >If you want to write general business apps, then I will suggest C#.
                        >
                        I agree with that.
                        >
                        >
                        >If you have special requirements for real time, embedded, device
                        >driver programming and similar then go for C++.
                        >
                        Moreover, if you want to build Windows shell extensions, you should use
                        C++.
                        >
                        If you want crossplatform code, you should use C++ (with proper libraries
                        like wxWidgets for the GUI).
                        >
                        If you want to build small .exe's easy to deploy (no need of huge runtime
                        to distribute), you should use C++ (with CRT/MFC/ATL statically linked).
                        >
                        If you learn C++ first, then moving to C# is a very easy path, as others
                        wisely wrote.
                        Instead, the opposite is not true.
                        >
                        Both languages have pro's and con's: choose the better tool for your
                        particular job.
                        >
                        Giovanni
                        >
                        >
                        >

                        Comment

                        • Daniel

                          #27
                          Re: learn C++ or C#

                          What is MSI? What do you mean by "MSI custom actions"?

                          Daniel

                          "Pavel Minaev" <int19h@gmail.c omwrote in message
                          news:f21ed502-645b-40e9-a5a0-d54cc68a9957@z1 6g2000prn.googl egroups.com...
                          On Jul 18, 2:31 am, "Daniel" <newso...@cable one.netwrote:
                          If I haven't made substantial investment in either C++ or C#, which
                          language
                          would the experts recommend I become well acquainted with?
                          By the way, one reason why a .NET developer might want to learn C++ or
                          at least C is to be able to write MSI custom actions for installers
                          (while it's possible to create managed actions, there is a number of
                          issues and technical difficulties associated with them).


                          Comment

                          • Daniel

                            #28
                            Re: learn C++ or C#

                            Thanks.

                            "David Wilkinson" <no-reply@effisols. comwrote in message
                            news:eeyAnVN6IH A.4352@TK2MSFTN GP03.phx.gbl...
                            Daniel wrote:
                            >If I haven't made substantial investment in either C++ or C#, which
                            >language would the experts recommend I become well acquainted with?
                            >
                            Daniel:
                            >
                            As you are posting in dotnet groups, you should know that there are
                            actually three languages
                            >
                            C++
                            C#
                            C++/CLI
                            >
                            Up to now you have been using C++/CLI, which is the wrong choice if you
                            want to write GUI Windows applications, because Microsoft no longer
                            recommends C++/CLi for writing GUI .NET applications.
                            >
                            Assuming that you want to write GUI applications for Windows, you need a
                            library.
                            >
                            If you use native C++, you will probably want to use the MFC library
                            (which does not come with VC Express. by the way). MFC is old, and not
                            very elegant, and has quite a learning curve. But there is a huge base of
                            available code samples for it, and Microsoft is once again working on
                            improving it (after many years of neglect). MFC is not portable to other
                            platforms, but if you separate the back-end of your application from the
                            GUI, you can port the back-end to other platforms such as MAC/linux. For
                            me, one of the advantages of going the MFC route is that you can use
                            static linking, which means that you can deploy without installing any
                            components on the target machine.
                            >
                            [Note that the main newsgroups for standard C++ are
                            microsoft.publi c.vc.language and microsoft.publi c.vc.mfc]
                            >
                            If you use C#, you will use the .NET library, which is more elegant, and
                            probably easier to learn than MFC. If you go this route, you need to make
                            sure that the appropriate version of the .NET framework is installed on
                            the target system.
                            >
                            There are also hybrid methods, where you write your back-end in standard
                            C++, the GUI in C#, and build an interface layer using C++/CLI. This may
                            be appropriate if you have a large amount of legacy C++ code, but it means
                            you have to learn and understand three languages.
                            >
                            Feel free to ask more questions. This is an important decision, and you
                            should be sure you make the one that is correct for you.
                            >
                            --
                            David Wilkinson
                            Visual C++ MVP

                            Comment

                            • Peter Duniho

                              #29
                              Re: learn C++ or C#

                              On Fri, 18 Jul 2008 09:40:45 -0700, Daniel <newsonly@cable one.netwrote:
                              I had forgotten the proper terminology. I meant to ask whether C# was a
                              low
                              level language to the same extent as C++.
                              I guess I would describe C++ as being "lower level" than C#. However, if
                              you're writing .NET code the difference doesn't matter. C++ has roughly
                              the same degree of "high level" features that C# has and vice a versa, and
                              even in C# you can write "unsafe" code to do certain "low level" things.
                              The main limitation with C# is that if you write C# code, it has to
                              execute in the managed environment, which excludes it from certain kinds
                              of applications (already discussed elsewhere in these threads).

                              Pete

                              Comment

                              • Pavel Minaev

                                #30
                                Re: learn C++ or C#

                                On Jul 18, 1:36 pm, Daniel James <wastebas...@no spam.aaisp.orgw rote:
                                A good implementation plan is to write your back-end code -- the
                                business logic of your application -- in a fast portable language (such
                                as C++) so that it can be built to run on the maximum possible number of
                                platforms, and then to write a GUI wrapper around it for each platform
                                on which you want to ship ... you might choose to write such a GUI
                                wrapper in C# for a Windows version of your software, though other
                                possibilities (including VB, Java, Python, etc) exist.
                                I disagree about the "business logic in C++" part. In practice,
                                standard C++ tends to be too low-level, verbose, and overcomplicated
                                for many common patterns that arise when developing a typical business
                                layer in many desktop and LOB applications. I'd still recommend C# for
                                that.

                                Leave C++ for tightly optimized algorithm implementations , device
                                drivers, shell plugins, MSI custom actions, etc.

                                Comment

                                Working...