Handmade Hero » Forums » Code » Learning C, Again
MrPhil
Mr. Phil
12 posts
1 project
(tbd)
#5932 Learning C, Again
2 years ago Edited by Mr. Phil on Feb. 20, 2016, 5:20 a.m.

I'm jumping back into C, last time was I used C was in the 90's. I started with this website http://c.learncodethehardway.org/book/ and so far I like it's approach, especially the "Break It" sections But, I came across this book C Programming: A Modern Approach, 2nd Edition http://amzn.com/0393979504 It's got great reviews, but also really expensive, $113!! Anyone have any opinions on either? I'm a professional developer, mainly C# and Unity, so I don't need a beginners book/website.
Drexir
9 posts
#5933 Learning C, Again
2 years ago Edited by Drexir on Feb. 20, 2016, 7:38 a.m.

"learn c the hard way" well doesn't teach you anything. If anything I'd say it will just end up confusing the learner more than anything. Not to mention the book has quiet a few errors.

A modern approach is a good book. For the price tag; it's used in schools as a textbook hence the higher price. Seems a bit backwards how that works. Anyways K&R C is not a bad book at all. It may trip up the absolute beginner because it uses the ANSI C standard. Which didn't require you to specify a return type for main. Also you could only declare variables at the beginning of a function. And a few other things. Otherwise it's still relevant. And a good read.
gingerBill
Ginger Bill
215 posts
2 projects

I am ginger thus have no soul.

#5935 Learning C, Again
2 years ago Edited by Ginger Bill on Feb. 20, 2016, 9:53 a.m.

"Learn C The Hard Way" is dreadful. I would suggest The books:

  • -- The C Programming Language (K&R) ("The Bible")
  • -- C Primer Plus

Because there are not many great resources out there for learning C (especially for beginners), I have started a new series called Intro to C. It's a video series that teaches everything about C for complete beginners. If you are not a beginner, I would suggest just reading some books.

In C, the most difficult thing to learn in my opinion is pointers. I remember when I was learning C years ago, the concept of pointers took over a week for me to actually understand.

The other difficult thing is if you are coming from C# is unlearning OOP. C is mainly a procedural language. In my opinion, most implementations OOP are dreadful and actually hinder "code reuse" (from experience). The only language that I have personally used that uses a kind of uses OOP that I "like" is Go (even then, most people say it isn't even a "true" OO language but that's mainly people it doesn't do encapsulation at a local level and "true" inheritance, etc.). In most of my Go code at work, I think I have written 5 methods (hundreds of standalone functions though). That's it. In Go, the OO way is only useful certain things such as file systems.
ratchetfreak
332 posts
#5937 Learning C, Again
2 years ago

Find the specification of the version you are using.

There have been several and they are not all compatible. And for any tutorial/book you follow you need to know which version they are targeting.
gingerBill
Ginger Bill
215 posts
2 projects

I am ginger thus have no soul.

#5940 Learning C, Again
2 years ago

I would suggest learning C99 as this is supported by most compilers (and now MSVC 14+ (except VLAs)). The later version C11, adds a few things but not anything that is drastically different nor difficult to learn if you know C99.

I would suggest not learning C89/C90/Ansi-C/Hardcore-C and stay away from the GNU variants too.
btaylor2401
Bryan Taylor
55 posts
#5942 Learning C, Again
2 years ago

I don't get the hate for Learn C The Hard Way. It's fine.

I wouldn't buy a book to learn C, though -- there's not a whole lot of need. C itself is actually a *very* small language, much smaller than C# or Java or Python.

