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

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

[-] asdfasdfasdf@lemmy.world 52 points 8 months ago

Hard disagree. Super beautiful.

[-] 30p87@feddit.org 14 points 8 months ago

Average Rust code:

macro_rules! sum {
    ( $initial:expr $(, $expr:expr )* $(,)? ) => {
        $initial $(+ $expr)*
    }
}

fn remove_prefix<'a>(mut original: &'a str, prefix: &str) -> &'a str

let mut up = 1;
    'outer: loop {

Hell I don't want to know what you define as ugly then.

[-] asdfasdfasdf@lemmy.world 26 points 8 months ago* (last edited 8 months ago)
  1. Macro syntax technically isn't even Rust
  2. This is definitely not average Rust code.
load more comments (6 replies)
[-] flamingo_pinyata@sopuli.xyz 19 points 8 months ago

I don't know if anyone would argue Rust macros are beautiful. If someone does they should be checked out by a doctor.
Speaking as a fan of Rust.

Definitely not your average Rust code, more like a very ugly example of it.

Also, as the syntax first put me off as well, I gave it a chance years afterwards, and have now (or rather years ago) officially joined the church of Rust evangelism.

A lot of the syntax you define as ugly makes sense when you learn it, it's just so much more explicit than a more dynamic language, but that exactly saves your ass a lot (it did for me at the very least) (I don't mean macros, macros are ugly and should be avoided if possible)

load more comments (1 replies)
[-] firelizzard@programming.dev 47 points 8 months ago

Almost any language is ok but some ecosystems make me want to turn into a murder hobo (looking at you, JavaScript).

load more comments (5 replies)
[-] asudox@lemmy.asudox.dev 34 points 8 months ago

what? what part of rust is ugly?

[-] UnderpantsWeevil@lemmy.world 25 points 8 months ago

Maybe they're confusing the literal name with the language? Idk.

I grew up on Perl and holy fuck... Rust is fine.

[-] hellfire103@lemmy.ca 7 points 8 months ago

I'm learning Perl - purely for fun - and yeah... it's a little funky.

load more comments (3 replies)
[-] rtxn@lemmy.world 16 points 8 months ago* (last edited 8 months ago)

Enums and nested blocks. I understand the importance of Option and Result, but it's fucking infuriating when I have to check and destructure the result of every function call and either bubble the result up the stack from six levels of nested if let blocks or risk Cloudflaring my program by using .unwrap(). And while I like being able to extract a return value from an if...else expression, the structure gets really convoluted when multiple if and match blocks are nested (of course each one returning a value), and it gets completely fucked once closures are introduced.

I like Rust, but calling it pretty is delusional.

[-] marcos@lemmy.world 22 points 8 months ago

have to check and destructure the result of every function call

Learn how to use enum error types, how error bubbling works, and how to convert between Options and Results.

It's Rust you are talking about, not Go.

load more comments (4 replies)
[-] roanutil_@programming.dev 20 points 8 months ago

Sum types with associated values are worth it

[-] SorryQuick@lemmy.ca 8 points 8 months ago* (last edited 8 months ago)

You can also use let else.

let (Some(count\_str), Some(item)) = (it.next(), it.next()) else {
    panic!("Can't segment count item pair: '{s}'");
};

But really it’s the exact same as other languages, it just forces you to handle it better. C-based languages will return 0/null/-1 and you’ll have to check all 3 of those because they might not mean the same thing. How is that better?

[-] magic_lobster_party@fedia.io 7 points 8 months ago

I like to use unwrap_or() to define fallback values. The Option API is quite expressive.

[-] eager_eagle@lemmy.world 7 points 8 months ago

Cloudflaring my program

I'll start using this one

[-] tatterdemalion@programming.dev 6 points 8 months ago

Enums are the best part of the Rust language IMO, so I'm not sure how you can view them as ugly. Having the choice to destructure something is fantastic. You generally aren't required to destructure every return value. Make sure you're using the ? operator as much as possible. If destructuring is getting in your way, it sounds like the code is not very idiomatic.

I can't really comment on your issue with nested if and match. Too much nesting is bad in any language; try extracting more functions and let bindings to make it more readable.

You can enable a clippy lint to deny .unwrap() if you're worried about it.

[-] 30p87@feddit.org 13 points 8 months ago

Literally every single bit of the syntax.

