Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Should I learn C or continue C++
1 point by ARR on Feb 1, 2010 | hide | past | favorite | 5 comments
The first programming language I was introduced to was directly Java (Not including web languages). Java was taught in our school so I had to learn it. Because it was my first introduction to programming I took a great deal of interest in Java and went beyond our school syllabus. After I left school (i.e passed 10th grade in my country)I stopped continuing with Java. I became inclined towards web development more.

But soon, the next year in the 11th grade, my syllabus included C++ instead of Java. But the syllabus of C++ was very weak and barely included anything. Plus they were teaching a form of C++ that was only compatible with turbo-c++ and thus very old. I surely stopped learning from them and took it upon myself to learn C++ from the internet tutorials. But the interest aspect wasn't that high because of the lack of encouragement from the institution. I was soon deviating more towards python as it seemed to be one of the good programming languages used to create applications on Ubuntu and I wanted to make my own applications. Python attracted me. It really charmed me in no way other programming languages that I had seen or learnt had. After that I thoroughly started learning python and did only that much of C++ that I needed and a little more.

But these few days, I have been reading a lot of articles regarding the awesome speed of C. I had never in my life even took as much as a glance towards C. I really want to do mainstream programming. What should I do about it? Should I continue to learn C++ and take it to a more advanced level or should I try and learn C also as it is so much in demand. C or C++?




As a former C++ programmer, I would say stick with C++ BUT be aware that its a dificult language with lots of tricky undefined behavior and hidden traps that even professional C++ programmers often forget about. [1]

The reasons for stickling with C++ being that you get such things as classes, RAII, runtime type info, the STL and templates.

C is probably a good bit easier to learn, though.

"the awesome speed of C"

Thats a trap. Don't listen to it. Really, by the time you're good enough of a programmer that speed matters, you'll be good enough to make other, seemingly slower, languages fast enough. Most speed is held back because the program simply isn't compute bound. Writing in super efficient highly-optimized assembly isn't going to make a program which blocks reading files or network sockets go any faster. Also, good data structures and algorithms do a lot more for performance than the inherent speed of the language. For example, in another comment I stated that I managed to get a python program take 20 minutes, down from 1.5 hours, by using a tool to translate it to C - but then rewrote the bottleneck in python, with a better data structure, and it ran in 40 seconds (at which point converting it to C actually made it slightly slower).

Very few programs really need to be so fast that writing in C is worthwhile and by the time you find your language to be the limiting factor, you should be a much more experienced programmer and picking up C then will be a lot easier.

My final advice is to pick a higher level language - Clojure, while fundamentally different from C++ and Java, is a very powerful language with lots of very high level abstractions (and streamlined access to Java code, so your Java skills will translate nicely to Clojure). If you're looking for a more mainstream, easy to learn language, I would suggest Python or Ruby - both of which are great high level languages and will serve you well, even if, in the future, you learn C.

[1] http://scapecode.com/?p=107


That certainly does simplify things in my mind. Thank you. I will leave C for such a time that I need it. I will continue on my path with python because I have come a long way. Thanks.


You're welcome. Glad to be of help.


Why is it so difficult finding good C++ prigrammers? I need a few good hands for lots of projects. -Ernest


Why is it so difficult finding good C++ programmers?

I imagine its because C++ is a hard language. I mean, its easy to program in C++ - but its difficult to program well. Its a large and complicated language, which, alongside its own problems, also inherits C's problems. This makes it a tough language to master and I guess most of the truly great C++ programmers have already been hired.

(PS: I won't claim to be a good programmer (C++ or otherwise), but I will be available for contract work soon, in case your needs for those projects happen to overlap with my skillset. Details in my profile, if interested)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: