this post was submitted on 17 Dec 2025
464 points (96.0% liked)

Programmer Humor

27933 readers
603 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] 30p87@feddit.org 5 points 1 day ago (3 children)

Rust:

fn getofmylawn(lawn: Lawn) -> bool {
    lawn.remove()
}

C:

bool getofmylawn(Lawn lawn) {
    return lawn.remove();
}

With Rust you safe 1 char, and gain needing to skip a whole line to see what type something is.

[–] fruitcantfly@programming.dev 4 points 1 day ago* (last edited 1 day ago)

With Rust you safe 1 char, and gain needing to skip a whole line to see what type something is.

Honestly, the Rust way of doing things feels much more natural to me.

You can read it as

  1. Define a function,
  2. with the name getoffmylawn,
  3. that takes a Lawn argument named lawn,
  4. and returns a bool

Whereas the C function is read as

  1. Do something with a bool? Could be a variable, could be a function, could be a forward declaration of a function,
  2. whatever it is, it has the name getoffmylawn,
  3. there's a (, so all options are still on the table,
  4. ok, that' a function, since it takes a Lawn argument named lawn, that returns a bool
[–] Sunrosa@lemmy.world 1 points 1 day ago (1 children)

"fn" was just one example. There's also other abbreviations like "pub", "impl", "extern", "mut", "ref", "bool", "u64" And it's true that some of these keywords are only relevant in Rust, however other langues have their own specific keywords, and they tend to be longer. In languages like Java (which is the worst example I can think of), you see things like "private static boolean" as function definition. In c++, you have to type "unsigned long" or even "unsigned long long" to represent "u64" (depending on data model).

[–] ChaosMonkey@lemmy.dbzer0.com 1 points 20 hours ago

To be fair, in C/C++ you can include stdint.h which defines type aliases such as uint64_t.

[–] chunes@lemmy.world 4 points 1 day ago

So that's why people like C-style return types. That actually makes a lot of sense. I do too now.