this post was submitted on 22 Oct 2023
600 points (95.6% liked)

Programmer Humor

31800 readers
212 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 21 points 10 months ago* (last edited 10 months ago) (4 children)

wtf kind of cursed programming language is this? JS? it's so ugly, in no universe should a function look like that

but obviously as a rust enjoyer i have to do it like

fn max ⟨T: PartialOrd + Copy⟩(nums: ⁊[T]) -> Option⟨T⟩ {
    let mut greatest: ⁊T = ⁊nums[0];
    match nums.len() {
        0 => None,
        1 => Some(*greatest),
        _ => {
            for num in nums {
                if num > greatest {
                    greatest = num;
                }
            }
            Some(*greatest)
        }
    }
}

edit: lemmy formatting REALLY hates references and generics it seems... time to go back to medieval times

[–] [email protected] 4 points 10 months ago (1 children)

Ah yes, rust. The language that somehow manages to manages to as verbose as possible, with as much jargonized shorthand that a computer could handle.

[–] [email protected] 2 points 10 months ago

Exactly, I don't understand why languages have decided that every keyword needs to be as randomly minified as possible. fn, def, rune(ok that's not minified, just a dumb name), fmt, std. Many of these things aren't new, but programmers recognize descriptive variable names are important, the same should be true for keywords.

[–] [email protected] 4 points 10 months ago (1 children)

Wow that's a very exhausting language. I dropped your code into an online rust to asm converter and it actually wasn't more! I did try to post it for fun but lemmy kept messing up the code block. Oh well, wasn't that amusing anyway!

[–] [email protected] 4 points 10 months ago (1 children)

lol that's not actually how rust is written, it was just a joke

it'd really be written

if x > y { x } else { y }
[–] [email protected] 1 points 10 months ago (1 children)

Hah thanks for clarifying. I was joking too and it's a shame I couldn't post the results.

Though I admit i don't know anything about rust. I'm sure I'd like it better than the proprietary garbage i use now that just gets converted to ASM / PLC code in the end. But I can't skip the middle man. I'm not gonna try but probably 30mins for me to "write" the above.

Besides, how do you make money if I can code something in an hour as opposed to 2 days?

[–] [email protected] 1 points 10 months ago