Live data from Hacker News

Ask HN: Learn C in 2023?

news.ycombinator.com

31–40 of 220 posts

Re: Ask HN: Learn C in 2023?

#31
post #17

I like firearms as an analogy here. Rust is like a modern rifle, unloaded, with six safeties and three locked triggers in a gun safe. The ammunition will harmlessly self-destruct if you don’t focus properly before firing. C is sort of like Rust except the rifle is on the couch, loaded, one in the chamber, all the safeties are off, the numerous open triggers are held by RNGs, and the business end is pointed right at y…

Meh. People love to hate on C but the invariants you have to keep track of are relatively simple (things like 0 Some languages like Rust and Haskell do a little better by having the compiler keep track of most of them (if you use it right) but the consequence of misunderstanding them here is accidentally coding yourself into a corner which is extremely unpleasant. There are other things people like to talk about like…

I mean I’ve worked with C for a long time. It’s love-hate. I think it’s hard to see the value from the other side of having internalized C, and Rust definitely encumbers you.

The number of things a beginner doesn’t have to know or worry about to code something as essential as a function that reads a file, searches for a string, and interacts in a serious way with the network in Rust vs C is substantial.

Probably I’ll get downvoted again but it’s fine.

Re: Ask HN: Learn C in 2023?

#32
post #27

Does anyone have a good recommendation on developing operating systems?

This depends on how deep you want to go. I honestly recommend starting small.

First, Code by Petzold to make sure you understand how a computer truly works. Then I recommend:

Understanding Microprocessors (Motorola)

8086/8088 Assembly Language Programming

Dissecting DOS

Practical Filesystem Design

FreeBSD Internals

The reason there are so many books is because it’s a big topic. The reason most are old is that things were once much simpler. Modern stuff builds on old, so if you get a good understanding of older stuff, you have an idea of what is happening. From there, I strongly recommend getting a good understanding of UEFI. UEFI will handle most of your system initialization no boot requirements, allowing you to focus on higher level stuff. Prior knowledge of systems will still be a requirement so that you can understand some of the assumptions and choices that UEFI makes.

OSDev is fun. I hope you have a good time.

Re: Ask HN: Learn C in 2023?

#34
Programming in C can turn you into a very disciplined programmer for the simple fact that you will need to track when you request memory and when you need to free it. Essentially you will become the garbage collector. I would recommend you to the read classic "The C Programming Language" (Kernighan & Ritchie) and "Expert C Programming Deep C Secrets" (Van Der Linden) which will get you far enough to write useful programs. I read half of Gustedt book and it has good advice, probably need to pick it up again. A good starting point is to implement your own data structures, like lists, double linked lists, dynamic arrays (had a lot of fun implementing this one). Also (this is personal preference) I would learn a bit of the autotools, they are painful to learn and feel kind of ugly, but once they are in place you basically will forget about a ton of things and your build will become a joy (there's a nice book by No Starch Press about it). I've managed to integrate Check (https://libcheck.github.io/check/) so now I have unit tests in C which is something nice.

Re: Ask HN: Learn C in 2023?

#35
post #11

I recommend C Programming: A Modern Approach by K.N. King http://knking.com/books/c2/index.html . My favorite part of this book is the exercises at the end of each chapter.

One of my favorite professors. His programming language concepts course was the most useful useful class I took in university.

I also recommend his book.

Re: Ask HN: Learn C in 2023?

#37
post #8

https://www.learn-c.org/ If you have lots of time: https://hal.inria.fr/hal-02383654 If you can't be bothered reading a whole book: https://matt.sh/howto-c Exercises: https://www.codestepbystep.com/problem/list/c and https://exercism.org/tracks/c Once you have syntax and basic algorithms down well, watch this, the only 2 hour YouTube video I'll ever recommend: https://m.youtube.com/watch?v=443UNeGrFoM Both r/cprogram…

Any recommendations on static analyzers, unit tests, coverage for c? Can clang tidy give hints about modern c they way it does about modern c++?

Re: Ask HN: Learn C in 2023?

#38

Earlier quoted context omitted.

Meh. People love to hate on C but the invariants you have to keep track of are relatively simple (things like 0 Some languages like Rust and Haskell do a little better by having the compiler keep track of most of them (if you use it right) but the consequence of misunderstanding them here is accidentally coding yourself into a corner which is extremely unpleasant. There are other things people like to talk about like…

> the invariants you have to keep track of are relatively simple (things like 0 If maintaining these invariants were so simple, why would the smartest people in the industry have so much trouble doing so? Humans cannot consistently write correct C, not even the ones who believe they can. We have decades of evidence. > Most languages replace these with multi-dimensional string based hashmaps that have much more comple…

My point is that they can't consistently write correct software in any language. Javascript for example has similar issues where if you're not careful about which keys in a hashmap you write to you can create situations that allow for all kinds of things including arbitrary code execution.

Modern C compilers/runtimes also have bounds checking (although I've never used it) like java if you want to use it.

Sure there's some improvement but it's not nearly as extreme as it's made out to be.

Re: Ask HN: Learn C in 2023?

#39

Well, GNU/linux is more "C plus GCC" than pure C. There are a lot of fancy things that GCC gives you that you'd otherwise have to do explicitly.

C has the unique distinction of being criticized on the one hand for the complexities of vendor-specific extensions and portability concerns... and on the other for being insufficiently like Rust or Go, which are defined entirely by their proprietary implementations. I don't think I've ever seen this criticism leveled elsewhere. Do people criticize JavaScript programming because the ECMAScript standard doesn't give y…

There is no meaningful sense in which either Rust or Go’s reference compilers is “proprietary.” If you’re trying to say that there is no ISO standard for the two, that’s an entirely different problem (and one shared by the overwhelming majority of programming languages).

Re: Ask HN: Learn C in 2023?

#40

Well, GNU/linux is more "C plus GCC" than pure C. There are a lot of fancy things that GCC gives you that you'd otherwise have to do explicitly.

C has the unique distinction of being criticized on the one hand for the complexities of vendor-specific extensions and portability concerns... and on the other for being insufficiently like Rust or Go, which are defined entirely by their proprietary implementations. I don't think I've ever seen this criticism leveled elsewhere. Do people criticize JavaScript programming because the ECMAScript standard doesn't give y…

yes
Post reply on HN