[-] Kacarott@aussie.zone 12 points 8 months ago

The majority of its syntax is very similar to many other languages. Can you give an example of a language with pretty syntax?

load more comments (2 replies)
load more comments (17 replies)
load more comments (2 replies)
[-] Lembot_0006@programming.dev 23 points 8 months ago

FORTRAN isn't a beauty either.
And Python is strange as hell with its mandatory tabs.

[-] bleistift2@sopuli.xyz 23 points 8 months ago

You can use spaces in Python.

[-] marduk@lemmy.sdf.org 20 points 8 months ago

Two, three or four spaces? If you answer wrong I'll never forgive you

[-] fartsparkles@lemmy.world 6 points 8 months ago

I’m rather partial to five myself but only when I’m feeling fancy.

load more comments (4 replies)
[-] firelizzard@programming.dev 16 points 8 months ago

Indentation-driven control flow is one of the most cursed things ever invented, excluding things explicitly designed to inflict pain or death.

[-] CompactFlax@discuss.tchncs.de 9 points 8 months ago

White space sensitive languages are evil.

load more comments (1 replies)
[-] tyler@programming.dev 14 points 8 months ago

List comprehensions are much stranger than tabs vs spaces. There are very very very few languages that use them, and python’s is by far the worst out of the popular ones.

[-] SaharaMaleikuhm@feddit.org 7 points 8 months ago

Skill issue. Once you learn them they are quite fun.

[-] unit327@lemmy.zip 8 points 8 months ago

The concept of a list comprehenshion is sinple but syntax is awful, as if Yoda was writing a for loop. "x for x in y it is, hmm yes".

load more comments (1 replies)
load more comments (6 replies)
[-] BehindTheBarrier@programming.dev 19 points 8 months ago

I can actually see where this is coming from, as I found Rust hard to read when I started out. I do really like Rust for reference, but I do agree Rust is hard to read for someone that has not learned it.

For example:

return statements that are implicit just because the semicolon isn't there. Even better if they occur inside a if block or something like that. Very hard to understanding when you don't know the syntax rules.

Lambda functions, especially when using move semantics too. They are quite simple, but if you don't know the meaning, it's more arcane characters. Especially when this is used inside lots of chained methods, and maybe a multi-line function in the lambda.

A lot for the if let x =... type of stataments are tough the first time around. Same for match statements.

Defining types for use with function::() and such.

Lifetimes, especially when they are all named a, b, c etc. It quickly gets messy, especially when combined with generics or explicitly defined types.

Macros, though not entry level rust to begin with, they are really cumbersome to decode.

None of these are sins of Rust, but for new people they are a hill to climb, and often hard to just "get" based on previous programming experience and reading the code. Rust can be really hard to approach because of these things. This happens in other languages too, but I do feel Rust has a particularly large amount of new concepts or ways to do something. And this is on top of learning lifetimes and borrow semantics.

[-] 5C5C5C@programming.dev 12 points 8 months ago

This is the most sober take in this thread. I was bothered by all these things you mentioned for the first two weeks of using the language. I begrudgingly accepted them for the following two months because I felt the benefits of the language were worth it. Now all of these things feel natural and I don't give them a second thought.

load more comments (5 replies)
[-] Sunrosa@lemmy.world 12 points 8 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 10 points 8 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.

load more comments (12 replies)
load more comments (4 replies)
[-] LiveLM@lemmy.zip 10 points 8 months ago

Go look at that Lisp kojumbo then tell me Rust is ugly.

(defmethod wake ((object magic-packet) address port)
  (let* ((payload (encode-payload object))
         (size (length payload))
         (socket (usocket:socket-connect nil nil :protocol :datagram :element-type '(unsigned-byte 8))))
    (setf (usocket:socket-option socket :broadcast) t)
    (usocket:socket-send socket payload size :host address :port port)
    (usocket:socket-close socket)))

Actually unreadable.

load more comments (9 replies)
[-] tomenzgg@midwest.social 6 points 8 months ago

Not to stereotype too much but I think this is the first Blåhaj I've seen (in a programming context) that wasn't team Rust.

What your programming language of choice (if you don't mind sharing)?

load more comments (5 replies)
load more comments (1 replies)
this post was submitted on 17 Dec 2025
515 points (100.0% liked)

Programmer Humor

32950 readers
1251 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 3 years ago
MODERATORS