views:

1237

answers:

17

Lately, I discover more and more that it's good to have extensive knowledge of programming fundamentals. Sadly, I am (one of the many) self-taught PHP developers and have no regrets choosing that path.

However, I still think I should extend my knowledge to some "real" programming languages starting from zero and build up my knowledge from there. I have no intention of changing my career path, but I do think it would be good to think out of the web-development box.

I prefer not taking classes or courses, because I simply do not have the time for this. So:

  • What is the best way to teach myself C step by step, starting from level zero?

  • As my main goal is to learn more programming fundamentals, is C even a good choice for this?

  • If not, what language would be?


Summary so far:

First of all, thanks for all the great responses. These will be quite helpful. Although most people seem to agree that starting off with C is not a bad choice, I have also seen people state that it is probably a better idea to skip C and go with C++ or even C#, since these languages are more current.

My personal opinion is still that it would be good to start from level zero, even if the language itself is not directly contributive to the things I make. I still believe it will indirectly make me a better programmer. But then again, like said, my knowledge of these languages is quite limited, so I'd love to hear your thoughts on the matter aswell.

+8  A: 

My first step in picking up C was a copy of "The C Programming Language" - it's a simple book, but the language is itself pretty simple.

bowens
Thanks for your answer, I'll look into this; could you please link to the book / author aswell?
Aron Rotteveel
Seriously, you can't do a search on Amazon??
cletus
Of course I can, but as the author of the answer can do this as well and the main goal of this site is to supply the best answer possible, I do not think this is a strange request.
Aron Rotteveel
Is it same book as in Nick answer ?
Ilya
Yes, we just answered at the same time
Nick Fortescue
So Aron, pick the link from Nick answer :)
Ilya
+25  A: 

Read Kernighan and Ritchie "The C Programming Language". It is the classic.

It is the book written by the original creators of the language. It is short, and very readable and well written.

Nick Fortescue
cletus
I agree with cletus
Robert Gould
Nick Fortescue
Aron Rotteveel
cletus
There is a full list at http://docs.sun.com/source/806-3567/compat.html, basically ANSI has slightly safer, stricter syntax.
Nick Fortescue
Cruachan
Aron: "K I wish more books were as concise and helpful.
bobince
Lars Wirzenius
Antonio Haley
+1 Not only you will learn C and programming in general, but you will gain a deep understanding of how OSs work.
Helper Method
+1  A: 

C is a good choice for mainstream education. However before going through books, I'd follow some IDE tutorials, so you get a hang of building projects, and makefiles, those two will be the biggest challenges you'll face initially, and they are rarely covered in any book.

Robert Gould
Thanks for the practical tip here, I'll remember this.
Aron Rotteveel
+1  A: 

Another option if you want to learn programming fundamentals is to read Knuth's The Art of Computer Programming. This will introduce you to fundamentals from the very beginning of time. For extra understanding implement the algorithms yourself in C.

Nick Fortescue
A: 

Let us C by Yeshvant P Kanitkar

Rakesh
+2  A: 

If you speek German I'd suggest you an open book from Galileo Computing.

Peter
+8  A: 

I have to disagree with the previous two answers who recommend the famous "K&R" guide. I was completely unable to learn anything from that book; I simply gave up after reading the first third of the book about three times. Maybe I'm just dumb.

I suggest, instead, this wonderful book: C Programming: A Modern Approach (disclaimer: amazon link)

I've learned everything I need to know about C from that book, and it covers the history as much as needs to be done, while still keeping a "modern" point of view.

Caveat: I didn't come to C "for C", I passed through it on the way to my eventual goal, Objective-C and Cocoa programming for desktop applications on Apple's Mac OS X. If you really want a very deep knoweldge of C, it may not hurt to get both of the above-mentioned books, and read the K&R guide after reading Modern C

elliottcable
Robert Gamble
+1  A: 

There is a university course at Indiana and Purdue Universities on C-programming. The course has video lectures that you can find at here.

If you are also interested in looking at C++, there are a bunch of lectures at the Web Lecture Archive Project called "C++ for Particle Physicists". You find those lectures here. The lectures are held by Paul Kunz from Stanford University.

For more C++ lectures, you can also check out these lectures from Reconnect Networks.

Erik Öjebo
+1  A: 

Read "The C Programming Language". Write short exercises (some are in the book). Use a compiler, such as gcc.

Yuval F
+1  A: 

The C programming language is a good starting point.

