C# vs c++

hi

yesterday i heard the same in fifth or sixth time.
“c# and .Net are buggy and really not powerful instead of c++”

for me it’s clear that all depends on goals.
for me it’s clear that for our purposes we have most powerful multipurpose toolkit
for me it’s clear that we should believe devvvvs

can anybody please explain to me, why we use c# here instead of c++
the best way of explanation is like presented here

or with a simple table should look something like

||goal |c# |c++

easy access to …| yes | no

time to do…| 10 mins | 3 days||

etc. thanks)

I don’t know c#, but from what i have seen it seems to be closer to java than c++. If so, important features are significantly different(interface implementation, inheritance, memory management and pointers). C# is proprietary language owned by Microsoft, the platform which vvvv is developed. Maybe accessing some of the API’s like DirectX is optimized by implementing native language(in the same way objectiveC is used for all the core image technologies on the Mac).
Good news, if c# is like java it is also easier to use than c++. However, it would be cool to have a c++ wrapper for writing plug ins in vvvv and have access to all the super nice feature of the language(smart pointers, generic programming, containers, etc.)

C Sharp is somehow different in the head, in the way to program.
in C sharp the function library .NET is in all the time evolution.
in C sharp you need to install runtime on the machine, where a C programm will use dll in autonomy.

But if I had really some time and have to make once again the choice, I would not in 2011 learn C++ but C Sharp. More powerfull, more easy.

Hey karistouf:
can you be more specific about the more powerful features of c# over c++? rather curious 'bout that perspective

just google the topic…

Well, if you want to code in C or C++, for example some visual effect .NET is really a very well all-integrated library… you don t really need to think and search for a library doing the stuff and find a way to integrate it with your others libraries. ( and sometimes deal with internal fights between libs)

You dont have to deal in C SHarp with low level code and instructions.
Far more easy it seems. But I m not coding in CSharp.
I m just giving you my impression when looking for code around and there and seeing that .NET is providing more easier solution very quickly to a lot of programming questions.

Basically I m a C gui. C is strong, short and not consumming ressources. BUT… less easy for global developpement.

For example WhiteCat is integrating different libraries for the following topics:
-graphics + windows handling
-kbd inputs & mouse
-timers
-sound
-midi
-video in + OpenCv

Despite openCV, everything is accesible from .NET.

ask google first, of course))) thanks tonfilm) very first was exactly i need

@karistouf. wow) thanks

hanks for your very first link bo27. it s a very good link, and really I keep my idea that if I had time to put in learning a new language, definitively it would be C Sharp

Hey, thanks for the c# pointers(what a funny line that is!).

That is not completely true, you can find c# full language specifications online and build your own compiler, they are owned by ecma now if i remember right. c# language is open, .net framework (owned by microsoft) is proprietary.

You can also write plugins in c++, which will be a mixed mode assembly. Stucture Synth/Box2d are built in c++ amongst other plugs.

Ok now on features, using both languages on a daily basis, with some preferences for one against other depending on the case.

  • c# use managed memory, so you don’t have to care as much as c++ for memory leaks (although you can do code which will have leaks in c#). On the other hand you can make very efficient memory allocators in c++ (stuff like SBA would be a pain in c#).

  • c# pointers support, even if possible, is very limited, some operations are just much easier using pointers, some are not.

  • c# threading system is great for background tasks, but i find options for threading large arrays processing in c++ much more efficient.

  • c++ compilation can be much more tricky compared to c# (all linker issues with the most cryptic messages can be let’s say… fun).

  • c++ is a very static language compared to c# (class reflection). Biggest advantage of c# for me. stuff like Activator.CreateInstance with dynamic assembly loading and listing is just awesome.

  • c# (only .net framework as mono does implement it) has no memory alignment support, so any sse code is not possible in plain c#. For me it’s the biggest advantage of c++ against c#.

  • c++ has a really nice bunch of libraries, some having no equivalent in c# (you can find wrappers but they rarely as up to data as the c++ version). And including a header file to access dll function is quite much cleaner than P/Invoke.

  • performance wise: depends a lot on what you try to do, but lots of c# functions are highly optimized (benched standard c# math against c++ ones and perfs are the same). You can make c++ code faster if you really know what to do, but in most cases I would say your code will be at best equivalent (unless you start to go into simd programming).

  • Stability wise: depends more on the coder than the language :)

Hope the list helps.

thx vux, very useful! still preferring c++ (for openframeworks) :-)

Indeed, thanks vux

thanks vux! great