6 ms·
C works everywhere, and everyone knows C, or can learn it in a couple of weeks and get coding. This is a hard combination to wholesale replace, but then not eve
by Santosh83 9y ago
C works everywhere, and everyone knows C, or can learn it in a couple of weeks and get coding. This is a hard combination to wholesale replace, but then not even Rust aims to do that. Instead it aims to chip away gradually, and I don't see why it can't do that .
- foota 9y agoI would argue that while writing your first c doesn't take much knowledge (and is much easier than say rust), writing good C is harder than writing e.g., good Java. (Where I'd say some dimensions for good are bug free, reasonable performance, and readability)
- geezerjay 9y ago> C works everywhere, and everyone knows C, or can learn it in a couple of weeks and get coding. You hit the nail in the head. The go-to tutorial and reference book of C is «The C programming language» by Brian Kernighan and Dennis Ritchie, which provides a complete and very thorough description of C and its standard library in less than 260 pages. That's unbeatable. As a comparison, the go-to book for C++, «the C++ programming language» by Bjarne Stroustrup, goes beyond 1200 pages and doesn't cover some fundamental aspects of C++, and even «The Rust Programming Language» by Steve Klabnik and Carol Nichols, a book on a programming language which was designed to eat away C's market, is over 400 pages. This speaks volumes on the effort required by anyone to get on their feet and be productive with these programming language.
- bluejekyll 9y agoFrom the article: “One standard textbook takes 534 pages to explain secure coding standards in C“
- oblio 9y agoYes, but that comes later. When Joe. D. Newbie wants to start programming, C seems quite approachable, conceptually. Hack away at things in an imperative fashion. There's a reason Visual Basic, Perl, PHP, Java (+IDEs), Javascript are/were the most popular languages. They're easy to get into. I'm not counting C++ because it was piggy-backing on C.
- bluejekyll 9y agoYou get safe programming for “free” in Rust. So those 400 pages mentioned are not equivalent to what you glean from the intro to C book. It’s not a fair comparison. Edit: fixed pronoun referencing gp...
- rurban 9y agoNo, Rust is not safe. From the 3 fundamental safeties: memory, concurrency and types, Rust only provides type safety.
- steveklabnik 9y agoWhat do you mean? Memory and concurrency safety are so important that they're in the main slogan of the language.
- Ar-Curunir 9y agoRust has the first two, and a rather strong type system, which is soon getting the equivalent of higher minded types, putting it roughly on par with Haskell in that respect. How much stronger do you want your type systems to be?
- syrrim 9y ago>You get safe programming for “free” in Rust. Not really. Rust will tell you your program is unsafe at compile time, whereas c will tell you at runtime. The major difference is that c sometimes won't tell you about an unsafe program, whereas rust will call perfectly safe programs unsafe. Note that for a beginner, the former is vastly preferable, because it allows them to iterate much faster. It doesn't matter if your code is buggy if you throw it away, and it doesn't matter if your code has security bugs if it will never be worth hacking.
- kibwen 9y ago> When Joe. D. Newbie wants to start programming, C seems quite approachable, conceptually. Coming from Java, my first experience with C was trying to write a trivial program and seeing nothing but the text "Segmentation fault" at runtime. Expecting a nice Java-like backtrace to tell me where the error was, I raised my hand and asked the TA what a "Segmentation fault" meant, and how to get a backtrace. He laughed, rolled his eyes, and went back to playing Slime Volleyball. Compared to any other language in use these days, C is anything but approachable. And when it comes to learning "secure coding standards in C", as the grandparent comment mentions, one cannot risk putting that off lest they develop bad habits that are never undone (though other environments share this property as well to some degree, e.g. PHP and client-side Javascript).
- geezerjay 9y ago> From the article: “One standard textbook takes 534 pages to explain secure coding standards in C“ If you wish to compare books on specialized topics, the book on C++'s STL by Jossutis spans over 1100 pages and the book on C++ Templates by Vandevoorde, Jossutis and Gregor spans over 800 pages.
- steveklabnik 9y agoDifferent books have different goals. K&R is short, but the standard is ~700 pages. The Rust book is over 400 pages, but contains entire chapters of just "let's build a project together." There's no spec yet like C has. Writing styles differ dramatically, K&R are more concise than I am, and don't dive into some details as much. Then, you may also consider the framing of "simple" vs "easy", they're not the same thing. And that's even if we agree that C is simple in the first place, which I personally consider not true. Basically, I don't think that comparing page counts of random documents says anything meaningful about language complexity.
- crispinb 9y agoAs an aside I don't have time or any purpose beyond curiosity to learn Rust right now. But having glanced through the Rust book a few times, I wish I did. It's the sort of book (a bit like K&R in this sense) that could lead one astray ..
- steveklabnik 9y agoThank you; even saying "a bit like K&R" at all is high praise to me. That said, not everyone likes my writing style, so I'm glad that there are other books coming out as well.
- geezerjay 9y ago> Different books have different goals. K&R is short, but the standard is ~700 pages. ISO/IEC 9899:1999 is 554 pages, and the annex alone takes around 140 pages. ANSI ISO 9899:1990 is even shorter: 230 pages.
- steveklabnik 9y agoI'm going by ISO/IEC 9899:201x, the draft, since I have not paid for the spec. This does include annexes, but some of them are normative... Really though, this just furthers my point; page count is a terrible metric for this.
- nine_k 9y agoI bet that manuals of Basic-80, Forth, Scheme, and Smalltalk are all short. The amount of power they give you differs drastically, though.
- anonacct37 9y ago"The C programming language" is a fantastic book and I treasure it. Unfortunately it's also not a book I would recommend to people who want to write good secure code.
- crispinb 9y ago> everyone .. can learn it in a couple of weeks and get coding Not so sure about that. I started on assembly and then C, though did neither professionally. But I'd be a bit scared of touching a serious C codebase now. There's so much to think about there that only long experience can really prepare you for. Sure you can cover the language very quickly with K&C (and what fun compared to much dev learning). But although I'm out of touch with the C world now, I suspect it would take a long time to get from there to being more useful than dangerous.
- naasking 9y ago> C works everywhere, and everyone knows C, or can learn it in a couple of weeks and get coding. I think you mean, they think they learn it in a couple of weeks, and then over the next 10 years are continuously surprised at how little they actually understand C.