r/ProgrammerHumor • • 17h ago

Meme checkBuildSettings

Post image
2.9k Upvotes

67 comments sorted by

View all comments

Show parent comment

15

u/ThaBroccoliDood 13h ago

NGL Rust gets it right on this one. Unused variables or unnecessary mutability, sure, give a warning. But anything else really ought to be an error. C/C++ are way too lenient on what you can ignore when it knows it’s wrong

2

u/beyluta 4h ago

Clang-Tidy rules for C and C++ can help with some of these headaches. But the setup is tedious and some flags only work on C++ but not on C or vice versa (for some unknown reason).

3

u/TiF4H3- 9h ago edited 5h ago

And even better, it's entierly customizable using directives within the code itself!
It evencan be set for the whole project, or for a specific module.

If you are still prototyping, you can add a little

#![allow(unused)]

and change it into a deny/forbid on the production build.

On the other end, a

#![forbid(unsafe)]

is a wonderful guarantee for your codebase.

There also a lot of very specific lints you can turn on, relating to endianness, and a bunch of more domain-specific things.

Quick edit:

More specifically, there's the whole restriction lint group, which is allow per default.

It has a lot of things related to enforcing some uncommon coding guidelines (like no else if without an else).

And there's also the whole pedantic lint group, also allow per default.

It's instead lints that are technically good, but more among the realm of micro optimizations and pedantic bullshit than the realm of actually important errors (like using an unstable sort to sort primitives, as it's slightly faster than a stable one).
But they can be very useful in contexts where these actually matter.

3

u/PrincessRTFM 5h ago

point of detail: it's #![...] not !#[...]

also, inline code doesn't get syntax highlighting so the leading rs for the language just gets rendered directly

2

u/TiF4H3- 5h ago

Thanks!

I always mess up the #! and never remember which is correct, lol.

2

u/pint_o_paint 7h ago

I hate that for a second I suspected your post to be an AI-copypasta; only because at first glance I saw proper formatting and an upbeat/enthusiastic intro ("And even better, it's entierly customizable[...]!").

I love proper formatting and enthusiastic posts, darn it.

-2

u/tiajuanat 8h ago

Rust has some really cool lints, and if you're working with agents you may as well activate all of them