Remix.run Logo
▲ uecker 19 hours ago

Any tutorial for C should explain compiler warnings and other tools that help make code safer. In C, you do not rely on the language specification but on tooling. Especially for Rust programmers, this needs to be explained more explicitly. And of course, you can build abstractions using types in C. So a tutorial should also focus on that, and perhaps not start with a low-level string reversal function.

▲swinglock 17 hours ago | parent | next [-]

Absolutely. Turn the warnings into errors too, build and test with sanitizers (ASAN, UBSAN, TSAN) when not measuring performance, and use static analysis beyond compiler warnings (Clang Tidy, Clang Static Analyzer).

Though the author doesn't look to be trying to write a great tutorial, rather prioritizing sharing what and how they learned something from their perspective.

▲tialaramex 16 hours ago | parent | next [-]

> Turn the warnings into errors too,

Please stop smashing all the nuance out of compiler diagnostics this way.

One of the biggest successes of Rust has been its great diagnostics and I can assure you that it would not help to smash my Clippy lint suggesting that what I wrote looks a lot like an implementation of the addition operator† into a fatal error like the one I get for forgetting to initialize a variable.

Rust even has a (begins empty) diagnostic category [named "expect"] for "This warning should be here" which will flag cases where a notable thing not only might happen here and if it does we can ignore that, but if it's no longer detected that is itself suspicious and should be diagnosed.

† Yes it does Clippy, and I considered implementing Add but I had a good reason not to, so here is a suppression annotation.

▲cohani 17 hours ago | parent | prev [-]

Maybe the author was given monetary support from the Rust Foundation, they have given money to people to write blog posts https://rustfoundation.org/media/introducing-our-newest-proj... . They love media instead of technical work.

▲deknos 7 minutes ago | parent | prev | next [-]

build one. i would verify gladyly

▲bjackman 18 hours ago | parent | prev | next [-]

> This is not a substitute for a proper C tutorial

▲kingforaday 18 hours ago | parent | prev | next [-]

I'm with you. Since the post already shows Clang catching the array-decay bug, the author could even just add a “always build with -Wall -Wextra -fsanitize=address,undefined” note and some explanation of course.

▲rramadass 4 hours ago | parent [-]

https://news.ycombinator.com/item?id=50016878

▲gerdesj 8 hours ago | parent | prev | next [-]

A Rust programmer, programming in C is a C programmer!

Tribalism is sooo ... sadly now.

Please don't.

▲jminnl 17 hours ago | parent | prev [-]

Asan!