Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
Hello.

I'm now studying C# myself. From the internet I can found what is C# and many merits than other language. But I can't realize what the exactly merits does C# have.

Could anybody notice me what the merits does C# have and differences between C/C++ very simply? Because I'm not good at English so I can't understand long sentences articles.

Always thank you.
Posted
Comments
BillWoodruff 20-Nov-13 20:51pm    
As RyanDev suggests here, I think if you post this question on the C# forum, that would be useful to you.

This is the quick answer forum; whereas, this is really better suited for the C# discussion forum since you really need a discussion instead of quick answer.

I would recommend posting here http://www.codeproject.com/Forums/1649/Csharp.aspx[^] and then also reading about it on msdn.
 
Share this answer
 
Comments
WuRunZhe 20-Nov-13 19:49pm    
Oh, thank you. But I've said on article. I'm not good at english and there is no articles written about merits on C# forum.
ZurdoDev 20-Nov-13 20:54pm    
The discussion forum is for discussions so it works better for you to ask various questions and get feedback from people.
BillWoodruff 20-Nov-13 20:49pm    
+5 Excellent suggestion.
 
Share this answer
 
http://stackoverflow.com/questions/686483/c-sharp-vs-c-big-performance-difference[^]

Refer this link for comparison based on performance
 
Share this answer
 
It's using the .NET Framework and compiles to an interpreted language (named IL or in case of C# and Visual Studio to MSIL) which gets interprated by the .Net Runtime.

It's probably closer to Java than C/C++ (other than the name) as both rely on an interpreter to do the work for them.

Warning: Probably a bit biased as I use C# a lot more than C++ ;)

Advantages of C#:
- You don't need to care about x86 or x64 or if it's Windows a lot as the interpreter will take care of that. (There is also a .Net for Linux called Mono, yet it might not offer all the features that Microsoft.Net does)
- It's much more difficult to write code that messes too much with your computer as the access goes through
- You get access to all those awesome functions offered by the .Net Framework.


The disadvantages of C#:
- As the code gets interpreted instead of directly executed it's slower than C++. As long as your not doing any time critical things, you're probably just fine. (You CAN make them into native applications however using NGEN (Native Image Generator))


There are probably much more features and differnces for both languages. I like C# just because it looks cleaner to me.


It's not better or worse than C/C++. Use the right tool for the right job.
 
Share this answer
 
Comments
BillWoodruff 20-Nov-13 20:40pm    
"As the code gets interpreted instead of directly executed it's slower than C++." This is not exactly a clear picture of how C# compiles code to IL, and uses JIT compilation, and caching, and, in many cases, C# code can be as fast as C++: it all depends on what your application is doing.
C# was invented by Microsoft to replace VB.Net. It didn't succeed, but, in terms of usage, it has become a major language in its own right. It was a .NET only language - which, of course, is convenient for Micro$oft O/S's

