LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Starting with C or C++? (https://www.linuxquestions.org/questions/programming-9/starting-with-c-or-c-229825/)

jplev22 09-12-2004 07:07 PM

Starting with C or C++?
 
I'm thinking getting into programming but I'm not sure what would be better to learn. I know C++ has some programming advantages that make it faster to program some same things in C. On the other hand, most linux programs seem to be still writen in C. Could it be confusing to learn C and then C++? Thanks

leonscape 09-12-2004 07:38 PM

If you start with C++ its easier to learn, if you learn C first, then its hard to get into the right minset for C++, i.e. you learn tricks in C that aren't needed in C++, or in fact are very wrong.

The other way around also has its problems, but I think isn't as hard.

The main thing is what you want to program, and what you are going to use.

irfanhab 09-12-2004 08:00 PM

Well it depends what you want to do

If you want to be a system programmer, a guy who works on the hardware drivers, kernel modules, and that sort of stuff, then you should definitely learn C, which is really good at this

but

If you want to look for application development, like developing KDE applications and so on, then you should look at C++

R00ts 09-12-2004 08:48 PM

I'd recommend learning both personally, for the reasons that irfanhab gave. But if I had to choose, I would start with C. Learning all the advanced C++ topics like templates, virtual functions, and operator overloading are just too much for someone who hasn't programmed before IMO, and makes the learning process longer and more frusterating. That's just my opinion though, you are free to disagree. ;)

scorbett 09-12-2004 09:08 PM

I agree with R00ts: it's easier to learn C than C++, especially if it's your first language. Once you have a decent grasp on C, then you can approach OO programming (if you're still interested). Worked for me, anyway - Pascal and C were my first languages, years before I learned C++. Not sure how well that would have worked had I tried it the other way.

wegster 09-12-2004 11:31 PM

Another comment for C or another reasonable language and then C++ (or Java). I used to teach programming, and can tell from first hand experience the number of people trying to 'avoid' C (or Pascal, it's been a while) and tried to go to C++.....had less than stellar results.

Generally, I agree with the last two few comments- if you're going to want to eventually 'hack' the Linux kernel, write device drivers or other system level programming, definitely C first as you'll primarily be writing to the kernel system calls, which are written in C. If you're going to want to write applications, then I _still_ suggest a non OOP language first, as you'll simply have a better idea of how things work down the road.

C++ is a somewhat over-complicated language, or can be (keywords with several context dependent meanings, multiple inheritance, and others), where C (or others) is simpler syntactically to learn, and will generally still be of use when/if you move to C++, Java, or ? It will also make you appreciate some of the 'niceties' C++ or Java buy you- writing a dozen lines of code versus 100, and give you a better grounding before jumping into the whole Object Oriented paradigm. I'm not 'thrilled' with Java personally, but I've seen a good number of 'Java programmers' that must have learned Java as their first language- that's not bad for some things, but they can have tendencies to having no _clue_ how the underlying OS works if Java doesn't 'hold their hand' (meaning provide an API for doing whatever task is at hand...)

Scott

jplev22 09-13-2004 06:19 AM

Thanks for the advices I think I learn C first. I was thinking of buying pratical C programming for O'Reilly. Good choice for learning?

chrism01 09-13-2004 06:23 AM

There's a few free books/guides on the net eg:
http://www.dwheeler.com/secure-progr...ams-HOWTO.html
http://publications.gbdirect.co.uk/c_book/
http://vergil.chemistry.gatech.edu/r...s/programming/


All times are GMT -5. The time now is 12:50 AM.