Still worth it to learn C?

  • Thread starter Thread starter Zeuge
  • Start date Start date
Joined
8/26/11
Messages
175
Points
28
Cprogramming.webp
So I've been putting off learning C++ and have continued to use Java and Matlab for all of my computing needs for class. But fall recruiting season is fast approaching, so I'll need to teach myself some decent C++ before then. Is it worth it to start it with C, or at this point (and given my Java experience) should I skip straight to C++? Thanks!
 
Using C is inexcusable. Sure there are some narrow application areas, like heavily constrained embedded systems, where the use of C can be justified. For some embedded systems C++ compilers are unavailable or the code that they generate is unreliable. But in the vast majority of cases the use of C is inexcusable. Programmers who insist on using C when there are alternatives never really learned object oriented programming.

Using C++ is very expensive. Any large C++ program will struggle with memory errors. Programmers are imperfect and their imperfections will eventually manifest as memory errors which are very difficult to locate and correct. Also, the software resources available for C++ are far smaller than those available for Java. Still, there are cases where C++ is the right choice. These situations are not that common, but they definitely exist. However, there is no reason to use C. What ever can be done in C can be done better in C++. By better I mean more maintainable and with fewer errors. C++ contains C as an almost complete subset. Any low level operation that can be done in C can be done in C++. But C++ gives the programmer the ability to structure code in a way that is clearer and more maintainable.

The fact that people continue to use an ancient programming language is simply depressing. We would never design such a language today. Unconstrained pointers and a lack of range checking were justified by the limitations of computer hardware 40 years ago (e.g., the DEC PDP 10). These limitations are long gone. The module structure of C is equally antiquated compared to object structure. The very fact that anyone would even argue for using C (again, except in heavily constrained embedded systems) is iconic of what is wrong with software engineering in practice. This post should not be considered inflammatory but obvious.
 
... What ever can be done in C can be done better in C++. By better I mean more maintainable and with fewer errors. C++ contains C as an almost complete subset. Any low level operation that can be done in C can be done in C++. But C++ gives the programmer the ability to structure code in a way that is clearer and more maintainable.

In the words of Linus Torvalds:

"...
C++ is a horrible language. It's made more horrible by the fact that a lot
of substandard programmers use it, to the point where it's much much
easier to generate total and utter crap with it. Quite frankly, even if
the choice of C were to do *nothing* but keep the C++ programmers out,
that in itself would be a huge reason to use C.
...
In other words, the only way to do good, efficient, and system-level and
portable C++ ends up to limit yourself to all the things that are
basically available in C. And limiting your project to C means that people
don't screw that up, and also means that you get a lot of programmers that
do actually understand low-level issues and don't screw things up with any
idiotic "object model" crap.
...
"
http://thread.gmane.org/gmane.comp.version-control.git/57643/focus=57918

Read the whole exchange. It will open your eyes.
 
Well, I could also quote Andrew Tannenbaum on how Torvalds missed the core lessons that Tannenbaum was trying to teach about the construction of operating system microkernels.

Just because Torvalds says it doesn't mean it's true. I stand by what I wrote.
 
Well, I could also quote Andrew Tannenbaum on how Torvalds missed the core lessons that Tannenbaum was trying to teach about the construction of operating system microkernels.

Just because Torvalds says it doesn't mean it's true. I stand by what I wrote.
Linus is not God but the microkernels have not panned out as much as what Tannebaum wants you to believe.

The fact that people continue to use an ancient programming language is simply depressing.

I completely agree with you. I will put C++ in that basket as well.
 
Bypassing any value judgment, I would also mention that a lot of the time a big part of the job is working with code that other people wrote and code can hang around for some time (in some cases longer than the people who wrote it). In that context, it may be helpful to know C.
 
Start with C++. You don't specifically need to learn C. If you come across something related to C while learning C++ just google those things which is what I do normally.
 
The very fact that anyone would even argue for using C (again, except in heavily constrained embedded systems) is iconic of what is wrong with software engineering in practice.

I hope, for your future employers sake, that with this sort of attitude you are never allowed to touch any piece of performance critical code...
 
I like C, it's very quick to write, fast and standardized. E.g. MQL, the MetaTrader language uses C like language to write trading algorithms.
 
Start with C++. You don't specifically need to learn C. If you come across something related to C while learning C++ just google those things which is what I do normally.

I used to think so as well.
But a good grounding in C as a stepping stone to C++ is invaluable because you learn how things really work.
 
So I've been putting off learning C++ and have continued to use Java and Matlab for all of my computing needs for class. But fall recruiting season is fast approaching, so I'll need to teach myself some decent C++ before then. Is it worth it to start it with C, or at this point (and given my Java experience) should I skip straight to C++? Thanks!

Java experience is maybe not enough. Maybe first spend a few weeks coding Kernighan and Ritchie book.
 
C++ is the new Fortran and it will be here forever. :) Job interviewer say "you know C++". No one cares if you know Java or Matlab.

BTW did you know that 80% of running progams are COBOL?
 
I've seen some of F# (shied away from it since it is Windows based), been picking up some OCaml on the side for fun. I've done functional programming before, but the ML static type-inference paradigm is a new one for me, so it's been interesting.
 
I've seen some of F# (shied away from it since it is Windows based), been picking up some OCaml on the side for fun. I've done functional programming before, but the ML static type-inference paradigm is a new one for me, so it's been interesting.
F# is very useful for cetain kinds of applications and is certainly worth keeping an eye on imo.

Especially the support for Higher Order Functions is crucial.
 
If you only had to learn one language, it would be C. Absolutely do not skip learning C before C++.
 
Here's a radical idea: in addition to learning C++, how about learning D (a programming language which much of the structure of C++, native code generation, range checking and garbage collection).

I've gone into this a lot elsewhere so I will not go into this at length here. The simple fact is, for large complex programs, especially multi-threaded programs it is difficult or impossible to write reliable code in C++. In particular, it is impossible to escape from memory reference errors. Even using memory testing tools will not find these errors, since they rely on the path taken through the code.

The fact that we are still using a dangerous language like C++ is the cause of a lot of software failure. If Java is not fast enough for your application then the D language is a good choice. D has memory range checking and garbage collection. It avoids some of C++'s ugly syntax (e.g., templates). The language compiles into native code.

Hopefully, after the debacle at Knight Capital people will start to think about how important software quality is. You can design more reliable software in Java or in D.

One poster, who doesn't know much about compiler optimization and code performance, suggested that C should be used for performance reasons. What this poster doesn't realize is that C is very difficult to optimize because it has pointers, not arrays. The D language was designed by one of the best compiler designers I know of (Walter Bright). D can be optimized much more efficiently than C or C++. So if you really want code that is as fast as possible, D is, again, a better choice.
 
Back
Top Bottom