Coffeehouse Thread

16 posts

C# + C++ = C#+

Back to Forum: Coffeehouse
  • User profile image
    Ion Todirel

    I have a idea,  a new extension to C# to embeding (C#+ C++ compiler output = mixed assemblies) C or C++ code like this:

    ...

    static void Main()
    {
        ...

        cppcode 
        {
            #include <stdio.h>

            void main()
            {
                printf("%s", "Hello World");
            }
        };

        ...
    }

    what do you think? why Turbo Pascal and C++ can have embedded asm code but C# can't?

  • User profile image
    littleguru

    Please not! this won't happen...

  • User profile image
    MasterPi

    Um, why would you want this to happen?


    You can already call code from files in other languages.

  • User profile image
    Ion Todirel

    im not saying that Microsoft should add this extension to C#, i just want to do this for fun.

    yes you can use P/Invoke - COM Interop, but will be more fun if you can do this:

    int a = 7;

    cppcode <a vara>
    {
        ...
        void Test()
        {
            cout << vara;
            vara = 6;
        }
    };

    ...

    now a = 6.

    inteaction between code in diferent languages will be amazing at this level.

  • User profile image
    androidi

    Inlining different languages seems too messy by looks and would make it hard for compiling too.

    I'm not sure this would work any better but I'd like it more than C++ in a C# method.

    [Language("C")]
    void method(bla bla)
    {
    }


    Or by having partial classes such that one class could have part of it in .cpp .cs etc.. Maybe that is already possible? Haven't tried. Big Smile

  • User profile image
    Shining Arcanine

    Originally when I heard about C#, I thought that it would be C++ with a PHP like syntax, which would incredibly reduce the learning curve for me. That got me very excited over it as I wanted to learn computer programming. It turned out that was never the case. Hopefully your C#+ idea gets off the ground.

  • User profile image
    Ion Todirel

    imagine... for game developers, for stuff that you can't do in C# will be fun.

  • User profile image
    pwzeus
  • User profile image
    Scott Bryen

    wouldbe good although i dont no C++ .. but i like the idea ^^... i mean someone has to make the ultimate lnguage some day lol Tongue Out

  • User profile image
    Ion Todirel

    like this:

    [Language("Assambler", Source="C:/Temp/rwq234.asm")]
    [access modifier] static extern type MethodName(type1 arg1, type2 arg2, ...);

    ya, will be fun

  • User profile image
    W3bbo

    Ion Todirel wrote:
    like this:

    [Language("Assambler", Source="C:/Temp/rwq234.asm")]
    [access modifier] static extern type MethodName(type1 arg1, type2 arg2, ...);

    ya, will be fun


    Putting assembly in .NET assemblies defeats the purpose of .NET in the first place (platform independent programming).

  • User profile image
    Sven Groot

    W3bbo wrote:
    Ion Todirel wrote: like this:

    [Language("Assambler", Source="C:/Temp/rwq234.asm")]
    [access modifier] static extern type MethodName(type1 arg1, type2 arg2, ...);

    ya, will be fun


    Putting assembly in .NET assemblies defeats the purpose of .NET in the first place (platform independent programming).

    That's not the purpose of .Net. Also, by that logic any kind of PInvoke or COM InterOp "defeats the purpose of .Net".

  • User profile image
    Ion Todirel

    so, again what do you think, will be cool right?

  • User profile image
    Ion Todirel

    language interoperatibility, security, productivity.

  • User profile image
    JohnAskew

    I think it's time for "D".

  • User profile image
    Manip

    C# already has the unsafe operator ... What your suggesting will damage both C# and C++... Nobody wins.

    I've said it before and I'll say it again... C++ needs a massive face lift. I don't 'hate' C++ in its current form, and would be extremely unhappy if anyone came along and damaged such a powerful language...

    What needs fixing in C++ is not the language, it is not the power & freedom given to developers; what needs fixing in C++ is the 1980's C library system.

    Why oh why when the C++ standard was created didn't they put in an OO library system?

    Well it isn't too late to fix that problem. And what's more it wouldn't break backwards compatibility... As you could support both the C library system and the OO system concurrently...

    Simply put, I want to see the .Net framework in an unmanaged enviroment...

    No offence to Microsoft but Managed VC++ is a waste of time. You loose C++'s power and flexibility, and gain nothing above what C# allows you to do. So I suggest you either use true C++ or C#.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.