27 ms·
Modern C [pdf]
- grabcocque 10y agoSounds like an Oxymoron. "Make sure your buffer flow exploits are up to the minute! Make sure your systematic lack of memory safety totally captures the zeitgeist!"
- MrRobotic 10y agoI didn't use C much. What kind of features of are in the book that make it modern?
- AlexeyBrin 10y agoThe author provides the book as a free to download pdf at http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf
- qwertyuiop924 10y agoCan any C programmers evaluate this book? I don't do a lot of C, so I can't really do it. Does it advocate good best practices? Does it talk about pitfalls? Does it overemphasize new, possibly less widely implemented, features? Does it do/not do anything else we should know about?
- shakna 10y ago> Does it advocate good best practices? That may come down to opinion. For example, type qualifiers are bound to the left. Traditionally you would write: char *var; They advocate keeping type on the left, name on the right, so: char* var; A few things like that are covered under "Warning to experienced C programmers". Personally, I prefer it, but have always done what everyone else expects, so there are no fights over styling. > Does it talk about pitfalls? Absolutely. At a glance over, they talk about the unexpected way C treats truthy values (if it ain't 0, it's true), accidentally dereferencing to NULL, and even goes into goto, when it's good, and when it's bad. > Does it overemphasize new, possibly less widely implemented, features? Yes. They assume a C11 compiler, and state it in the introduction. At the moment, GCC and clang have some disagreements with how some C11 features should be treated, (GCC accepts a char or a char* for _Generic, clang requires it to be char. clang is more technically correct, but GCC is more flexible), and MSVC is still struggling to implement most of it. [0] > Does it do/not do anything else we should know about? I probably need a week to read it more fully, but I'll quote from the end of the introduction: > Last but not least comes ambition . It discusses my personal ideas for a future development of C. C as it is today has some rough edges and particularities that only have historical justification. I propose possible paths to improve on the lack of general constants, to simplify the memory model, and more generally to improve the modularity of the language. This level is clearly much more specialized than the others, most C programmers can probably live without it, but the curious ones among you could perhaps take up some of the ideas. [0] https://msdn.microsoft.com/en-us/library/hh567368.aspx https://msdn.microsoft.com/en-us/library/hh567368.aspx Edit: escaping
- giis 10y agoI looked into the table of contents & jumped into pages of it. It looks like good material on best practices & optimization rules & tips. Quickly, bookmarked it & definitely worth reading. IMO, the title here is misleading, I don't think new feature is added to C to make it modern.
- kensai 10y agoThe reason Gustedt calls it Modern C has to do with how he organizes the contents, especially the last level: Ambition. "This book is organized in levels. The starting level, encounter, will introduce you to the very basics of programming with C. By the end of it, even if you don’t have much experience in programming, you should be able to understand the structure of simple programs and start writing your own. The acquaintance level details most principal concepts and features such as control structures, data types, operators and functions. It should give you a deeper understanding of the things that are going on when you run your programs. This knowledge should be sufficient for an introductory course in algorithms and other work at that level, with the notable caveat that pointers aren’t fully introduced yet at this level. The cognition level goes to the heart of the C language. It fully explains pointers, familiarizes you with C’s memory model, and allows you to understand most of C’s library interface. Completing this level should enable you to write C code professionally, it therefore begins with an essential discussion about the writing and organization of C programs. I personally would expect anybody who graduated from an engineering school with a major related to computer science or programming in C to master this level. Don’t be satisfied with less. The experience level then goes into detail in specific topics, such as performance, reentrancy, atomicity, threads and type generic programming. These are probably best discovered as you go, that is when you encounter them in the real world. Nevertheless, as a whole they are necessary to round off the picture and to provide you with full expertise in C. Anybody with some years of professional programming in C or who heads a software project that uses C as its main programming language should master this level. Last but not least comes ambition. It discusses my personal ideas for a future development of C. C as it is today has some rough edges and particularities that only have historical justification. I propose possible paths to improve on the lack of general constants, to simplify the memory model, and more generally to improve the modularity of the language. This level is clearly much more specialized than the others, most C programmers can probably live without it, but the curious ones among you could perhaps take up some of the ideas."
- SwellJoe 10y agoIt's been a decade or more since I've worked in C (and have never been a heavy C coder). Is "modern C" really a thing? I mean, is there some subset of C that is safer than what I think of when I think of C? I know about stuff like reference counting techniques, rather than manual memory management, for example, and that goes miles towards safer coding. But, even so, the variety of ways you can shoot yourself in the foot with C are seemingly beyond counting. Are threads and async easier and/or safer now than 10-20 years ago, and with more direct language or standard library support? Is memory management in the standard library safer today? Are there concurrency primitives (beyond low-level interacting with epoll or kqueues or even fork or whatever)? I mean, it's obviously possible to write reliable, safe, secure, software in C (Linux, Git, SQLite, all come to mind), but how much easier has it gotten? Would anyone choose C for a new systems project with no legacy baggage or dependencies, in a world with Rust and Go?
- cygx 10y agoWould anyone choose C for a new systems project with no legacy baggage or dependencies, in a world with Rust and Go? Note that Go does not entirely compete in the same space, and Rust is only starting to gain traction.
- mitchty 10y agoAlso if anyone is talking about systems programming, it would be beneficial if you specify what that means. I've seen people consider "systems" programming as relating to building web services. Traditionally systems programming would be more kernel level and utilities/daemons. Rust might be OK to start using for the latter, but its very much not yet where I'd start using it for new things for either of the traditional setup. I know everyone is gung-ho about rust, but for the traditional systems programming crowd, its very new. Given how much it changes I would NOT want to bet on using it for at least 5 years. You don't switch just because something is better on memory safety. That is a nice to have thing. But changing 40ish years of things isn't something that you do without planning. Also, in my opinion Rust doesn't go far enough. I'd rather we move to things like Idris where I can prove much more than just memory safety. Rust is basically Ada/Oberon/Modula for the modern age. Nice, but ultimately not the first time this has happened.
- Waterluvian 10y agoI've had no luck learning a language on its own. But I've had a lot of luck learning languages as part of something bigger. Like C# via. Unity, Swift via. 2D game dev in XCode. Any suggestions on what I should apply C to as a way to learn it?
- qwertyuiop924 10y agoPOSIX.
- pawadu 10y agoOr unix in general. I learned C by implementing my own versions of popular unix commands, starting with echo then cat and so on...
- slededit 10y agoIf your a fan of the terminal I recommend writing a terminal program that scratches an itch of yours. Perhaps theres a shell script that runs too slowly? Or something in inscrutable awk that would be better as its own program.
- Waterluvian 10y agoHmmm... Yes I'll have to give it some thought. I use Python for most of my scripting needs. I guess I've never had a need that's required better performance.
- slededit 10y agoEven though it may not make technical sense to choose C, you may want to just use it to learn.
- Waterluvian 10y agoYup. I'm going to make some scripts. Thanks. :)
- timthorn 10y agoDiscussion at: https://news.ycombinator.com/item?id=13052486 https://news.ycombinator.com/item?id=13052486
- sctb 10y agoWe've merged the discussions into this thread.
- grabcocque 10y agoI mean, the problem cut C is not that it is old, but that it is dangerous.
- quickben 10y agoEvery language is, just about different things. Array out of bounds is dangerous even in Excel VB.
- zunzun 10y agoI personally prefer Prehistoric C, which only has the two language keywords "ugh" and "grunt". Modern C has too many keywords for my taste.
- oblio 10y ago> "grunt" I'm sorry, you cannot use this keyword as it will cause a conflict with Javascript tools.
- oneeyedpigeon 10y agoNah, coming down from the trees was a bad idea: http://www.dangermouse.net/esoteric/ook.html http://www.dangermouse.net/esoteric/ook.html
- Koshkin 10y ago"Prehistoric" or not, the classical C as created by Kernighan and Ritchie is actually a perfect example of a sensibly minimalist design. Subsequent changes made to the language have spoiled the characteristic elegance of that design.
- mpweiher 10y agoWell, function prototypes in the first ANSI standard were a fine addition, if you ask me. After that...
- aleksei 10y agoAnother day for the HN crowd to express their distaste for C :)
- coldcode 10y agoIn a PDF no less. I for one do not miss C (or Objective-C for a long time) at all. I built my first commercial app in C starting in the mid 1985 (Mac). That's how much of an antique this language is.
- pawadu 10y agoAnd yet, the OS and the browser you used to type this comment was written in C or a C-derivative like C++.
- pjmlp 10y agoHistorical accident. It could have been written in any other language that compiled to native code, if we had more options available.
- pawadu 10y agoWell, there are two types of people in this world 1. the type that do something 2. the type that claim they could do it better than the first group (this is by no means limited to programming, it is for example pretty common in politics) So please show me an OS written in Go or Rust or Ruby or Python or Java that people can actually use for day-to-day tasks.
- pjmlp 10y agoIf you pay me my monthly salary to prove you wrong, I will happily do it, should we discuss a work contract?
- pcwalton 10y agoI've been working full time for years on a browser written in Rust. Which category am I in? Yes, C++ is very entrenched. That is a problem. We should be fixing that.
- grabcocque 10y agoIt strikes me as odd you'd even go to the lengths of producing such a book. If you really wanted to protect people from the worst vagaries C the book should simply say "don't".
- AsyncAwait 10y agoC is still the lingua franca of computing, like it or not.
- pawadu 10y agoAny idea if it will be available as a physical book?
- marmaduke 10y agoIt's nice to see this perspective kept alive. I put some effort into a numerical library (github.com/maedoc/sddekit) in C99, and I didn't find the language lacking until I tried to imitate inherited interfaces with virtual dispatch by hand (empirically I can say, a poor move in C lib design). I did find it useful to apply rules like only use uint32_t, double & bool as primitives. My main wish is that it would be possible to opt into automatic const & restrict, as a compiler flag or pragma, so that something like https://github.com/maedoc/sddekit/blob/master/doc/C.md#aliasing-and-mutation https://github.com/maedoc/sddekit/blob/master/doc/C.md#alias... would be easier to do.
- deleted 10y ago[deleted]
- pawadu 10y agoThe author has also been involved in development of "musl", a modern C11 compliant standard library implementation: http://www.musl-libc.org http://www.musl-libc.org https://gustedt.wordpress.com/2014/10/14/musl-1-1-5-with-full-c11-library-support/ https://gustedt.wordpress.com/2014/10/14/musl-1-1-5-with-ful...
- stinos 10y agocomplaint yeah I hear that often when talking about C11 :]
- pawadu 10y agohah! fixed that for you. Who would complain about something as wonderful as C11, outside it not being available for your compiler?
- stinos 10y agoWho would complain about something as wonderful as C11 Beats me, but see rest of thread I guess :] In all fairness, sometimes it's the right tool for the job, sometimes it isn't
- verandaguy 10y agoI've been following musl for a little while because of its support for C11 threads. I'm surprised that none of the bigger libraries haven't implemented that.
- nabla9 10y agoWhat alternatives there are for C/C++ if you want to write library that you can call from Python, R, Matlab, Java, Rust, Lua, node.js ... and have good performance? Old ones like Ada and Fortran of course. There are newcomers like Rust and Go. Are their C api's mature and portable?
- vvanders 10y agoFor Rust? Totally usable and robust.
- pjmlp 10y ago> Old ones like Ada and Fortran of course. Modula-2, FreePascal, D
- insertnickname 10y agoThis isn't really something that Go is meant to do, but it is possible with a little bit of hacking. https://blog.heroku.com/see_python_see_python_go_go_python_go https://blog.heroku.com/see_python_see_python_go_go_python_g...
- biokoda 10y ago> Are their C api's mature and portable? Rusts C api is completely mature and portable. In fact if you are writing a library that you want to have a C interface to, Rust is a fantastic choice.
- minxomat 10y agoI get a 500 error. Here's an archive link: http://web.archive.org/web/20161128093244/http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf http://web.archive.org/web/20161128093244/http://icube-icps....
- pcr0 10y agoFor someone who studied basic C/C++ in university and is interested in hacking around in C, should I read this over K&R?
- sk1pper 10y agoDon't skip K&R. Probably read both. They're both pretty short. A really, really good one is Advanced Programming in the Unix Environment. But, it's pretty expensive.
- grandiego 10y agoAPUE does not teach C, but the Unix API. Granted, it is an excellent resource for people interested in such OS family. K&R is a great resource which covers a lot beyond the syntax, but is obviously dated from the standard's perspective.
- frag 10y agoI want to cry... remembering the old good time of C programming... ohhhh
- chrisd1100 10y agoI'm really surprised by the "hate" for C that is appearing in these comments. What ever happened to actually enjoying the danger of getting low level? Is assembly also useless because it isn't readable? There is a lot of great code written in C, and a lot of crappy code written in C. Because C doesn't protect you from yourself, it exacerbates any design flaws your code may have, and makes logical errors ever more insidious. So in this sense, the quality of the C you write is really a reflection of you as a C programmer, not the shortcomings of the language. Maybe you've been badly burned by C in the past, but keep an open mind and understand that C can be beautiful.
- Koshkin 10y agoPeople have strong feelings about C because C is far from being perfect by modern standards and yet it continues to be the single most important programming language of our time. There is nothing wrong or surprising with people being frustrated about this fact. I only wish that there was less irrational hate on this forum in this regard.
- crpatino 10y agoWell, the haters could always reimplement the whole infrastructure in their language of choice, wouldn't they? It's been done at least once before for ideological reasons (and in C none-the-less) by the FSF. It should be even easier to give it a go in modern languages. I bet you can even get funding if you can write a compelling case that the wheel is actually broken!!!
- rileymat2 10y agoThere is also the issue of undefined and implementation defined behavior. When developing on one platform for an extended period of time, it is human nature to forget which features are implementation defined as you use them day after day and then have unexpected errors/flaws when porting.
- bluetomcat 10y agoUndefined behaviour actually isn't the monster that most C language lawyers want you to believe it is. With tools like valgrind, address sanitizers and modern debugging toolchains, most of these issues can be caught. Compilers are also mature enough to issue warnings about the use of uninitialized variables, missing return statements or mismatched printf specifiers. Heck, Clang maybe has more than 250 -W options.
- pksadiq 10y agoI would recommend that anyone who hires a programmer should test his/her knowledge in C (especially in areas like code that produces undefined or unspecified results), even if the candidate is never going to code in C, ever. If he/she knows these concepts well, that means he/she have invested much time, and probably know other things well enough (or can learn them easily).
- loup-vaillant 10y agoLet's not confuse low level understanding with the fine points of the C virtual machine, which drifts from whatever platform you are working on by the year. What you really want is an understanding of how whatever code the candidate may write will map to the underlying hardware. Test for that.
- uryga 10y agodo you have any pointers for reading about "the C virtual machine"? i'd love an accessible explanation of how the model of the hardware predented by C differs from actual modern chips, but those keywords make it hard to google for.
- nwmcsween 10y agoThe C virtual machine is described by the C standard, implementations of such do vary which is due to a combination of bugs, vague language and interpretations of the standard. But ask anyone to build a house given 100 pages of text and see what happens.
- loup-vaillant 10y agoWell, like the sibling comment, I can only point to the standard. I'll give one example: the segmented memory model. In C, the difference between two pointers is a valid operation iff they point to the same object (or one slot past it). So it works if it's the same array or malloc() block, but something as simple as int a; int b; ptrdiff_t d = &b - &a; is undefined. Modern computers, including most embedded platforms, have a flat memory model by now, and could implement the operation above without problem. Another difference I know of is signed integer overflow. Most platforms use a 2's complement architecture, where signed overflow simply wraps around. In C, such an operation is undefined. Yet another difference relates to pointer aliasing. On most platform, a pointer is just a pointer to a memory slot. In C, it is assumed for optimization purposes that pointers of different types cannot point to overlapping regions. This prevents practical stuff like type punning, for which you have to use unions.
- ape4 10y agoGoto is considered useful by the book: The use of goto and similar jumps in programming languages has been subject to intensive debate, starting from an article by Dijkstra [1968]. Still today you will find people that seriously object code as it is given here, but let us try to be pragmatic about that: code with or without goto can be ugly and hard to follow.
- jeanlucas 10y agoHave you ever used goto in C? I feel like most people bash on C just because they heard Dijkstra said it, and that's it. Most code I saw while teaching it were not good cases, but sometimes it's a very interesting technique that can make the code easier to understand and shorter. I think that use is beautiful. But it doesn't mean there aren't bad use cases.
- cr0sh 10y agoI think you meant "bash on goto" instead of "bash on C"? Regardless, yes, a ton of people do bash on it because of Dijkstra - but at the time, he had a good point. In the industry of the time (as I understand it - I was a kid when he wrote that), there was a lot of "cowboy coding" out there, with goto's "gone wild" - jumping into the middle of everywhere and everything - and producing "spaghetti code". But as you note, it can be very useful and make things easier to read (for instance, jumping out of deeply nested if-then constructs - though I could also argue a refactor might be the better solution). I was once part of a discussion in a forum about state machines, and one guy posted a very beautifully done state machine that used no select-case construct, but rather goto statements, but done in a tight way that mimic'ed a select-case construct. I was very impressed at the time; it was some code for PIC Basic IIRC. In time, I've changed my views from seeing goto as "always bad", to "can be very useful, in some situations - provided you know the risks of the tool". In other words - think very carefully before you rush into using it; maybe there's a better or cleaner way.
- thegeomaster 10y agoI've found goto to be a good way of dealing with exceptions in low-level C. For example: void* foo() { int handle = get_some_handle(); if (handle < 0) { goto fail; } void* something = some_function(handle); if (something == NULL) { goto free_handle; } void* something_else = some_other_function(something); if (something_else == NULL) { goto free_something; } return something_else; free_something: free_something(something); free_handle: free_handle(handle); fail: return NULL; } I've seen this pattern frequently in the Linux source code. I think this is an example of a case where usage of goto improves readability and reduces errors.
- plg 10y agohttps://pragprog.com/magazines/2011-03/punk-rock-languages https://pragprog.com/magazines/2011-03/punk-rock-languages
- kzrdude 10y agoWill this book be printed? I would love to get a paper copy.
- fb03 10y agoITT: Heated arguments and zealotry. In resume: "C is outdated, its ubiquitousness is just a historical accident" "Better tools exist to do this job" "C is not needed anymore" (Yet no contender has ever come close to it, hehehe --my2c) There, saved you a ton of reading time.
- wangchow 10y agoA time will come when our entire concept of programming will shift due to advances in hardware unlike what we have today. Consider quantum computers or some biological machine etc. Those who use C and assembly I imagine would be better equipped to understand the new paradigms. It's best to understand how to implement data structures in their most rudimentary form because implementing them on new platforms becomes easier. In addition, higher-level idioms become easy to understand if the parts that make up the whole are understood. And underneath all those layers of translation and compilation we have raw assembly and the bare machine.
- fb03 10y agoI agree! I also believe efforts like LLVM are actively trying to 'bridge the gap' between both worlds (totally raw VS fully dynamic/scripted). Stuff like emscripten is enabling the "old farts" and the "newfags" to share common ground, and that's amazing... I just hope these youngsters keep learning stuff instead of just piling framework after framework after the new 'hot shit' gets released in a 6 month timeframe.. really, adhd is in full effect, specially in the webdev world, and imho that's hurtful. o/
- colanderman 10y agoWhile I like a lot of what's in here, for (size_t i = 9; i <= 9; --i) is a pretty terrible example to put in the second chapter. I would not let that line pass code review. There is no need or place for cutesy cleverness in C. EDIT: Ugh, just found this too: isset[!!largeA[i]] += 1; Not only is that confusingly cutesy, but largeA[i] is a double. Please DON'T write – or encourage beginners to write! – such smug code! EDIT2: In section 5 is the statement than unsigned integers "can be optimized best." This is flatly untrue on x86 and I suspect many other architectures. Compilers can and do take advantage of undefined signed overflow to optimize signed arithmetic; the same is not possible with unsigned arithmetic. See https://kristerw.blogspot.com/2016/02/how-undefined-signed-overflow-enables.html https://kristerw.blogspot.com/2016/02/how-undefined-signed-o...
- Nadya 10y agoGiven the explanatory text - I think this was more of a "test of intuition" accompanied by a "gotcha!" As someone unfamiliar with C - I initially thought it would go on forever. The explanatory text explained why I was wrong and this can be equally parts "clever code" or a "gotcha!" depending how you view it. With your experience you're seeing it as overly clever code. With mine, I'm seeing it as a "gotcha". I don't think it is supporting writing code like that. :) >The third for appears like it would go on forever, but actually counts down from 9 to 0. In fact, in the next section we will see that “sizes” in C, that is numbers that have type size_t, are never negative.
- imron 10y ago> I would not let that line pass code review. At least it's not for (size_t i = 9; i >= 0; --i) :-)
- colanderman 10y agoI agree. For this reason I wish the author would promote (no pun intended) the use of signed arithmetic.
- renlo 10y agoYour for loop works, whereas the one in the parent comment would run forever, correct? Is there something I'm missing here? edit: Ok, looking at it again the parent example is probably going to overflow or something right?
- awinter-py 10y agoYikes. important words that don't appear in this: 'static analysis', 'verification'. On the 'wow' side, had no idea there was a _Generic macro. Pretty cool.
- jackhack 10y agoI wish I could like this book, but after reviewing the first chapter I can only imagine the confusion of students. I support very much the idea of breaking the book into levels, but it attempts to cover far too much, far too quickly and I don't believe this book would be useful for those who are not already familiar with the language. I've been writing C since the late 1980s, moved to mostly C++ by the mid 90s, C# in the 2000s, and now I've come back to C. Most recently built some realtime components and drivers, having to drop back to C77. I mention this as I've taught many colleagues along the way and I'm sensitive to the places where beginners tend to get hung up with problems and I've come to anticipate many of the questions along the way. Let me take a moment to illustrate the base of the problems i see: "Too much, too fast." The best example is right on page 2: a program which demonstrates a complex printf format string, along with arrays and loops. I can't help but sarcastically ask "Are you sure that is how you want to introduce someone to the language?" A beginner's eyes will glaze over. Seriously, the way to introduce the language is simple examples. Explain the main is the entry point where all programs begin running, and that main returns it's success or failure to the operating system (or other program that called it). 3 lines of code. Then add a SIMPLE print, if you wish, or a variable declaration. Int. Float. char. again, it MUST be simple. Introduce loops. Then show how to move some functionality out of main into a subroutine/a new method/new function, how to call that function, and return results. Talk about header files, etc. From there, dive into the rest of the base language... talk up arrays, memory management, heap/stack, pointers, libraries, exceptions, etc. But this is only my experience, and I'm sure that it is different for others. Kind regards.
- pselbert 10y agoYour experience sounds spot on to me. No matter what you are teaching, whether it is fundamental like reading, physical like a sport, or technical like programming, it is critical to teach ONE THING at a time. Teaching multiple concepts at once muddles the exercise and slows down learning. Breaking large concepts into discrete blocks lets the student focus and then build on that concept as they continue. That's certainly how I work, and how I've heard experienced teachers explain it.
- komali2 10y agoThis has always been my problem with websites like codeacademy, and I started my entire career by learning through that website. Take the Javascript course - a fantastic way to get introduced to the syntax of the language, and I highly recommend it for total noobies. But then you come out of it with no understanding whatsoever about what javascript is. If I asked someone who just finished the course to make an "app" that console.log'd to the console, they wouldn't understand where to start. They wouldn't know that JS is a language run in the browser, that they need an HTML file with a script tag or a node file that they can run in the terminal. They wouldn't know about DOM manipulation, etc. This reminds me of the Java class I took in highschool - the teacher was going on about ints and floats and loops, and the only questioned I wanted answered, and never got an answer for, was "what does `public static void main` mean?" I think the fact that I never got an answer to questions like that are why it took me nearly 3 years into my career to figure out I should be a developer.
- sndean 10y agoPardon my noobness, but if I learned and became proficient in C and knew nothing else, would I have a marketable skill? Is it possible for C to be a standalone skill, where ones job could be 100% programming in C, or do you need a lot of auxiliary knowledge outside of that?
- ksherlock 10y agoYes and that's true of any marketable language.
- __d 10y agoProbably not. C doesn't exist in a vacuum: it has to run on something. And the standard library doesn't get you very far. You'd need to know at least one OS API as well: POSIX is probably best, maybe Win32, an embedded OS/executive might work also, or perhaps even a bare-metal CPU or two. C + POSIX covers a lot of the Open Source world, and increasingly more of the embedded market. C + VxWorks is possibly the next best combo.
- ArkyBeagle 10y agoYou'd need a lot of auxiliary knowledge outside of that. Perhaps FPGA programming, perhaps even hardware development.
- crpatino 10y ago> would I have a marketable skill? Yes. Systems programming and Embedded are your best and most visible playing fields, but many large, legacy applications were written in C and continue to be maintained. > Is it possible for C to be a standalone skill, No. As others have pointed out, the language + standard library is very spartan and will only take you so far. This will only get you an entry level position, and only in teams that are big enough to have some senior people with spare capacity for mentoring, and a stream of small, self contained tasks for you do while in training. To be able to work independently you need to have at least some basic knowledge of the whole toolchain: Compiling (you need to know to heart the different steps that are taken by the compiler, and at least its 20% most common cmdline flags), Building (make), program analysis (lint, valgrind), debugging (gdb, or whatever comes with the compiler you are using), 3rd-Party-Libraries (pick 2-3 of: glib, pthreads, antlr, curses, openssl, etc), Standards (MISRA, POSIX - which is at least as much about the API to Unix-like OS as it's about the C language). From there, there are more tools to help you, but those are typically OS dependent and are not exclusive to C.
- joveian 10y agoI haven't looked at this updated version (site is busy :/) but the version I looked at a while ago is quite good. The author's use of register to avoid aliasing is something I hadn't heard before and seems like a good idea in some cases. Beyond the learning C aspects, I really hope that some of the author's suggestions for language extensions are implemented.
- manish_gill 10y agoIf people aren't so into this book, can anyone suggest some other book beyond K&R?
- hackcrafter 10y agoLearn C the Hard Way was Zed Shaw's aspiration of a K&R Replacement[1]. If you like it, great, if you don't, you have company[2] [0] https://learncodethehardway.org/c/ https://learncodethehardway.org/c/ [1] https://web.archive.org/web/20141205223016/http://c.learncodethehardway.org/book/krcritique.html https://web.archive.org/web/20141205223016/http://c.learncod... [2] http://hentenaar.com/dont-learn-c-the-wrong-way http://hentenaar.com/dont-learn-c-the-wrong-way
- kruhft 10y agoThe best book I had for learning more about C was titled 'Writing Bug Free Code For Windows' from the late '90s early 2000's. It contained a complete object oriented system using simple header tricks and data hiding plus covered all sorts of pre-processor tricks that aren't evident until you really dig into what C can really do. I'm sure it's impossible to find now, but recommended.
- hitlin37 10y agoHi, is there a epub version of this book? The pdf format is painful to read.
- kasabali 10y agoSeconded. If it is not feasible I would appreciate a narrow PDF (like A5) with minimal margins which should be good enough for reading on a Kindle.
- leighflix 10y agoWould any C-lovers recommend this book to people that already know programming (but not sys programming) wanting to learn C? I personally know Java, (lil bit) Elixir, and Python. EDIT: I'll also be reading K&R along side it.
- maqbool 10y agowhere i can find Errata list of this book.