Live data from Hacker News

Ask HN: Learn C in 2023?

news.ycombinator.com

21–30 of 220 posts

Re: Ask HN: Learn C in 2023?

#21

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.

"GNU C" has a number of features that make the language far more pleasant if you're willing to give up the portability and use them. A big one if you've been using modern languages is anonymous functions.

Re: Ask HN: Learn C in 2023?

#22
post #12

The C programming language book.

Just like C, there is a stark beauty to the original K&R C Programming Language book. And there's an admirable clarity in the writing that has set the standard for all language manuals that have followed. It is, indeed, a terrific read. As long as you're not trying to learn C.

It's really out of date. It doesn't cover subsequent C standards; and it doesn't cover any of the best practices that have subsequently evolved to protect us from the things in C that are deeply awful (in retrospect) in the original. Or any of the evolved practical lore for writing good, portable, safe C code.

Re: Ask HN: Learn C in 2023?

#23
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 0Some 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 automatic memory management and package management and again I'm not convinced these really improve much. The pain of allocating memory in C means people often find ways to avoid doing it altogether which results in much more predictable behavior. Same with pulling in third party libraries. It's rare using more than a couple is actually beneficial but when the package manager is there the temptation is way too much for most people and the result is both unpleasant and very vulnerable to supply chain attacks.

I'm still not convinced any of this is the improvement people think it is.

Re: Ask HN: Learn C in 2023?

#24

Write a CHIP-8 emulator in C! In my opinion it’s a perfect project because: - it is a good size. You can be done in 10-20 hours, or longer if that’s your pace (have fun!) - a lot of examples and community support. - you have a whole project without any overwhelming complexities: you’re just taking inputs, reading some data, running it through a switch statement, writing data, writing to a screen, then repeating. - yo…

“can be done in a weekend”

RIP me who has spent 3 weeks on this

Great project for sure though!

Re: Ask HN: Learn C in 2023?

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

#c on libera is a genuinely helpful place full of neckbeards.

Re: Ask HN: Learn C in 2023?

#28

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 you everything you could want?

Re: Ask HN: Learn C in 2023?

#29

Write a CHIP-8 emulator in C! In my opinion it’s a perfect project because: - it is a good size. You can be done in 10-20 hours, or longer if that’s your pace (have fun!) - a lot of examples and community support. - you have a whole project without any overwhelming complexities: you’re just taking inputs, reading some data, running it through a switch statement, writing data, writing to a screen, then repeating. - yo…

“can be done in a weekend” RIP me who has spent 3 weeks on this Great project for sure though!

haha I guess a “weekend” is a fuzzy unit of measure. I’ll amend.

Re: Ask HN: Learn C in 2023?

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

> the invariants you have to keep track of are relatively simple (things like 0If 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 complex invariants to keep track of and similar consequences for failing to do so.

This take reflects a profound ignorance of the relative severity of different kinds of software defect.

When you get an array bound wrong in Java or Rust, you get an exception or a panic. Your program exits and restarts. You get a ticket for fixing the bug. Life goes on.

When you get an array bound wrong in C, you open the door for a nefarious actor to gain control over everything that your program can access.

These aren't similar consequences. They're not even on the same planet of consequences. C apologists are like apologists for asbestos and lead paint.

Post reply on HN