coja@lemmy.ml to Programmer Humor@lemmy.ml · 11 months agoFind yourselflemmy.mlimagemessage-square128fedilinkarrow-up1611
arrow-up1611imageFind yourselflemmy.mlcoja@lemmy.ml to Programmer Humor@lemmy.ml · 11 months agomessage-square128fedilink
minus-squareforce@lemmy.worldlinkfedilinkEnglisharrow-up20·edit-211 months agowtf 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
minus-squareCihta@lemmy.worldlinkfedilinkarrow-up3·11 months agoWow 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!
minus-squareforce@lemmy.worldlinkfedilinkarrow-up1·11 months agolol that’s not actually how rust is written, it was just a joke it’d really be written if x > y { x } else { y }
minus-squarestingpie@lemmy.worldlinkfedilinkarrow-up3·11 months agoAh yes, rust. The language that somehow manages to manages to as verbose as possible, with as much jargonized shorthand that a computer could handle.
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
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!
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 }
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.
deleted by creator
Isn’t it php?