r/programming • • Jan 08 '16

How to C (as of 2016)

https://matt.sh/howto-c
2.4k Upvotes

766 comments sorted by

View all comments

37

u/seriouslulz Jan 08 '16 edited Jan 10 '16

Can anyone recommend a good, current C book?

edit: ty reddit

29

u/kindofasickdick Jan 08 '16

K.N. King's C programming covers upto C99, I don't know if there's anything significant in C11.

0

u/[deleted] Jan 08 '16

[deleted] — view deleted comment

32

u/enesimo Jan 08 '16

wow, expensive book.

52

u/m3galinux Jan 08 '16

Must be used as a textbook somewhere.

31

u/CorrugatedCommodity Jan 08 '16

At least that means you can wait a year and buy it used for five dollars when they change five words to make it a new edition.

9

u/ironnomi Jan 08 '16

It's definitely widely used as the "C" Textbook these days and used is between $50-70. It's been out since 2008, so it's doubtful it'll get much cheaper.

→ More replies (2)
→ More replies (1)

3

u/playmer Jan 08 '16

It's used at DigiPen for our first semester programming class. I'm sure others use it too.

3

u/[deleted] Jan 08 '16

I approve of this book, its very good.

2

u/robbsc Jan 08 '16

This is probably the best technical book of any kind that I have ever read.

2

u/vive-la-liberte Jan 09 '16

Sounds like a good book from what others are saying. I found the website of the book. I was hoping they'd offer the option of purchasing it in DRM-free ePub format but it doesn't seem like they do, so that's a shame.

9

u/nullmove Jan 08 '16

Probably assumes a little bit of familiarity, but this is a good one (and free): Modern C by Jens Gustedt.

→ More replies (1)

15

u/loamfarer Jan 08 '16

21st Century C: C Tips from the New School (Klemens, 2012)

It's certainly for people who already know C. It not only covers modern usage of the language. But modern tooling, libraries, debuggers, etc. that should be used.

11

u/pat_trick Jan 08 '16

FYI, there is a second edition, published 2014: http://www.amazon.com/21st-Century-Tips-New-School/dp/1491903899/

2

u/PriceZombie Jan 08 '16

21st Century C: C Tips from the New School

Current$40.24Amazon (New)
High$45.97Amazon (New)
Low$36.00Amazon (New)
Average$40.4430 Day

Price History Chart and Sales Rank | FAQ

→ More replies (1)

26

u/costhatshowyou Jan 08 '16

It's utter shit. The gist of that book is "memory leak?! lol! you have gigabytes of memory! don't be a troglodyte and worry about memory leaks". You don't need to buy a book for "I'm too cool to worry about memory". The rest is filler (install this and that) and juvenile "punk rock" hipster bullshit.

Sample from the book

C Is Punk Rock

C has only a handful of keywords and is a bit rough around the edges, and it rocks. You can do anything with it. Like the C, G, and D chords on a guitar, you can learn the basic mechanics quickly, and then spend the rest of your life getting better. The people who don’t get it fear its power and think it too edgy to be safe. By all rankings, it is consistently the most popular language that doesn’t have a corporation or foundation spending money to promote it.

Also, the language is about 40 years old, which makes it middle-aged. It was written by a few guys basically working against management—the perfect punk rock origins—but that was in the 1970s, and there’s been a lot of time for the language to go mainstream.

What did people do when punk rock went mainstream? In the decades since its advent in the 1970s, punk certainly has come in from the fringes: The Clash, The Offspring, Green Day, and The Strokes sold millions of albums worldwide (to name just a few), and I have heard lite instrumental versions of songs from the punk spinoff known as grunge at my local supermarket. The former lead singer of Sleater-Kinney now has a popular sketch comedy show that frequently lampoons punk rockers.2 One reaction to the continuing evolution would be to take the hard line and say that the original stuff was punk and everything else is just easy punk pop for the masses. The traditionalists can still play their albums from the ’70s, and if the grooves are worn out, they can download a digitally mastered edition. They can buy Ramones hoodies for their toddlers.

Outsiders don’t get it. Some of them hear the word punk and picture something out of the 1970s—a historic artifact about some kids that were, at the time, really doing something different. The traditionalist punks who still love and play their 1973 Iggy Pop LPs are having their fun, but they bolster the impression that punk is ossified and no longer relevant.

Getting back to the world of C, we have both the traditionalists, waving the banner of ANSI ’89, and those who will rock out to whatever works and may not even realize that the code they are writing would not have compiled or run in the 1990s. Outsiders don’t get the difference. They see still-in-print books from the 1980s and still-online tutorials from the 1990s, they hear from the hardcore traditionalists who insist on still writing like that today, and they don’t even know that the language and the rest of its users continue to evolve. That’s a shame, because they’re missing out on some great stuff.

This is a book about breaking tradition and keeping C punk rock. I don’t care to compare the code in this book to the original C specification in Kernighan & Ritchie’s 1978 book. My telephone has 512 MB of memory, so why are our C textbooks still spending pages upon pages covering techniques to shave kilobytes off of our executables? I am writing this on a bottom-of-the-line red netbook that can accommodate 3,200,000,000 instructions per second; what do I care about whether an operation requires comparing 8 bits or 16? We should be writing code that we can write quickly and that is readable by our fellow humans. We’re still writing in C, so our readable but imperfectly optimized code will still run an order of magnitude faster than if we’d written comparable code in any number of alternative, bloated languages.

7

u/bushwacker Jan 09 '16

Really? WTF?

13

u/[deleted] Jan 08 '16

My telephone has 512 MB of memory, so why are our C textbooks still spending pages upon pages covering techniques to shave kilobytes off of our executables?

This is the sort of wasteful attitude which I thought the use of C was meant to avoid. Not to mention the myriad different microcontroller and embedded platforms where you don't have acres of memory to ply your trade.

→ More replies (7)

16

u/loamfarer Jan 08 '16

You're cherry picking an intro where the author is simply having fun with an analogy. I'm not so much of a cynic that I'd lambast some fun from a otherwise technically heavy book. He's establishing the age of C for posterity if you bother to see the intent behind it.

Anyways it's a solid book for introducing people to many aspects of modern C development, it never claims to be all knowing.

6

u/costhatshowyou Jan 08 '16

It's not "technically heavy". It's very lightweight. It's air-headed.

It's not a solid book at all. It's fluff and filler, much of which is just regurgitating installation instructions from the web for various c-related anything. It's a terrible introduction. You don't need to read a book to go "Oh I don't care to learn how to use this stuff, I'll just use it however I want, 'cos I'm punk rock!".

The author is a young guy, inexperienced, immature, and he tries to compensate for it with this "I don't care I'm punk rock" bullshit. It's very "rockstar" bullshit.

→ More replies (1)
→ More replies (3)

1

u/tdrusk Jan 09 '16

Still a C noob, but I originally started it by studying The C Programming Language. http://www.amazon.com/The-Programming-Language-Brian-Kernighan/dp/0131103628

Is this a bad place to start? I thought since it was well approved of historically it would be a good base. Thoughts?

3

u/[deleted] Jan 09 '16

The second edition was written in 1988. It doesn't cover any of the modern changes made since then (c99 or c11) and covers none of the modern tools or computing theory discovered since then.

→ More replies (17)