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. The true advantage of C# over C++

The true advantage of C# over C++

Scheduled Pinned Locked Moved The Lounge
csharpc++comtoolshelp
17 Posts 12 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.
  • C Christopher Duncan

    Does C# have the equivalent of the C/C++ #define? If so, you could just do a #define _T() (which I find almost as clumsy to type as @""). :)

    Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

    P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #8

    I use the "C pre-processor" with my C#, I'm just that kind of guy. So yes, I have the same # define. (And I compile from the command-line... with a bat file, although I suppose make can do it too.)

    "C:\Program files\mingw\bin\cpp" -include "C:\Projects\PIEBALD\Defines.hs" -P -C -D__Csharp=# -w %1.cs %1.csi
    csc.exe @"C:\batfiles\Build.rsp" %1.csi

    When I do want the C# # define, which is very rare, I write __Csharp define instead. This is mostly from years of using Pro*C; I'd pass the code through CPP (or equivalent), then through the Pro*C pre-compiler, and then into the C compiler. The downside is that my line numbers are off by one, but I can live with that.

    1 Reply Last reply
    0
    • P peterchen

      no _T(), bug @"c:\temp" I mean, really.


      Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers!
      We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
      Linkify!|Fold With Us!

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

      Haven't used _T() in a while :) (yeah, Linux...) Anyway, if you ask me, the true advantage of C# over C++ is that it is developed by Microsoft, and not the "Standard Comitee". Heck, they (MS) managed to turn a joke that C# 1.0 was into the most advanced mainstream language[^] (this story about MS products getting decent around version 3.0 seems to have something about it after all) and we are still hoping that type inference and lambdas will get adopted by the Standard around 2010 if we are lucky, and then it would take another 5 years for the compiler vendors to catch up :mad: Well, at least we have real destructors :)


      Programming Blog utf8-cpp

      N 1 Reply Last reply
      0
      • N Nemanja Trifunovic

        Haven't used _T() in a while :) (yeah, Linux...) Anyway, if you ask me, the true advantage of C# over C++ is that it is developed by Microsoft, and not the "Standard Comitee". Heck, they (MS) managed to turn a joke that C# 1.0 was into the most advanced mainstream language[^] (this story about MS products getting decent around version 3.0 seems to have something about it after all) and we are still hoping that type inference and lambdas will get adopted by the Standard around 2010 if we are lucky, and then it would take another 5 years for the compiler vendors to catch up :mad: Well, at least we have real destructors :)


        Programming Blog utf8-cpp

        N Offline
        N Offline
        Nish Nishant
        wrote on last edited by
        #10

        Nemanja Trifunovic wrote:

        Well, at least we have real destructors

        :laugh:

        Regards, Nish


        Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
        Currently working on C++/CLI in Action for Manning Publications. (*Sample chapter available online*)

        1 Reply Last reply
        0
        • C Christopher Duncan

          Does C# have the equivalent of the C/C++ #define? If so, you could just do a #define _T() (which I find almost as clumsy to type as @""). :)

          Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

          M Offline
          M Offline
          Matt Gerrans
          wrote on last edited by
          #11

          Anyway _T() and @"" are not doing the same thing. _T() does L"" for Unicode, nothing for ANSI, whereas @"" allows you to do raw strings (strings that don't process escape characters). In C# you don't have to fool with single- vs. double-byte strings because they are all double byte. You can do the same in a C++ program by using wstring and L"" and then you don't neeed the ugly _T() macro. However, I don't know of any way to do raw strings in C++. Yes, C# does have a limited #define, but it -- thankfully -- doesn't do macros. It is just for #ifdef/#ifndef kind of stuff.

          Matt Gerrans

          1 Reply Last reply
          0
          • S Shog9 0

            Yes. I hate, hate, hate typing that stupid macro.

            J Offline
            J Offline
            Jorgen Sigvardsson
            wrote on last edited by
            #12

            Just make the builds unicode. :~ Assuming you don't have the misfortune of supporting braindead win9x OSs...

            -- Transmitido en Martian en SAP

            L S 2 Replies Last reply
            0
            • J Jorgen Sigvardsson

              Just make the builds unicode. :~ Assuming you don't have the misfortune of supporting braindead win9x OSs...

              -- Transmitido en Martian en SAP

              L Offline
              L Offline
              Luis Alonso Ramos
              wrote on last edited by
              #13

              Joergen Sigvardsson wrote:

              Just make the builds unicode.

              It has been a long time, but doesn't in Unicode builds "" still produce ANSI strings? L"" is a Unicode string:

              #ifdef _UNICODE
              #define _T(str) L#str
              #else
              #define _T(str) str
              #endif
              

              or something like that.

              Luis Alonso Ramos Intelectix Chihuahua, Mexico

              Not much here: My CP Blog!

              J 1 Reply Last reply
              0
              • J Jorgen Sigvardsson

                Just make the builds unicode. :~ Assuming you don't have the misfortune of supporting braindead win9x OSs...

                -- Transmitido en Martian en SAP

                S Offline
                S Offline
                Shog9 0
                wrote on last edited by
                #14

                Joergen Sigvardsson wrote:

                Just make the builds unicode.

                I do. But even then, my choices are between _T("String!") and L"String!" - with the latter making it troublesome to re-use some code in non-Unicode apps.

                1 Reply Last reply
                0
                • L Luis Alonso Ramos

                  Joergen Sigvardsson wrote:

                  Just make the builds unicode.

                  It has been a long time, but doesn't in Unicode builds "" still produce ANSI strings? L"" is a Unicode string:

                  #ifdef _UNICODE
                  #define _T(str) L#str
                  #else
                  #define _T(str) str
                  #endif
                  

                  or something like that.

                  Luis Alonso Ramos Intelectix Chihuahua, Mexico

                  Not much here: My CP Blog!

                  J Offline
                  J Offline
                  Jorgen Sigvardsson
                  wrote on last edited by
                  #15

                  Yes, you'll need the L prefix, but that is in my opinion a minor peeve compared to _T().

                  -- Please rise for the Futurama theme song

                  1 Reply Last reply
                  0
                  • N Nish Nishant

                    :) prop [tab] [tab] obj.someevent += [tab] [tab] It's awesome!

                    Regards, Nish


                    Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
                    Currently working on C++/CLI in Action for Manning Publications. (*Sample chapter available online*)

                    P Offline
                    P Offline
                    peterchen
                    wrote on last edited by
                    #16

                    But Nish! That's you, aka "the C++.NET guy"! But yes, you make an absolutely important point. Languages today are judged not just inside the domain of "programming languages in general/theory", but how well they work together with IDE tools.


                    Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers!
                    We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                    Linkify!|Fold With Us!

                    1 Reply Last reply
                    0
                    • P peterchen

                      no _T(), bug @"c:\temp" I mean, really.


                      Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers!
                      We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                      Linkify!|Fold With Us!

                      P Offline
                      P Offline
                      peterchen
                      wrote on last edited by
                      #17

                      5 words, and a full spelling bug :doh:


                      Developers, Developers, Developers, Developers, Developers, Developers, Velopers, Develprs, Developers!
                      We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                      Linkify!|Fold With Us!

                      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