22 ms·
Modern C, Second Edition
- fxleach 7y agoI guess no pre-ordering, the link is broken: https://www.manning.com/books/modern-c https://www.manning.com/books/modern-c
- arthurcolle 7y agoPDF is here: https://gforge.inria.fr/frs/?group_id=6881 https://gforge.inria.fr/frs/?group_id=6881
- markdoubleyou 7y agoWow, I wish more technical books used LaTeX for typesetting like this. Beautiful.
- mikece 7y agoSince you mention typesetting: I am working on a volunteer project that is transcribing old, out of print books from the 1700s through early 1900s (all public domain). For now the plan is simply to make them available online formatted for web, e-readers, and PDF, but thought is being given to formatting for print-on-demand. We've never done the latter so we have no idea what tools would be best for that: is there a good reference for free tools/software for doing page layout for physical books?
- jkepler 7y agoLaTeX or TeX would be excellent choices if you want good typographic control, though there's a significant learning curve if you're going to produce beautiful books. Check out https://www.ctan.org https://www.ctan.org to start learning more. They have lots of book publishing resources: https://www.ctan.org/topic/book-pub https://www.ctan.org/topic/book-pub
- photojosh 7y agoAny connection to https://standardebooks.org/contribute/ https://standardebooks.org/contribute/ or if not, are you online yet? Wouldn't mind having a look. (And also interested in the print typesetting question.)
- abhgh 7y agoIf you want to begin with what your outcomes could look like if you use TeX and friends, as suggested by jkepler, see here - [1]. [1] https://tex.stackexchange.com/questions/1319/showcase-of-beautiful-typography-done-in-tex-friends https://tex.stackexchange.com/questions/1319/showcase-of-bea...
- bingerman 7y agoContext would be a convenient tool for the job. You can create pdf, xml, and epub from the same source. You get the power of Tex but producing modern looking stuff is IMO much easier than with Latex. I personally usually use Latex for short articles and Context for books.
- lqet 7y ago> Beautiful. Is it? I skimmed over it, and I don't find the typesetting / listings / tables / highlighting particularly appealing.
- wyldfire 7y agoI wonder if it used a publicly available style? I like how some stuff looks, I'd like to experiment with this.
- ternaryoperator 7y agoHonestly, I prefer Manning's regular typesetting, which is also beautiful and clear.
- stplsd 7y agoI hate LaTeX typesetting, it looks very archaic and reeks of academism (is that a word?). Unless document require lot of formulas, LaTeX is not a right tool in 2019.
- bingerman 7y agoYou probably don't hate Latex typesetting. It's just that the kind of default styles that people, especially beginners, tend to use that often look archaic. Latex doesn't make creating your own unique styles too easy though, which is why I personally prefer Context.
- efficax 7y agoInsane take. Latex can look like anything you want and also has amazing microtype features these days
- jrumbut 7y agoIs this file not opening for anyone else? Can't seem to get it to open?
- def- 7y agoSome PDF viewers have trouble with it.
- montalbano 7y agoDepends where you are, Waterstones (UK) has it available for pre-order (where I have ordered mine from): https://www.waterstones.com/book/modern-c/jens-gustedt//9781617295812 https://www.waterstones.com/book/modern-c/jens-gustedt//9781... Also book depository which I think delivers worldwide: https://www.bookdepository.com/Modern-C-Jens-Gustedt/9781617295812 https://www.bookdepository.com/Modern-C-Jens-Gustedt/9781617...
- aportnoy 7y agoIs this a good book, can anyone comment?
- torstenvl 7y agoI'm not a fan so far. Lots of deliberately bad C code. Using uninitialized variables, etc. Explanation of jargon seems to take priority over explanation of the language - the term "string literal" is explained before the concept of a function.
- tym0 7y agoWhat book would you recommend as an alternative?
- jacobkg 7y agoI learned C from “C Primer Plus” about a decade ago and I thought it was terrific: C Primer Plus (6th Edition) (Developer's Library) https://www.amazon.com/dp/0321928423/ref=cm_sw_r_cp_api_i_bgNGDb3GWV3VF https://www.amazon.com/dp/0321928423/ref=cm_sw_r_cp_api_i_bg...
- AlexeyBrin 7y agoC Programming: A Modern Approach, 2nd Edition by King is a good beginner book. 21st Century C by Ben Kelemens is also a good book.
- learc83 7y ago> C Programming: A Modern Approach, 2nd Edition by King is a good beginner book. I would recommend that as well. Dr. King was one of my favorite professors, but I bought that particular book on my own.
- Apocryphon 7y agoHow about Zed Shaw's Learn C the Hard Way?
- ncmncm 7y agoContradiction in terms.
- saagarjha 7y agoThere’s a lot of new things in C since the K&R book came out.
- ncmncm 7y agoHalf of them cribbed from C++.
- saagarjha 7y agoNot really; C has a number of things that C++ never adopted such as restrict and partial structure initialization (although this might be coming to C++).
- ncmncm 7y agoHalf does mean some are, some aren't. "//" comments, function prototypes, const, atomic, inline, complex, mid-block definitions are. Runtime variable local arrays, designated initializers, restrict not. C++ cribbed designated initializers from C, coming in '20. Restrict was cribbed, late, from Fortran.
- wahern 7y ago> C++ cribbed designated initializers from C AFAIU C++ will require that you initialize the members in the same order as defined. It also won't permit you to exclude any definitions. Why even bother? Somewhat controversially, C permits you to define members multiple times, with the last definition taking precedence. Compilers sometimes warn about this, but I've personally found the behavior useful--I'll write an API that provides a macro with default values yet which allows the user to override any particular definition. I don't think I've ever had a bug in an initialization, at least not involving multiple definitions. That seems like a very easy and superficially useful diagnostic to write, but which prevents useful behaviors; behaviors that named initializer's were deliberately designed to provide.
- Santosh83 7y agoOn a related note, do we have any fully complaint C11 compiler for MS Windows or is using gcc under WSL (or a VM) the best option? I take it there is no C17 compliant compiler yet?
- rwmj 7y agoGCC 8 and above support C17, and there is a version available for Windows. See also: https://gcc.gnu.org/onlinedocs/gcc/Standards.html https://gcc.gnu.org/onlinedocs/gcc/Standards.html
- AlexeyBrin 7y agoClang and GCC both support C17 and there are binary versions for Windows see MSYS2. I think Pelles C also supports C11.
- basementcat 7y agoDoes glibc support cthreads yet?
- AlexeyBrin 7y agoAFAIK, C11 threads are supported only in Linux. From a glibc point of view C11 threads are supported since v2.28.
- earenndil 7y agoC11 threads are also available on freebsd and possibly (don't know) other BSDs. Pelles c also supports them.
- jeremyjh 7y agoYou don’t need WSL to run gcc on windows. You can use the mingw distribution to get a GNU tool chain that compiles a standard windows EXE.
- 7y ago
- baby 7y agoIsn't modern C pretty much Rust?
- coldtea 7y agoNo, for the foreseeable future (20-30 years) C will still be 10x larger than Rust in code and deployments...
- joshbaptiste 7y agoEh more like C++, Zig is more of a modern C
- ncmncm 7y ago10000x
- lone_haxx0r 7y agoCall me when Rust becomes the interface to the most used kernel in servers and supercomputers.
- gpm 7y agoI wouldn't call syscalls anymore "C" than "Rust". Neither language can make them without library support or inline assembly. Both can with.
- phonebucket 7y agoI think the parent comment was less about the capability of Rust, but more about the overwhelming momentum that C has.
- deleted 7y ago[deleted]
- gpm 7y agoAnd on that I'd fully agree with him. My comment also isn't really a comment about rust. It's about a common misconception that the unix/linux kernel somehow talks in "C". Libc talks in C, most of the other libraries talking for interfacing with the kernel talk in C. The kernel speaks it's own language that has no special relation to C at all.
- sys_64738 7y agoDo people still use K&R these days?
- mistrial9 7y agoI would liken that to "middle-english" or similar interesting but archaic forms. https://en.wikipedia.org/wiki/Middle_English https://en.wikipedia.org/wiki/Middle_English
- big_chungus 7y agoThat's what I used first. I did a lot more study, but I think that's actually the only book I used. What did it for me was trial-and-error and practice, but the most important part was getting the basics down so I could start reading through other people's good code.
- arawde 7y agoI can't speak for everyone, but I read K&R 4 years ago to supplement some of my classes in universtiy
- Gibbon1 7y agoIf someone tells you to use K&R take that as license to ignore their advice from that point on.
- valacmur98 7y agoI am using it to study C. Can you tell me the reason why you wouldn't recommend it?
- saagarjha 7y agoI really enjoyed it, but it’s best supplemented with exposure to modern C syntax and an introduction to undefined behavior.
- ThrowawayR2 7y agoDespite being amazingly well written, the most recent edition of K&R was published in 1988. The current version of C is C18, released last year, so K&R is missing about 30 years of evolution. It's not a bad book, by any means, but it doesn't include important aspects about how C is used today.
- mrspeaker 7y agoDamn it, two giant gross "toenail fungus" ads taking up most of the page - shocked me a bit and I closed the page really quickly (and probably now associate this book with fungal diseases - choose your ad providers carefully!)... Is there a non-fungus-y link to this book somewhere?
- AlexeyBrin 7y agoTry this link http://modernc.gforge.inria.fr/ http://modernc.gforge.inria.fr/
- mrspeaker 7y agoAwesome, thanks!
- boring_twenties 7y agoI was theoretically aware that there are people out there that don't use ad blockers, but I sure as heck didn't expect to find one on hackernews. I'd recommend uBlock Origin.
- dlivingston 7y agoThat's an ethical question that I've weighed a decent bit. I don't use ad blockers personally, as ads are truly the reason most of the internet is free. If ads are too intrusive, I will 'vote with my clicks' and avoid that particular website in the future. There are privacy concerns with this, of course, but DuckDuckGo and modern Safari (with cross-site tracking prevention) helps mitigate a bit of it.
- iamnotacrook 7y ago"If ads are too intrusive, I will 'vote with my clicks' and avoid that particular website in the future." They'll never even notice, and in the meantime you're at risk of all sorts of trackers, malware etc. Plus...you're seeing adverts all the time. I used chrome on android the other day and I couldn't believe how many there were, or how annoying. If you're not clicking on them it means nothing anyway, as far as I can tell. I remember back in the day sites saying "click on the ads - it helps us" but I don't think that's a thing any more. Perhaps I should knock up a script to visit random sites with ads and maybe click on a few, in a container/vm. Would that help?
- vymague 7y agoLink for the code examples on http://modernc.gforge.inria.fr/ http://modernc.gforge.inria.fr/ is broken. Should be .../5298/code.zip instead of 5297, I think.
- big_chungus 7y agoAs long as he's publishing under a CC license, it might be nice to release the LaTeX source as well. PDF is usually good enough, but sometimes needs to be converted to other formats; you usually get best results going latex->epub than pdf->epub. Some devices it's a lot easier to be able to change attributes to better fit the form factor.
- compressedgas 7y agoIf the source was available, we could fix all the formatting errors.
- hasahmed 7y agoCool stuff! Typo in first paragraph of https://gustedt.wordpress.com/category/c/ https://gustedt.wordpress.com/category/c/ (mayor instead of major)
- syphilis2 7y agoIs there a place to report errors? I've just skimmed through and the pdf has some possible formatting bugs: tables inside code blocks, page breaks splitting the tops of code blocks, small things like that.
- ausjke 7y agoThe Linux Programming Interface: A Linux and UNIX System Programming Handbook - is arguably the best C programming book nowadays if you code in Linux/Unix, the rest C books are most for ANSI C, that might be more useful for bare metal embedded system that does not run a full multi-task POSIX OS?
- sigjuice 7y agoIMHO, the phrase “C is a compiled programming language” is super confusing. Edit: there are many languages that have both compilers and interpreters. There are several C interpreters as well. The classification of languages as “interpreted” or “compiled” does not appear to be a sound concept, IMHO.
- pmikesell 7y agoWhy? I guess it's because some interpreted languages are also compiled? "Compiled" traditionally means "not interpreted", or rather "compiled to machine code".
- _ZeD_ 7y agobecause languages are specification, "books". they are not interpreted nor compiled. The most common implementations of the C language are compilers, yes, but "compiled" it's not a language property oh, and btw: there are multiple c interpreters
- mrmuagi 7y agoAs another denizen of this chain, I still don't see the confusion at all. > because languages are specification, "books". they are not interpreted nor compiled Languages are a specification, and an implementation working together in perfect harmony, with absolutely no undefined behaviour at all, yes, keep walking now. At least... the good ones try to be, cough ignoring small half baked interpreters and compilers I've had the pleasure of working with cough and never touching again. > The most common implementations of the C language are compilers, yes, but "compiled" it's not a language property It absolutely is a large part of the C language and worth teaching, and I'd only split hairs in a programming language theory class, this is a book that presumably leaves the reader with a better grasp of C than before. And arguing against it is an exercise in personal experience I assume (you have C interpreter experience I wager?). Most people are still taught C in terms of a compiler like gcc, or clang. Source code in, object code (for a specific language specification, target architecture, etc) out. Think operating systems, kernel modules, executables, dll's, and, etc. I never touched a C interpreter (but I am curious at such a beast), but I know that C is fine to be referenced as "compiled".
- nullbyte 7y agoA little off topic, but that is some terrible art on the book cover.
- reificator 7y ago> A little off topic, but that is some terrible art on the book cover. Relative to other books in the series, or do you object to the "historical fashion" style book covers that publisher tends to use?
- Etheryte 7y agoTo be fair, I don't think I've ever seen a serious, hardcore programming book that looked nice. They're either neutral, or just downright weird [1]. [1] https://en.wikipedia.org/wiki/Structure_and_Interpretation_of_Computer_Programs#/media/File:SICP_cover.jpg https://en.wikipedia.org/wiki/Structure_and_Interpretation_o...
- wutbrodo 7y agoAw man I was gonna hold up SICP as a counterexample
- giorgioz 7y agoegghead.io has some awesome illustration for the courses: https://egghead.io/browse/languages/javascript https://egghead.io/browse/languages/javascript Technical book publishers should just stop hiring ink illustrator that like medieval drawings and get graphic illustrators that like Adobe Illustrator and SVGs
- infiniteseeker 7y agoFrom the author's page: > I find such a C library project aiming to be standard .... with a really humane discussion culture, a proof that people (even men!) can constructively work together to achieve great things without denigrating each other. Is this casual sexism helpful to anyone, men or women?
- reificator 7y agoWhether it's helpful or not, I hope it's self aware. Jumping from denigrating men to celebrating a culture without denigration in a single sentence is impressive.
- maxymajzr 7y agoWhy is it always that SJWs like you need to find that one joke, one excerpt and turn it into some kind of personal war/problem/argument/discussion/hate? Instead of focusing on the VALUE brought by the author, you managed to dig up one benign joke and went on to discredit the entire thing. What's worse, you actually put EFFORT in finding something you can use for this purpose. Why aren't you ashamed of yourself?
- fao_ 7y ago> Why is it always that SJWs like you need to find that one joke, one excerpt and turn it into some kind of personal war/problem/argument/discussion/hate? Namecalling ("SJWs like you") is against the hacker news guidelines. I would suggest you read them. Also, it's worth noting that actual, self-proclaimed SJWs (I am one, I know many, and am in their communities) wouldn't have any problem with the joke in question, because it's "punching up", i.e. it is making a joke about social problems in a group that has the systemic advantage. So your name calling isn't even accurate in this case. > Instead of focusing on the VALUE brought by the author, you managed to dig up one benign joke and went on to discredit the entire thing. Please point out where the poster "discredit[ed] the entire thing". I don't see them discrediting the entire book, I see them questioning a bit of context around the joke, which is a perfectly valid thing to do. > Why aren't you ashamed of yourself? Why aren't you? The poster is asking a legitimate question around the context of a line of the book, and you're insulting them and denigrating them for this.
- mobilemidget 7y agohttps://www.manning.com/books/modern-c https://www.manning.com/books/modern-c Gives me a 404?
- ukyrgf 7y agoScandalous language on page 3! > printf("element␣%zu␣is␣%g,␣\tits␣square␣is␣%g\n",
- donedealomg 7y agoNice, any news on an update on C Programming: A Modern Approach? Because I liked that book even more :-) Thanks
- k_sze 7y agoHow does this book compare with "21st Century C"? I know that, unlike "Modern C", "21st Century C" can't possibly cover C17 because that book was released in 2014. But otherwise, what would be notable differences? In terms of style, correctness, idiom, depth, and breadth?
- AlexeyBrin 7y agoC17/C18 is a minimal "bugfix release" to C11, mostly standard clarifications. https://en.wikipedia.org/wiki/C18_(C_standard_revision) https://en.wikipedia.org/wiki/C18_(C_standard_revision)
- bumblebritches5 7y ago1 macro was deprecated, ATOMIC_VAR_INIT, it's not needed. that's the only user facing change in C18.
- fermigier 7y ago"Modern C" is a beginners book. "21st Century C" is for people who have learned C in the past but need to brush up their knowledge with modern practices. As someone who learned C at the time of the first edition of the K&R, "21st Century C" would be more useful if I ever had to code in C again (which hopefully I won't). A refresh, 5 years later, would be useful, though.
- mister_hn 7y agolove it, thank you for giving the PDF out for free
- deleted 7y ago[deleted]
- skocznymroczny 7y agoI'd love a language that feels like a more convenient C. C as it is, with some niceties like built-in containers with some nice syntax sugar. Maybe someday Zig will get there.
- gnode 7y agoWhy would conservative use of C++ not meet this mark? It's highly compatible with C, has container types, ranged for-loops, operator overloading which makes use of container types more sugary.
- DagAgren 7y ago"Conservative use" introduces a massive cognitive load of trying to figure out what you are and what you aren't using. And the ergonomics of modern C++ look absolutely horrid compared to actual modern languages.
- humanrebar 7y agoHow is it a massive cognitive load? Use clang libraries and error out if there are any operator declarations, for instance.
- AndrewGaspar 7y ago"How is it a massive cognitive load? Just write a bunch of tooling to enforce your rules!"
- humanrebar 7y agoIt's simpler than the tutorial example for python-clang. It's strictly less work than a responsible unit test suite, and there's not much downside to getting some details wrong on this particular application.
- 7y ago
- jakedub4d2 7y agoWhere is the Holy C edition :) (PS. I know about his rants on ycomb) If you can get past his rants, some of his concepts end up pretty neat. To experience it, just download the ~12mb OS and run it in VM Virtual Box pretty quickly. Choose 64bit alternative OS. https://www.vice.com/en_us/article/wnj43x/gods-lonely-programmer https://www.vice.com/en_us/article/wnj43x/gods-lonely-progra...