I want to learn C

8    20 Jul 2015 03:37 by u/gtcom

I know, I know, "do you really need to know C", "there are easier programming languages", "you should do python first".

I get all of that. I feel fairly comfortable in python. I want to learn C.

I have the K&R book, and I'm about halfway through, are there other, more current resources? Or is K&R the best way to go?

26 comments

4

What got me interested in C was microcontrollers. The Arduino and like boards are Atmel ATMEGA processors that can be programmed with GCC. It was more compelling to watch some real I/O than to put together console apps. The boards are typically around $20 and can be found at lots of sites.

Cool demo: Blinking LED

3

Data Structures: An Advanced Approach using C is also a very good book for data structures.

1

Wish they had a kindle edition. Okay, will be in the mail in 4-5 business days. Thanks.

1

This book is what I used in college in 2006 for a data structures class.

2

The Linux kernel is a great project in C.

2

I've read through some of the kernel source and it's intimidating.

I downloaded the source to wc the other day (it's so small, how complex could it be?) -- I've got a long way to go.

2

I recommend K&R and Head First C, nice books. And practice, practice, practice

2

C is a key language, if you want to understand memory management and resource handling it's the way to go. K&R book is still a good resource, I wouldn't go after another book before finishing it.

C is a very basic language in terms of syntax, there's almost no complexity if compare to languages like Clojure, Haskell, Lisp or Scala, but on the other side is a wider world, you can do a lot of stuff with many potential solutions and the only way to handle them is to try. C, more than other languages, requires a lot of time to code and try different solutions, mainly when asynchronous computation is introduced. Keep going!

2

What is almost everyone trouble with old C? The language is older than the grandparents of a few of the ones present here. Did it age that bad?

0

It's still a great language, but for 99% of the applications being developed it is cumbersome. Just because you spend an exorbitant amount of time doing things modern languages have solved. Like garbage collection. I'd point to D as an example of a language which has potential to supplant it in those 99% cases.

But when it comes to things like Drivers, Kernels, Micro controllers, Life Support Systems, etc. Nothing can take the place of C.

1

K&R C is the best book for learning C.

Modern publications will not provide you with more knowledge, but they will have "did you know?" text filling the margins, which is distracting.

I'm not a C programmer, but it is the language I was introduced to when first learning how to code. Writing small programs in C made it clear to me how code is represented in memory. You're certainly on the right path.

1

I'm a fan of Modern C. It's free, extremely precise in its language, and covers all the latest language features.

0

Downloading it now, thank you.

1

C is not difficult to learn, so don't sweat it. Especially if it's not your first programming language (even if it's your first type-safe language). Get good at the simple stuff like fast arithmetic, memory bookkeeping and debugging, then dive into either the Python C API or C++14 (why not both?).

1

Seriously, go to your local community college and sign up for their C class. You could learn it by yourself, and a lot of people here are going to give you some solid advice about doing that. Having access to a professor and a lab full of peers learning the same thing as you is a valuable resource.

If you are already comfortable with other languages, like Python, C shouldn't be much of a problem, language wise.

Learning C is 10% learning the language and 90% learning how to use the tools. Here's what you REALLY need to focus on:

  1. Learn the tools. Specifically, the gcc tool chain. Specifically the debugger. Learn how to use these tools without an IDE.

  2. Pointers are a bitch, but they are useful. Unlike Pyhon, you need to actually know how pointers work in C.

  3. Learn how to safely allocate and deallocate memory.

  4. Datastructures. Walls and Mirrors (book) is a good resource. But you should probably also take a class for this for guidance.

Also, take the "self teaching" advice everyone else is giving here. It too is valid.

0

you actually need to do the K&R exercises on a "modern" compiler. Have fun.