i am new with c programming and i try to decide to learn which one.thats why i have a question.whats the difference between c,c++ and C#.which one is more useful nowadays?

thanks.

04-28-2011

CommonTater

That's kind of a loaded question... You're about to get everyone touting their favorite language and possibly a firestorm debate about the merrits and flaws of each.

C, C++ and C# are all "C-like" languages, but they are different languages.

Speaking only for myself...

I would rule out C# because it is an interpreted lanugage that realies upon a rather massive .NET infrastructure to work.

C++ is very popular right now because it works on the "Object Oriented Programming" (OOP) model and makes code re-use and code-hiding very easy. It has the advantage of a greatly expanded run-time library but it also suffers the complexity of a greatly expanded run-time library... learning C++ is a real challenge and even though I work on it a little bit each day, it still overwhelms me.

I've chosen (for now) to stay with C-99, "standard C" as it's a function based language with enormous capability from a relatively small compiler and library. However, it's not in high demand anymore, having been largely replaced by C++.

My advice --if I dare in this case-- would be to learn standard C first then make the jump to C++... The advantage being that C++ compilers will compile C programs so by the time you get to C++ you're half way through the new language.

04-28-2011

laserlight

I am moving this thread to General Discussion, but as CommonTater noted this kind of threads tend to spiral out of control, so don't be disappointed if the thread is eventually closed.

Quote:

Originally Posted by Lisyus

i am new with c programming and i try to decide to learn which one.thats why i have a question.whats the difference between c,c++ and C#.which one is more useful nowadays?

Why do you want to learn programming? If it is purely out of interest, then forget about what is useful. Pick one, then another, then another, and just have fun. If there is also the academic element, e.g., you will be learning something in school that involves programming, then what is useful is to find out what programming language will be used, and learn that. If you have something more specific in mind, then what is most useful to you could be determined by that.

Quote:

Originally Posted by CommonTater

My advice --if I dare in this case-- would be to learn standard C first then make the jump to C++... The advantage being that C++ compilers will compile C programs so by the time you get to C++ you're half way through the new language.

That said, if you attempt to make use of your C knowledge too much when learning C++, you may actually retard your progress because you would reach for C-style solutions where C++-style solutions are more appropriate in C++.

04-28-2011

Mario F.

Quote:

Originally Posted by Lisyus

Which Language

English.

No, really. Even if you are programming for another idiom, always use English when naming variables and other objects or making comments on the code.

04-28-2011

MK27

Learning C will provide you with a more fundamental education as far as lower level computer science concepts are involved for a number of reasons:

1) because the memory management is manual
2) because of the nature of c-strings
3) because there is an emphasis on the use of bit manipulation (shifting, flagging, etc).

That may or may not make the language more useful -- for some things, it makes it less, but according to TIOBE Programming Community Index for April 2011, C is actually used about 60% more than C++ and twice as much as C# worldwide:

So, contra to some claims, it is far from a "dead" or outdated language. C would be the language of choice for high-performance applications with a minimal memory footprint, and provide the broadest range of possible settings for its use.

C++ can be less tedious to program in, and performs as well, but tends to use more memory (even if some people are in denial about it, lol). It's also more complex. I started learning C, then C++, and it's a path I recommend, but if you are really drawn to C++ now then go for it.

C# is I think not used much except on Microsoft systems, so if you are looking for a language not bound to (and controlled by) a specific corporation, don't choose C#.

Quote:

Originally Posted by laserlight

if you attempt to make use of your C knowledge too much when learning C++, you may actually retard your progress because you would reach for C-style solutions where C++-style solutions are more appropriate in C++.

This is true, the temptation is always to do something in a way you know works, rather than investigate something new. However, if you are conscious about it and make an effort to see the difference, you can decide for yourself the value of some particular "c-style" solution in relation to its potential counterpart. Sometimes I see the C++ light, other times I think it is a little obsessive compulsive. C++ is very interesting, fer sure.

04-28-2011

anduril462

To follow up with what laserlight and MK27 have said, the difference between learning C and C++ well is not just some minor syntactic differences, public and private members, inheritance, etc. The difference between procedural programming (C) and object oriented programming (C++) are really more about different ways of thinking and solving problems. The language used is just a tool for implementing those solutions. I personally grew up on Pascal and C for far too long before being introduced to serious OOP, and have had a very difficult time making the transition. I still write OOP with a procedural influence, kind of like speaking a foreign language with an accent. My grammar and vocabulary is quite good, but you know I'm not a native speaker. As for yourself, learn them both, perhaps somewhat in tandem. Find a problem to solve, and try it in C, tackling it in a procedural manner. Try solving it in C++ using good OOP methodologies. Once you have a solid grasp of both languages and problem solving paradigms, see how many OOP features you can implement in C. I think the following site has some good info/advice on learning programming: Teach Yourself Programming in Ten Years.

04-28-2011

C_ntua

Do you want to learn OOP? Of course at this point you probably have no idea. Do you want to focus on low-level programming? Maybe again this question is pointless without starting programming.

Let's set up an environment for both options. For this you need C++, not C. With C++ you can compile, as mentioned, low-level code and OOP code. So you keep your options open. If you decide later on to go purely to C, then you can skip C++. Learn the few differences of C++ and C and that is it.

Furthermore, somethings are much easier in C++, like using a string. This can be nice for a beginner that wants to do something simple as an input/output without having to worry about ranges. Again, there are more options in C++ that are helpful to teach programming.