HACKER Q&A
📣 akasakahakada

Is C Really That “Difficult”?


Reading introductory C++ books.

Seems like it is just a combination of bad designs that make doing simple things tedious and not being smart.

Any examples that really show the difficulties?


  👤 binarynate Accepted Answer ✓
C and C++ are different languages. It's subjective, but both are generally more difficult than garbage collected languages because you have to think about memory management and they don't have some of the high-level utilities other languages do (like an easy to use timer). IMO, modern C++ isn't too gnarly (it has a nice standard library that with components like smart pointers and containers), but it's still a PITA compared to garbage collected languages because it builds slowly and you do have to think about memory management like I mentioned. C is gnarlier IMO because its standard library is much more bare bones and it doesn't have the built-in smart pointers or containers that C++ has.

👤 GianFabien
Personally I find "modern C++" far more difficult than ANSI C. Due to my lack of competence with C++ I generally stick to writing C code. That is when I'm not writing some quick scripts in Python or web stuff in JavaScript - which for the most part is comparable to C.

If you are finding C++ difficult, perhaps you could learn C first.


👤 gregjor
"Difficult" doesn't describe a property of a programming language. The majority of code most of us run every day, from operating systems to networking to desktop and mobile applications exists because programmers wrote it in C or C++, or some closely-related derivative such as Java, C#, or Swift. So it follows that hundreds of thousands of programmers have mastered these languages over the years, and the languages stand out as tools of choice in many domains.

C came out in the mid-70s, C++ about a decade later, and both still get used to write lots of new code.

Some programmers find C and C++ difficult to learn and master, others don't. That depends on the programmer, not the language. Some people struggle with Python and Javascript too.


👤 bombcar
Pointers are hard for many people.

Once you get past that (really get past it, not just fumble through it) C has a large number of foot guns available.

It's not a difficult language (it only has a few "instructions" if you will) but it is difficult to avoid all the possible mistakes.

C++ is an entirely separate language that happens to have some similarities.

https://beej.us/guide/bgc/pdf/bgc_usl_c_1.pdf is a good introduction to C.


👤 simonblack
Some of us learned Assembly Language programming before we hit C. Assembly Language makes a lot of use of pointers. So we're very comfortable using pointers.

I feel that we work better with C because of that. In fact, C has been called 'high level Assembly Language' by somebody in the past.

C is not difficult. C++ is difficult because of its use of overloading (IMHO) and it seems quite messy. In C, the frugal language, what you see is what you get.


👤 leed25d
I didn't find C all that hard to grok. It helped matters that I had spent the previous 10 years programming in assembly languages.