Elektrine lite

← Feed

@Hyperlynx@aus.social

Post #2456453

2026-04-22 03:09 UTC

@joxean@mastodon.social yes, absolutely! We tend to do it at work, and I'm a big proponent of it. The main reason is that it makes your intent clearer, which makes your code easier to read and understand (especially the first time I see it, in review). When I see `const`, I can immediately eliminate a bunch of possibilities in my mental "what does this code do?" tree. I never have to worry about figuring out what x is going to be assigned or modified. Secondary reason is that it prevents you or others from modifying it accidentally. Mistakes happen, even to the best of us, and if you can completely eliminate a certain class of them for free, why not?

Replies (1)

  • @Hyperlynx@aus.social 2026-04-22 03:14

    @joxean@mastodon.social but, also, are you not using constants in general? That's really bad practice to sprinkle your code with "magic numbers" rather than using constants. It's A: harder to read, and B: a maintenance pain in the backside if the value ever needs to be changed. Unless you're talking about const vs constexpr, in which case I don't think it makes much practical difference.

    Open ##2456454