Learn the basic syntax, and then start writing a lot of C. Personally, I worked through all of DSA ( http://dotnetslackers.com/projects/Data-Structures-And-Algorithms/ ), implementing everything as I went along, which was enough to help me "get" pointers. If you run into any tools/utilities you'd usually use C# for, write them in C instead.

Find a good reference for the stdlib. I use http://linux.die.net/man/3/ for *nix, and MSDN for Windows. There are, of course, plenty of others.

Write lots and lots and lots of C. Practice is more useful than any book. You can worry about the details of the One True Way of Writing C *after* you can use C proficiently.
gingerBill
Ginger Bill
215 posts
2 projects

I am ginger thus have no soul.

#5943 Learning C, Again
2 years ago

Here is an article that I mainly agree on with why "Learn C the Hard Way" is bad: http://hentenaar.com/dont-learn-c-the-wrong-way
MrPhil
Mr. Phil
12 posts
1 project
(tbd)
#5946 Learning C, Again
2 years ago Edited by Mr. Phil on Feb. 23, 2016, 9:02 a.m.

Thanks for all the thoughts! Since Learn C the Hard Way is free, I think I'll just finish it and then see what feels missing. I get pointers, just need to relearn some of the nuances.


btaylor2401
Personally, I worked through all of DSA ( http://dotnetslackers.com/projects/Data-Structures-And-Algorithms/ ), implementing everything as I went along, which was enough to help me "get" pointers. If you run into any tools/utilities you'd usually use C# for, write them in C instead.


This looks like a great resource, thanks!


btaylor2401

Write lots and lots and lots of C. Practice is more useful than any book. You can worry about the details of the One True Way of Writing C *after* you can use C proficiently.

Totally agree.
Acry
Carsten Holtkamp
26 posts
#5952 Learning C, Again
1 year, 12 months ago

I wouldn't spend so much money on such a general book.
The book isn't a rocket science break through paper, it is just an ordinary book from 2008.
Ofc it doesn’t cover C11, cause it is from 2008.

You can buy a lot of used books really cheap.

Here you can find a lot of PDF’s
http://it-ebooks.info/

Here a search for c language
https://goo.gl/UQJmJ6

I have NO CLUE if this page is legal, it is around since 2011 now.

Site states:
Reproduction of site books is authorized only for informative purposes and strictly for personal, private use.
gingerBill
Ginger Bill
215 posts
2 projects

I am ginger thus have no soul.

#5953 Learning C, Again
1 year, 12 months ago Edited by Ginger Bill on Feb. 22, 2016, 9:49 a.m.

I am guessing that the site is illegal but I could be wrong as I am not a lawyer and different countries have different laws. The "Head First C" book on that site is not a book for a beginners but for people who already know a language and depending on your learning style. The book also gives a go at humour (which you may or may not like).

C is very simple language but from its simplicity, it brings allows for a lot of complexity.
Acry
Carsten Holtkamp
26 posts
#5966 Learning C, Again
1 year, 12 months ago

Another free C-language book:
http://publications.gbdirect.co.uk/c_book/

Maybe we could maintain a book-list with reviews?
Sizik
Matt
34 posts
#5967 Learning C, Again
1 year, 12 months ago

Stack Overflow has a list of books, categorized by skill level: http://stackoverflow.com/a/562377/1486690
pmad
Piotr Madalinski
9 posts
#5968 Learning C, Again
1 year, 12 months ago

I've found reading the linux kernel source code very instructive.
It's a very well engineered codebase - simple, down to earth, and yet uses a few C specific tricks and idioms (and macros) which are worth knowing.

The only problem is to figure out where to start (myself - I was trying to modify a driver for my router, so it wasn't an issue).

Maybe pick a simple subsystem (like gpio) and give it a shot:
http://lxr.free-electrons.com/source/
Acry
Carsten Holtkamp
26 posts
#5969 Learning C, Again
1 year, 12 months ago

Great, don't think I stumbled over it.
I have a way more comprehensive private list,
with distinct application fields or Host environment.

Like:

*GPU-Computing:Professional CUDA C Programming
or
Black Art of 3D Game Programming: Writing Your Own High-Speed 3D Polygon Video Games in C, Andre Lamothe, Sep 1995

Lately I saw tons of "new C books" where a guy created a script to swizzle topics and release/sell 15 instead of one book :(
mmisu
Misu Popescu
6 posts
#5981 Learning C, Again
1 year, 11 months ago Edited by Misu Popescu on Feb. 27, 2016, 2:16 p.m.

@MrPhil

You can buy C Programming a modern approach by King at half a price from abebooks.com. Pretty sure you can get it at an even better price if you do some research. Also, if you know a student at a decent Uni you may ask him to borrow the book for you if you just want to have a look.

Learn C the hard way - is not a bad book, keep in mind that the author has also released a series of videos, one video for every book chapter. The author has strong opinions about how to code in C, but you can say the same about our own gingerBill here :).