C or C++ or C# ...that much difference?

Started by
6 comments, last by smr 18 years, 9 months ago
Ok, I'm new here and am not sure if this has been posted laready or not. I was wondering what the big difference between C and C++ and C#. I know that C++ is is OO, and that C# works with the .net stuff. Aside from these things, the main thing I was wondering is if you know C++ for instance do you pretty much know or at least be able to use fairly well the other 2 C and C#? Are they that different syntax wise? Thanks, Dark savant
Advertisement
The biggest things to learn in programming are not a single language... it is the logic, structure, algorithms, and design patterns. If you know either in the AdaC family than you will be able to learn the others if needed quite quickly.

Here at work most of the guys were C++/Java programmers and came here with no C# knowledge but were using the language within a week or two. On the other side there were also a few guys that hadn't used C++ and learned the language quite quickly.

Although to answer your first question the biggest difference between native C++ and C# is that C# is compiled to MSIL and JIT to native code when run and utilizes the .NET framework. This can also be done with managed C++ / CLI C++ as well. The gap widens when you compare C to OOP C++ and C# because of the procedural paradigm that C programming traditionally utilizes.

I can tell you from experience that the majority of my time spent on projects is not implementing code, but the design and architecture.
If you know C++ then you already know C. C++ is a superset of C. C++ can work with .NET. C# is another language that Microsoft created to look like C++ so that C++ programmers would feel more comfortable to it.
Syntax wise they are relatively similar. If you know C++ you can probably read C or C#, and if you know C you can probably read C# or C++ with a little effort and so on. However, reading the different languages is a very different skill from writing in the languages. Each language fosters a different set of idioms and best practices.

For example, in order to do proper resource management in C++ requires undertand and using RAII. In C you need to get used to longjmps and gotos. In C# it requires understanding how garbage collection works.

So even if you know one, you'll still need to put in extra time to become proficient in the others.
Quote:Original post by smr
If you know C++ then you already know C.

I wouldn't say that at all. Considering C is a completely different programming paradigm and structure. Not to mention that people that were taught to write in good style standard C++ such as std::string, std::vector, etc might not know all the ins and outs of the C style IO, etc.
Quote:Original post by smr
If you know C++ then you already know C. C++ is a superset of C. C++ can work with .NET. C# is another language that Microsoft created to look like C++ so that C++ programmers would feel more comfortable to it.


C++ beign a superset of C means that if you know C then you can work in C++. Not the other way around though. I recently had to move to pure C for work, and it was a somewhat jarring experience. I had to get used to a) weird ways of declaring structures, b) no variable declaration in the middle of a function, and c) a compiler that has different requirements.

(an example of C's "different requirements" is that if you try using a function without declaring it first, all you get is a *warning*. The compiler tells you that "I don't know this function, but I'm assuming it's void and returns an int!". I wasn't used to actually reading the warnings, because in C++ anything that serious gets an error. So that one issue alone caused lots of bugs for me).
Quote:Original post by Dark savant
I know that C++ is is OO


Its not quite correct C++ is a multi-paradigm language, its not just OO and doesn't force you to do so. In C++ you can do procedural, OO, generic, generative and even functional style programming (not with native C++ though requires library help).
Quote:Original post by Saruman
Quote:Original post by smr
If you know C++ then you already know C.

I wouldn't say that at all. Considering C is a completely different programming paradigm and structure. Not to mention that people that were taught to write in good style standard C++ such as std::string, std::vector, etc might not know all the ins and outs of the C style IO, etc.


True. I should have been more clear. I wasn't really referring to being proficient with the language. Someone who knows C++ should be able to write a working C program.

This topic is closed to new replies.

Advertisement