515
you are viewing a single comment's thread
view the rest of the comments
[-] 30p87@feddit.org 26 points 3 months ago

Almost any language is OK, but Rust is just so, so fucking ugly

[-] Sunrosa@lemmy.world 11 points 3 months ago

One of the reasons i find it so hard to use non-Rust languages is how ugly they typically are by comparison. "fn" instead of "function" is such a great example of saving key presses where they're most needed. And you get very used to seeing compact abbreviations. Idk if that's what you're talking about though.

[-] 30p87@feddit.org 7 points 3 months ago

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 5 points 3 months ago* (last edited 3 months 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
[-] cryoistalline@lemmy.ml 4 points 3 months ago

types in C are pretty weird

int *a can be read as

  1. *a is a int
  2. since dereferencing is a operator on pointers, a is a pointer to int

int *a, b is read as

  1. *a and b are int
  2. so a is a pointer to int and b is a int

bool getofmylawn(Lawn lawn)

  1. getoffmylawn(Lawn lawn) is a bool
  2. since calling is done on functions, getoffmylawn is a function that takes a Lawn and returns a bool

And then you have function pointers

bool (*foo(int a))(float b)

  1. (*foo(int a))(float b) is a bool
  2. *foo(int a) is a function from float to bool
  3. foo(int a) is a function pointer from float to bool
  4. foo is a function that takes a int and returns a function pointer from float to bool

really weird in my opinion.

[-] fruitcantfly@programming.dev 4 points 3 months ago

C++ is even worse, due to templates and the so-called most vexing parse. Initializing with {} mitigated the latter somewhat, but came with its own set of woes

load more comments (11 replies)
load more comments (16 replies)
load more comments (131 replies)
this post was submitted on 17 Dec 2025
515 points (95.9% liked)

Programmer Humor

30761 readers
1289 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