Live data from Hacker News

Ask HN: Learn C in 2023?

news.ycombinator.com

41–50 of 220 posts

Re: Ask HN: Learn C in 2023?

#41

Earlier quoted context omitted.

> 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…

It's true that humans will inevitably produce software with defects. There are differences in the impacts of these defects.

> 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.

Not without eval() you can't.

> Modern C compilers/runtimes also have bounds checking

No, they don't. There are C-like languages (e.g. C++/CLI) that do, and you can use containers, but no, plain C cannot do bounds checking. There's no room in the ABI for it, at least not without CHERI or ASAN.

> although I've never used it

One of the most dangerous things in the world is giving powerful tools to people who don't know that they shouldn't use them.

Re: Ask HN: Learn C in 2023?

#42

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 prog…

I’m also a traditionalist and I think the classic K&R C Programming Language book is the best way to learn C—you also get an understanding why C and *nix-based systems seem to go so well.

Re: Ask HN: Learn C in 2023?

#43
post #16

I'm a C# guy who learnt C over the past 2 years. It absolutely made me a better programmer. I learnt by going through K&R first and then Expert C programming by Peter van der Linden. I also went through OS books, books that talk about the machines like Understanding the machine. I program in many high level languages. The main difference I felt when learning C is, I felt like I needed to learn how the machine actuall…

As C# guy who had to work with C for a while - this language is minefield.

If you want to create your own language and want to experience what choices are subpar by modern standards - C is way to go.

If I had choice then I'd pick Rust anytime when messing with low level programming.

I don't understand fascination with C just because it's "tradition" "everywhere" or "gives you full control" - especially that, since it brought us countless security issues

Re: Ask HN: Learn C in 2023?

#45

Earlier quoted context omitted.

> 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…

> My point is that they can’t consistently write correct software in any language. Javascript for example

I don’t think Javascript is the counterexample you want to use as a good language. It is like C where safety is traded for flexibility.

If people can’t write correct software in any language, the language designers can help, which is exactly what the Rust designers did.

It’s not great for everyone because now all the scar tissue that great C devs have around what near-fatal errors they’ve made previously has lost some of its value.

Re: Ask HN: Learn C in 2023?

#46
How in the world in this day and age of nearly infinite resources to learn ANYTHING on the internet is this a question that gets voted up to the top of HN?

Here's an idea: pick a project that interests you and start. For any question or issue you run into, there will be 1000 Youtube videos to choose from, and 10000 online tutorials. There will be an associated sub reddit to ask questions.

Re: Ask HN: Learn C in 2023?

#49

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 prog…

I’m also a traditionalist and I think the classic K&R C Programming Language book is the best way to learn C—you also get an understanding why C and *nix-based systems seem to go so well.

I love books, even if I don't finish them, especially the technical ones. Today we're very used to recommend sites and youtube videos as primers for learning. In some situations that is ok but I wouldn't hesitate for even a second if I have to choose been something online or a book.

Re: Ask HN: Learn C in 2023?

#50
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…

What is your opinion on K&R?
Post reply on HN