Learning C as a (relatively) experienced programmer?

c
resources

#1

I have a computer science degree from which I learned Java, Scala, a bit of Python and other high level languages, but no low-level languages such as C. I’ve had jobs working in Java, and for the past year have had a job writing Python. I also have a bit of experienced with functional programming and logic programming.

I’d like to learn some C, partly out of curiosity, partly out of the history of it, partly to learn any insights that high level languages don’t offer, partly so I might be able to contribute to a project in C at some point if I get interested in one.

What approaches to learning C would you recommend to someone in my position?


#2

I learned C (a very long time ago, to be sure) by reading Kernighan and Ritchie (https://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628) and doing the problems. I don’t think there is a better way to do it - a decent programmer should likely speed through the early problems and so get to the more advanced stuff (like pointers) quickly.


#3

I have to second that book. It’s great.


#4

For exercise, I would suggest doing a lot of string parsing, splitting, etc. in C. That was something that tripped me up a long time ago when I was first learning, and more recently saw that trip up lots of people in a class I was taking. That included even some people experienced with Java and other languages.

It will help grasp things like pointers and memory allocation, as well as make you appreciate languages that do this for you :slight_smile:


#5

I’ve been a big fan of Zed Shaw for a while and really enjoyed Learn C The Hard Way.


#6

OOh and the other plus of any of the Learn Code The Hard Way series is that it’s easy for people who have the experience to learn the basic of the language fairly quickly.


#7

Strongly agree with this comment!

I failed my first heavy string parsing project in my first C class (operating systems) in college, dropped the class and took an intro course that moved slower. By the time I retook operating systems and did the project the second time, I was much better prepared for how to deal with strings when I had to manage their memory myself!


#8

In addition to K&R2, you may find the book “Expert C Programming: Deep C Secrets” interesting (ISBN: 978-0131774292).

It was written by Peter van der Linden who used to be with Sun. You may find your Java background resonating here!

The book is very well-written and is fun to read. It has all the three elements you look for: insights, history, and fun stuff that will satisfy your curiosity.


#9

I can recommend Learn C the Hard Way, it teaches you C but also shows what’s going on under the hood of the programs you’ve written too.


#10

Try out CS50

https://courses.edx.org/courses/course-v1:HarvardX+CS50+X/course/

  • has small projects
  • comes with lectures and short clips
  • large community of students to chat with
  • free

#11

+1 to this book, and your recommendation of it!

I feel like Deep C Secrets is a really under-appreciated book. It’s full of fun anecdotes, enlightening explanations of how things work, and really good advice on how to avoid common problems!