6

It looks like K&R "C Programming Language (2nd Edition)" covers ANSI C, but another book that I'm starting (Stephen G. Kochan "Programming in C") says that it uses C99.

I'm coming from a C#/JavaScript/Python/PHP/Java background and looking to round out my skills.

I'm currently using GCC, but I'm curious about Clang. Which version is used more in new and existing code? Does it even matter, or should I learn both?

Matthieu
  • 4,599
Nogwater
  • 171

4 Answers4

14

Learn C89 first, then learn everything that is different between C89 and C99.

A good book covering both is C Programming: A Modern Approach.

I think C89 gets used the more; GNU uses it and then, most compilers don't even support C99 (fully). GCC supports C99 only partially. Myself, the only C99 features I use are variable length arrays and single-line comments. If you want maximum portability, choose C89 for your projects, but it is still important to at least be aware of C99's features.

Anto
  • 11,197
3

I think you are confusing C language standards and specific extensions offered by compilers.

As for standards, I would learn the latest you can use to produce running code.

As for compiler, I would try to stay away from extensions as long as possible. Consider compiling in a highly standard-compliant mode (e.g. -pedantic for gcc and clang). This makes your code more portable and helps you understand the language better.

1

In one respect, it doesn't matter. As you build a career in programming, you're certain to encounter C, C89, C99, C++ in some variant forms, C#, Java (as a quasi-variant of C) and Objective-C (as another quasi-variant) The goal, in my opinion, would be to establish yourself as a competent programmer first, and then any language you see, including Fortran, Cobol, or Basic, will be easy to read and understand, and therefore easy to adapt to.

In that sense, an early focus on any one of those languages is fine, as long as you're prepared to adapt to the other languages as they come along.

So I say this: If you're making this a focus of academic study, then choose the most popular standard C variant in use today, and do your learning while adhering strictly to the standard set. Following that, make an analysis of the differences between your choice, and the differences.

If this is a professional focus, you're going to want to learn C# and Objective-C and know them both cold, eventually, unless you're maintaining code. And if you're a smart professional, you're also becoming expert in PHP, Python, Ruby, Visual Basic (y'know, just. in. case.) etc, etc, etc...

0

Use the C-subset of C++. Being able to define variables close to where they are initialized and used is better than having C force you to declare a list of variables at the top.

Lord Tydus
  • 1,441