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. a C# version of c++ can be created?

a C# version of c++ can be created?

Scheduled Pinned Locked Moved The Lounge
csharpc++questionannouncement
36 Posts 16 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.
  • G Glenn Dawson

    BTW, private members do get inherited, you just cannot access them in the derived class. See Derived Class Access to Base Class Members in http://msdn.microsoft.com/en-us/library/ms173149.aspx[^]

    A Offline
    A Offline
    AspDotNetDev
    wrote on last edited by
    #24

    Glenn Dawson wrote:

    BTW, private members do get inherited, you just cannot access them in the derived class

    Sure you can. Just not directly. :rolleyes:

    Thou mewling ill-breeding pignut!

    G 1 Reply Last reply
    0
    • A AspDotNetDev

      Glenn Dawson wrote:

      BTW, private members do get inherited, you just cannot access them in the derived class

      Sure you can. Just not directly. :rolleyes:

      Thou mewling ill-breeding pignut!

      G Offline
      G Offline
      Glenn Dawson
      wrote on last edited by
      #25

      Hehe, I just re-read your post. You said do. It's late. I'm going home now. :)

      1 Reply Last reply
      0
      • N Not Active

        And your point is?


        Failure is not an option; it's the default selection.

        F Offline
        F Offline
        Fernando A Gomez F
        wrote on last edited by
        #26

        Mark Nischalke wrote:

        And your point_er_ is?

        FTFY :)

        1 Reply Last reply
        0
        • N Nish Nishant

          That's still managed code. He wants to use C# syntax and generate native code.

          Regards, Nish


          My technology blog: voidnish.wordpress.com

          K Offline
          K Offline
          killabyte
          wrote on last edited by
          #27

          Nish Sivakumar wrote:

          That's still managed code.

          not really

          1 Reply Last reply
          0
          • D Daniel Grunwald

            It may not require a "framework" as extensive as the .NET framework, but C# (as any high-level language) certainly requires some form of runtime library. Even C needs a runtime library, the trick is to have the ability to statically link against only those portions used by your program. Unfortunately C# programs require bit of code - a good portion of the BCL (strings, arrays, etc.), the garbage collector, etc. Mono comes with an mkbundle tool that can create a native executable from managed code. Unfortunately the static linking option is not available for Windows.

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

            Daniel Grunwald wrote:

            not require a "framework"

            It's more that it shouldn't require a virtual machine, but even that may be too generic a term.

            Daniel Grunwald wrote:

            Even C needs a runtime library

            Basically, yes, but is that technically true? Can't you compile and run a program that doesn't link to and use any libraries? Certainly you can write a program that doesn't # include anything. As a simple example:

            int
            main
            (
            int argc
            ,
            char* argv[]
            )
            {
            return ( argv==0?-1:argc ) ;
            }

            This works, but obviously with no IO it can't do much. Does this example use the "standard library"? Is it not possible to use a completely different library instead? D is similar, and includes garbage collection -- I don't know whether or not you can compile without the "standard library".

            Daniel Grunwald wrote:

            a good portion of the BCL (strings, arrays, etc.), the garbage collector, etc.

            Yes, but in theory you should be able to write a C# program without ever saying System:

            namespace Test
            {
            public static class C
            {
            public static int
            Main
            (
            string[] args
            )
            {
            return ( args==null?-1:args.Length ) ;
            }
            }
            }

            (Again, there's not much you can do without IO.) Such a program could be compiled against some minimal* implementation of BCL. I don't care whether or not it's statically linked (that's just implementation details :-D ), as long as it works. What I'm more concerned about is that the underlying structure (framework, virtual machine, whatever) needs to have a concept of System.IDisposable and System.IEnumerable in order to compile the language. * Just enough to support the language -- object, int, string, etc.

            D J 2 Replies Last reply
            0
            • P PIEBALDconsult

              Daniel Grunwald wrote:

              not require a "framework"

              It's more that it shouldn't require a virtual machine, but even that may be too generic a term.

              Daniel Grunwald wrote:

              Even C needs a runtime library

              Basically, yes, but is that technically true? Can't you compile and run a program that doesn't link to and use any libraries? Certainly you can write a program that doesn't # include anything. As a simple example:

              int
              main
              (
              int argc
              ,
              char* argv[]
              )
              {
              return ( argv==0?-1:argc ) ;
              }

              This works, but obviously with no IO it can't do much. Does this example use the "standard library"? Is it not possible to use a completely different library instead? D is similar, and includes garbage collection -- I don't know whether or not you can compile without the "standard library".

              Daniel Grunwald wrote:

              a good portion of the BCL (strings, arrays, etc.), the garbage collector, etc.

              Yes, but in theory you should be able to write a C# program without ever saying System:

              namespace Test
              {
              public static class C
              {
              public static int
              Main
              (
              string[] args
              )
              {
              return ( args==null?-1:args.Length ) ;
              }
              }
              }

              (Again, there's not much you can do without IO.) Such a program could be compiled against some minimal* implementation of BCL. I don't care whether or not it's statically linked (that's just implementation details :-D ), as long as it works. What I'm more concerned about is that the underlying structure (framework, virtual machine, whatever) needs to have a concept of System.IDisposable and System.IEnumerable in order to compile the language. * Just enough to support the language -- object, int, string, etc.

              D Offline
              D Offline
              Daniel Grunwald
              wrote on last edited by
              #29

              PIEBALDconsult wrote:

              Basically, yes, but is that technically true? Can't you compile and run a program that doesn't link to and use any libraries? Certainly you can write a program that doesn't # include anything.

              That depends. Built-in C language features may very well map to library functions - think embedded CPUs with a software floating point library. As soon as the language has more features, inevitably some of them will need a runtime library. For example the new operator in C++ will need a malloc implementation or similar. And then there's exceptions, dynamic_cast, ...

              PIEBALDconsult wrote:

              What I'm more concerned about is that the underlying structure (framework, virtual machine, whatever) needs to have a concept of System.IDisposable and System.IEnumerable in order to compile the language.

              Why is that a concern, but string isn't? IDisposable and IEnumerable are trivial interfaces, strings and arrays are much more complex. There are actually quite a few types in .NET that are well-known to the compiler, many more than you think. decimal is just a struct, nothing special on MSIL level. And then there are at least these types that any C# compiler will need: * Type - for typeof() * Array - base class for arrays * Attribute - base class for attribute, required for the disambiguation rule in ยง17.2 * ValueType - base class for structs * Enum - base class for enums * Delegate - base class for delegates * Exception - base class for exceptions * IEnumerable and IEnumerator - for foreach * IEnumerable<T> and IEnumerator<T> - for yield return * IList<T> - interface implemented by arrays * IReadOnlyList<T> - interface implemented by arrays in .NET 4.5 * Task and Task<T> - for async/await * Nullable<T> - nullable operator lifting etc. * IDisposable - using statement Of course there are many more, e.g. attributes that have special effects (ParamsAttribute etc.), but those can be said to be specific to the .NET implementation of C#, they aren't necessary in general. Still, the abov

              1 Reply Last reply
              0
              • L Lost User

                Actually, that would suck. There are many nice things about the C# syntax, but then we'd suddenly lose templates (generics do not replace them), classes couldn't go on the stack (that will really hurt), there would be no private or protected inheritance, no friend functions/classes, half of the operators that are useful when working with pointers wouldn't exist, and I could go on for a while but maybe you get the point. On the other hand if you said "just imagine C# compiling to native code directly instead of going through MSIL", then yes, I would love that (just so long as we get to keep the nice compilation model - no linking please!). It would kill some parts of reflection, but I wouldn't mourn the loss.

                J Offline
                J Offline
                jschell
                wrote on last edited by
                #30

                harold aptroot wrote:

                classes couldn't go on the stack (that will really hurt),

                How so? Surely you don't pass most class instances via the stack?

                harold aptroot wrote:

                half of the operators that are useful when working with pointers wouldn't exist,

                The OP specifically said that pointers exist so why would the operators associated with them not exist?

                L 1 Reply Last reply
                0
                • P PIEBALDconsult

                  Daniel Grunwald wrote:

                  not require a "framework"

                  It's more that it shouldn't require a virtual machine, but even that may be too generic a term.

                  Daniel Grunwald wrote:

                  Even C needs a runtime library

                  Basically, yes, but is that technically true? Can't you compile and run a program that doesn't link to and use any libraries? Certainly you can write a program that doesn't # include anything. As a simple example:

                  int
                  main
                  (
                  int argc
                  ,
                  char* argv[]
                  )
                  {
                  return ( argv==0?-1:argc ) ;
                  }

                  This works, but obviously with no IO it can't do much. Does this example use the "standard library"? Is it not possible to use a completely different library instead? D is similar, and includes garbage collection -- I don't know whether or not you can compile without the "standard library".

                  Daniel Grunwald wrote:

                  a good portion of the BCL (strings, arrays, etc.), the garbage collector, etc.

                  Yes, but in theory you should be able to write a C# program without ever saying System:

                  namespace Test
                  {
                  public static class C
                  {
                  public static int
                  Main
                  (
                  string[] args
                  )
                  {
                  return ( args==null?-1:args.Length ) ;
                  }
                  }
                  }

                  (Again, there's not much you can do without IO.) Such a program could be compiled against some minimal* implementation of BCL. I don't care whether or not it's statically linked (that's just implementation details :-D ), as long as it works. What I'm more concerned about is that the underlying structure (framework, virtual machine, whatever) needs to have a concept of System.IDisposable and System.IEnumerable in order to compile the language. * Just enough to support the language -- object, int, string, etc.

                  J Offline
                  J Offline
                  jschell
                  wrote on last edited by
                  #31

                  PIEBALDconsult wrote:

                  Basically, yes, but is that technically true? Can't you compile and run a program that doesn't link to and use any libraries?

                  In terms of practicality it is true. If one wants to write real applications with a language in a realistic amount of time then it will need supporting 'libraries'. The term 'library' can have a nebulous meaning since, for example, perl (the language) can write to the files and the console without a 'library' but C/C++ cannot. However the same functionality that exists in C/C++ for that must then be embedded in the language itself. And for modern enterprise applications attempting to embed every needed feature in the language itself isn't going to be feasible.

                  1 Reply Last reply
                  0
                  • J jschell

                    harold aptroot wrote:

                    classes couldn't go on the stack (that will really hurt),

                    How so? Surely you don't pass most class instances via the stack?

                    harold aptroot wrote:

                    half of the operators that are useful when working with pointers wouldn't exist,

                    The OP specifically said that pointers exist so why would the operators associated with them not exist?

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #32

                    jschell wrote:

                    How so? Surely you don't pass most class instances via the stack?

                    Pass? No. But local variables that don't escape would have to use dynamic allocation, and that wouldn't be good. Or they would have to be structs, which isn't always desirable or even possible.

                    jschell wrote:

                    The OP specifically said that pointers exist so why would the operators associated with them not exist?

                    Pointers exist in C# anyway, but not all operators associated with them do. (see my other post)

                    J 1 Reply Last reply
                    0
                    • L Lost User

                      jschell wrote:

                      How so? Surely you don't pass most class instances via the stack?

                      Pass? No. But local variables that don't escape would have to use dynamic allocation, and that wouldn't be good. Or they would have to be structs, which isn't always desirable or even possible.

                      jschell wrote:

                      The OP specifically said that pointers exist so why would the operators associated with them not exist?

                      Pointers exist in C# anyway, but not all operators associated with them do. (see my other post)

                      J Offline
                      J Offline
                      jschell
                      wrote on last edited by
                      #33

                      harold aptroot wrote:

                      Pointers exist in C# anyway, but not all operators associated with them do. (see my other post)

                      As phrased by the OP my take was that they were suggesting that pointers would reflect the semantics of C++, not C#.

                      L 1 Reply Last reply
                      0
                      • J jschell

                        harold aptroot wrote:

                        Pointers exist in C# anyway, but not all operators associated with them do. (see my other post)

                        As phrased by the OP my take was that they were suggesting that pointers would reflect the semantics of C++, not C#.

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #34

                        That makes no sense to me. The pointers in C# are not that different from the pointers in C++. You need an extra unsafe or fixed here and there, but that's about as far as the differences go. But there are two (not very common) operators that just aren't in C#, and OP said nothing about creating them.

                        J 1 Reply Last reply
                        0
                        • L Lost User

                          That makes no sense to me. The pointers in C# are not that different from the pointers in C++. You need an extra unsafe or fixed here and there, but that's about as far as the differences go. But there are two (not very common) operators that just aren't in C#, and OP said nothing about creating them.

                          J Offline
                          J Offline
                          jschell
                          wrote on last edited by
                          #35

                          harold aptroot wrote:

                          That makes no sense to me.

                          The OP referred to pointers, my presumption was that they wanted more than what currently exists.

                          harold aptroot wrote:

                          But there are two (not very common) operators that just aren't in C#, and OP said nothing about creating them.

                          You referred to operators and it could be that that is what the OP is referring to.

                          L 1 Reply Last reply
                          0
                          • J jschell

                            harold aptroot wrote:

                            That makes no sense to me.

                            The OP referred to pointers, my presumption was that they wanted more than what currently exists.

                            harold aptroot wrote:

                            But there are two (not very common) operators that just aren't in C#, and OP said nothing about creating them.

                            You referred to operators and it could be that that is what the OP is referring to.

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #36

                            Oh ok. It's starting to make sense to me. That still leaves all the other problems though.

                            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