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

Programmer Humor

32558 readers
624 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
[–] force@lemmy.world 21 points 1 year ago* (last edited 1 year ago) (2 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

[–] stingpie@lemmy.world 4 points 1 year 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.

[–] aidan@lemmy.world 2 points 1 year 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.

[–] Amends1782@lemmy.ca 1 points 1 year ago