It is viewed by some as a lighter version of C++. It has fewer choices (all C# code is managed), and thus it eliminates syntax that would be used to differentiate between managed and unmanaged declarations. C++ lets you mix managed and unmanaged code essentially at will (IJW = It Just Works). I use this for very specific designed data structures.

In addition, it's not fully compiled (C and C++ are) - but is mostly compiled. At runtime, as components are actually used, the compilation is completed "Just In Time", often abbreviated as "JIT". Once compiled for that instance of an application, it remains compiled and additional executions for that instance will be a bit faster.

Micro$oft strongly pushes C# (vs. C++) in its Visual Studios - with more extensive help and functionality (such as LINQ) - which in my opinion is to pull people from C++.

If this is your first go-round with a C-style language, it'll let you concentrate on more on basic programming techniques. If you have need of really controlling how, when, and where thing are occurring (and need more speed) then you'll move on to C++.

The preceeding is nuanced with personal opinion.

 
Share this answer
 
Comments
johannesnestler 20-Nov-13 9:27am    
Just a quick remark: C# code can be native (but I agree this is not used very often). Did you never wonder about C# keywords like fixed, stackalloc etc. (e.g. http://msdn.microsoft.com/en-us/library/cx9s2sy4(v=vs.110).aspx) .
Btw. Have you used VS latest version (2013) to work with C++? What the IDE does on IntelliSense and background compilation is just "wow" - you get the C# felling with C++ now. So maybe your argument VS is "pulling" is not true (you mentioned LINQ, - functional programming features (lambdas) arrived to C++ too... http://blogs.msdn.com/b/vcblog/archive/2013/11/18/announcing-the-visual-c-compiler-november-2013-ctp.aspx )
W Balboos, GHB 20-Nov-13 9:36am    
I'll be downloading VS 2013: you've certainly peaked my interest!

It was always very frustrating to be obviously marginalized.* Perhaps they gave up trying to 'persuade' their users?

* Once upon a time, using the MS Interoperability, I could only find help for VB/C# .NET. The function wouldn't work until I figured out that for C++ I needed to add an extra 15 arguments (all effectively null).

So it's off to MSDN for me!
johannesnestler 20-Nov-13 10:04am    
Maybe they gave up :-) yes, even on the WindowsPhone platform the "realized" Silverlight is "not enough" ..
BillWoodruff 20-Nov-13 20:48pm    
"nuanced with personal opinion." ... what a wonderful phrase ! :)

I totally disagree with your assertion that MS developed C# to replace VB.NET: Microsoft (Anders and friends) developed the .NET FrameWork, CIL, etc. as the next generation host for many programming languages, including C++, C, F#, and VB.NET.

Your statement "C# did not succeed" is truly fantastic ! C# is a stunning success, used by millions of developers, and it co-exists with C/C++ quite well.

You state that C# "eliminates syntax that would be used to differentiate between managed and unmanaged declarations." Asolutely wrong: you can demarcate unmanaged code in C# with "Unsafe" syntax.

The ideas that Microsoft created Linq to "pull people from C++" is another absolute whopper.

I suggest you study the history of .NET and C#.
W Balboos, GHB 21-Nov-13 6:58am    
You perhaps should reread my comments more carefully.

C# did not succeed was obviously in the context of "to replace VB" - which did not succeed. And the VERY NEXT sentence in the same paragraph states it became a major language. Your comment that implicates it as a "Whopper" is thus totally wrong.

You refer to why MS developed the .NET framework - and what does that have to do with my statements? .NET wasn't devleoped for C# - but vis versa. Which is what I wrote - as C# development, certainly at its inception, required the .NET framework. Thus, C# would lock people into Window. Certainly to begin with.

As to why it was deleloped? It was quite a long while ago, but I was given that concept from a number of articles I read at the time (on the then-new C#). I have not interest in VB.NET, so I'd have no interest in what MS thinks about it. Other articles called it a Java knock-off, too - that was in an intro to a book on C# I had before Hurricane Sande decided that many of my books needed a good salty rinse.

As for the demarcation. In C# you would have something like System.Windows.SomeClass.someValue whilst in C++ it would look like System::Windows:SomeClass->SomeValue (or .SomeValue). The forgoing is what people use - especially a new developer. There is, to my fragile eyes, no difference between . and . in the C# version -> and thus, that they are referring to different types of items. A namespace isn't a class, and I personally feel it's better to designate them separately.

With that simplification, along with not worrying about how you declare a pointer (* vs ^), or if a pointer at all, makes it more difficult to learn for a beginner. That, and MS's leaving it out of most of the help system, and originally no connection with LINQ, difficulty in using interoperability (vs. C#), etc., certainly helped it draw its large crowd of users.

I currently am encouraging the director of IT to learn C# - for now he uses VB6 - so despite your perception, I'm not against C#. I DO see it as C++ Light.

Last note - related to carpentry but applicable to reading something you disagree with: measure twice - cut once




This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900