• force@lemmy.world
    link
    fedilink
    English
    arrow-up
    26
    arrow-down
    5
    ·
    edit-2
    1 year ago

    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

    • Cihta@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      1 year ago

      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!

      • force@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        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 }
        
        • Cihta@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          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?

          • force@lemmy.world
            link
            fedilink
            arrow-up
            3
            ·
            edit-2
            1 year ago

            If the last part is referring to programming in Rust vs something else (I’m not sure if it is):

            A lot of things call for code that is either easily maintainable, high-performance, safe, etc. which e.g. Python isn’t going to be good for any of.

            Sure, you can write demanding graphics stuff (like games) in Python or something, but it’s gonna suck – and there’s a reason most big game developers use C++ (often with Unreal) rather than Unity, Godot, or the stuff Java has (looking at Tarkov which is extremely performant for a large Unity game, it still has awful performance just from the fact that it’s a C# project). That’s the entire idea of why Minecraft Bedrock was created anyways, because very high level languages like Java are bad for performance.

            There’s also a reason nobody uses Python or Java for embedded or systems, sure you can do it and there are a few tools out there for it but just… why?

            Also I find Rust no less fast to work in than Java or C#. It almost forces you to write better code just by nature of how the language is designed, so you spend far less time debugging or fixing fuck-ups. Learning Rust can also teach you to write better code in other languages (namely C++).

            • Cihta@lemmy.world
              link
              fedilink
              arrow-up
              2
              ·
              1 year ago

              No no no you misunderstood me.

              I was being honest, I know nothing of rust. I have however used python in embedded systems with positive results. The product didn’t make it but for other reasons.

              Funny you mention java, that’s sorta what I’m stuck in but not like you think. Beyond the fact that it’s a bloated nightmare.

              I’m just a low-level programmer at heart but I have bills to pay. The rust stuff was all just a joke… i don’t know it but maybe i should. Thanks for the info.

              Saying anymore about what I do is just super embarrassing but i promise i meant no ill will. Excuse my frustration, I’m locked into a proprietary system i have no control over. You would laugh your ass off if you saw it. Anyway, i meant no offense, have a good night!

    • stingpie@lemmy.world
      link
      fedilink
      arrow-up
      6
      arrow-down
      3
      ·
      1 year ago

      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
        link
        fedilink
        arrow-up
        2
        ·
        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.