

Ask HN: Should I learn C or continue C++ - ARR

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.<p>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.<p>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++?
======
dkersten
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>

~~~
ARR
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.

~~~
dkersten
You're welcome. Glad to be of help.