Moreover, C itself is a good starting point for learning programming fundamentals: you can find C software and C developpers almost everywhere and many other languages take roots in C, such as C++, C#, Objective-C, ...

mouviciel
+1  A: 

After reading the "The C Programming Language" like many suggested i would start looking into open source projects and learn from practical examples. There is a lot and it's not easy to find the right one, but learning from reading good code is the best alternative for learning from good coder :)
If you have one around: pair programming or just mutual code reviews is the best way to learn.

Ilya
+1  A: 

1) The C programming Language K&R 2) Read a lot of C source code. Google code search

That is all.

Jorge Niedbalski R.
A: 

I believe your current approach is incorrect. C is currently a subset of C++ and does not have many of the concepts of a modern OO language. In most cases, it is relegated to legacy systems, and most new development that is not tied to legacy code is not written in C. Personally, I started with C++ (self taught), and moved to C#. Starting in C++ gives you all of the basics you need to understand object orientation and what's going on at a low level. However, for someone just starting, I would now recommend C# for the simple reason that its much easier to get off the ground and start running with it. Also, several of the concepts in c# have few analogs in the C world and make programming much more intuitive (LINQ, lambdas, etc). While memory management is important (and occasionally shows up in C#) it is painful to manage, and easier not to worry about as you're starting up. The sooner you can start an interesting project, the less likely you are to give up.

Steve
Thanks for your answer. It's good to see another view on the matter aswell. I do not intend to use C in production environments, but still do believe it is quite useful to have experience and understanding of this language. How do others feel about this?
Aron Rotteveel
C is still widely used in systems' programming, embedded devices, and so forth - definitely far from legacy code. C++ is a lot more complex, gives you more ways to shoot yourself in the foot and it'll hurt more while doing it. Only move to C++ when you have a decent grasp of C, it'll ease the transition. Unfortunately I don't have a solid opinion on C#.
Michael Foukarakis
+1  A: 

If you want some good source code to read, I can heartily suggest Simon Tatham's Puzzle Collection (http://www.chiark.greenend.org.uk/~sgtatham/puzzles/, scroll down to the bottom for developer documentation). From it, you can learn:

  • How to do object-oriented-like programming in C (each game is in a sense a class that implements the "game" interface).
  • How to write portable C (hide all the unportable stuff behind your own interface).
  • How to comment and document your code.
  • How to do GUI programming in C.
  • How to implement data structures in C (I recall the union find and 2-4 trees being done).
Jonas Kölker
please add link to the resource you're talking about.
Vadi
+1  A: 

Well, if you want to "start from level zero" i recommend learning assembly. yes assembly. I learned 6502, you can learn x86 if you like or arm or mips. Find a emulator or an interrupter and read some tutorials. You'll understand exactly how a CPU works and code will make much more sense (like why does getkeys not update until you do pollkeys and etc).

After that i recommend C# because it isnt as nasty as c/c++ (i primarily use c++). You'll understand how a C# line could be represented in assembly. C# allows you to do more things you want to do unlike c and c++ (heres a list of things that we can do in c++ that we will be able to do in the next standard http://en.wikipedia.org/wiki/C%2B%2B0x, C# has a few of these).

If you want to learn a lot you can try learning the language i recommend here http://stackoverflow.com/questions/498964/the-difficulty-in-learning-new-languages-by-yourself/578618#578618 which i think is a good idea after assembly.

acidzombie24
Thanks for your answer, and different insights on the question, I appreciate it!
Aron Rotteveel
A: 

About learning C

If you really want to learn C, Kernighan and Ritchie "The C Programming Language" book is good start.

However nowadays, in my opinion, learning C is just mind exercise -- you can learn a lot important details like, for example:

  1. Difference between equal operator (==) and assignment instruction (=),
  2. Expression can have value (i.e. a = 1 has value 1),
  3. Pointers arithmetic,
  4. Direct memory operations (i.e. memset(), memcpy()).

These things are interesting for developers, but most of them is not in use in today mainstream application development (except two first points above).

However if you try to take part in some computer since competitions, C language can be useful.

My recommendation

I would learn C# because it's modern, well designed (in my opinion) object oriented programming language with good, free of charge IDE -- Visual Studio Express Edition, good support (wide community, a lot of source code to study, a lot of tutorials and examples). With C# you can write console application, desktop application or Web Apps, which makes easy to learn by solving wide range of real problems.

Also, on .NET platform there are some other interesting choices -- IronPyton or functional F#.

Grzegorz Gierlik
A: 

1) Kernighan & Ritchie

2) Writing Solid Code

3) Code Complete

Billy