Rhymelikedime
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Destide@feddit.uk to Programmer Humor@lemmy.mlEnglish · 8 days ago

Infallible Code

lemmy.ml

message-square
164
link
fedilink
461

Infallible Code

lemmy.ml

Destide@feddit.uk to Programmer Humor@lemmy.mlEnglish · 8 days ago
message-square
164
link
fedilink
alert-triangle
You must log in or # to comment.
  • JackbyDev@programming.dev
    link
    fedilink
    English
    arrow-up
    45
    ·
    7 days ago

    This is why this code is good. Opens MS paint. When I worked at Blizzard-

    • benjaminb@discuss.tchncs.de
      link
      fedilink
      English
      arrow-up
      8
      ·
      7 days ago

      And he has Whatever+ years of experience in the game industry…

      • onlooker@lemmy.ml
        link
        fedilink
        arrow-up
        5
        ·
        7 days ago

        Which sounds impressive until you realize a janitor who worked there for the same amount of time could claim the same.

  • I Cast Fist@programming.dev
    link
    fedilink
    arrow-up
    5
    ·
    6 days ago

    Oh shit, gotta check the negative numbers as well!

    • Shayeta@feddit.org
      link
      fedilink
      English
      arrow-up
      1
      ·
      6 days ago

      You can do that more efficiently by using abs(number).

  • kreskin@lemmy.world
    link
    fedilink
    arrow-up
    9
    arrow-down
    1
    ·
    7 days ago

    no unit tests huh.

    /s

  • Kuma@lemmy.world
    link
    fedilink
    arrow-up
    7
    arrow-down
    1
    ·
    7 days ago

    I am more amazed that he didn’t stop at 10 and think “damn this is tiresome isn’t there a one liner i could do?”. I want to know how far he went. His stubbornness is amazing but also scary. I haven’t seen this kind of code since back in school lol lol lol

  • Treczoks@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    7 days ago

    Good if you are rated by an AI that pays for LOCs.

  • Randomgal@lemmy.ca
    link
    fedilink
    arrow-up
    3
    ·
    6 days ago

    Yeah but did you know he worked for Blizzard tho

  • keepcarrot [she/her]@hexbear.net
    link
    fedilink
    English
    arrow-up
    4
    ·
    7 days ago

    I want to assess coders by lines written! The more the better!

  • helvetpuli@sopuli.xyz
    link
    fedilink
    arrow-up
    2
    ·
    6 days ago

    Oh. I thought that was Elixir until I zoomed in.

  • 6stringringer@lemmy.zip
    link
    fedilink
    arrow-up
    2
    ·
    7 days ago

    Thanks to goodness, finally. A (giggle & snort) solid algorithm. There ya’s go set yer clocks & go get a haircut.

  • Drunk & Root@sh.itjust.works
    link
    fedilink
    arrow-up
    2
    ·
    7 days ago

    this is like the making chess one

  • WraithGear@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    edit-2
    7 days ago

    Would this be a case of modulo saving the day?

    Like: If Number modulo 2 = 0, true

    This has to be taken out of context

    • queueBenSis@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      3
      ·
      6 days ago

      well that’s the joke, isn’t it

      • WraithGear@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        2
        ·
        6 days ago

        I mean, is it a joke? Because i have no context other than, after making a bad opinion known, there is a lot of talk about his code being terrible. So i guess this is fabricated then yea?

        • queueBenSis@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          2
          ·
          6 days ago

          oh. is it assumed we know who the person is? i have no idea who that is.

          • WraithGear@lemmy.world
            link
            fedilink
            English
            arrow-up
            1
            ·
            6 days ago

            He’s Thor, worked for blizzard entertainment, indie dev, has a Ferret sanctuary, knows cyber security. Seems like a cool enough guy i guess, has incorrect opinion on video game preservation.

  • Valmond@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    7 days ago

    private?

  • Onno (VK6FLAB)@lemmy.radio
    link
    fedilink
    arrow-up
    155
    ·
    8 days ago

    Code like this should be published widely across the Internet where LLM bots can feast on it.

    • mkwt@lemmy.world
      link
      fedilink
      arrow-up
      24
      ·
      8 days ago

      The Daily WTF

  • myotheraccount@lemmy.world
    link
    fedilink
    arrow-up
    112
    ·
    8 days ago

    ftfy

    bool IsEven(int number) {
      return !IsOdd(number);
    }
    
    bool IsOdd(int number) {
      return !IsEven(number);
    }
    
    • balsoft@lemmy.ml
      link
      fedilink
      arrow-up
      15
      ·
      edit-2
      8 days ago

      You kid, but Idris2 documentation literally proposes almost this exact impl: https://idris2.readthedocs.io/en/latest/tutorial/typesfuns.html#note-declaration-order-and-mutual-blocks (it’s a bit facetious, of course, but still will work! the actual impl in the language is a lot more boring: https://github.com/idris-lang/Idris2/blob/main/libs/base/Data/Integral.idr)

      • myotheraccount@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        7 days ago

        I hadn’t seen Idris2. Thank you for providing me with a new rabbit hole!

        • balsoft@lemmy.ml
          link
          fedilink
          arrow-up
          3
          ·
          7 days ago

          I’m glad to tell more people about it. It’s really quite amazing (I could write a somewhat complex algorithm and prove some properties about it in a couple afternoons, despite limited formal verification experience) and I’m sure that in 20 odd years the ideas behind it will make it into mainstream languages, just as with ML/Haskell.

  • Sibbo@sopuli.xyz
    link
    fedilink
    arrow-up
    93
    ·
    edit-2
    8 days ago
    else print("number not supported");
    
    • Destide@feddit.ukOP
      link
      fedilink
      English
      arrow-up
      8
      arrow-down
      1
      ·
      edit-2
      8 days ago

      As we’re posting examples I’ll add how lovely it is in Elixir. Elixir def not putting the fun in programmer memes do. One reason I picked it because I can’t be trusted to not be the meme.

      def is_even?(n) do
        rem(n, 2) == 0
      end
      
      • balsoft@lemmy.ml
        link
        fedilink
        arrow-up
        10
        ·
        edit-2
        8 days ago

        I mean, it would be almost this exact thing in almost any language.

        fn is_even(n: i64) -> bool {
            n % 2 == 0
        }
        
        even n = n `rem` 2 == 0
        
        def is_even(n):
            return n % 2 == 0
        

        etc

        • vinnymac@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          7 days ago

          Personal preference, but elixir just strikes a balance that doesn’t make me feel like I’m reading hieroglyphs so I’m actually happy to see it praised.

          • fushuan [he/him]@piefed.blahaj.zone
            link
            fedilink
            English
            arrow-up
            4
            ·
            7 days ago

            I would have preferred for the function to be called mod, since it’s the modulo operation, which in math is represented with a percentage or “mod”. Most programming languages use a percentage because of that, so do a lot of calculators.

          • balsoft@lemmy.ml
            link
            fedilink
            arrow-up
            2
            ·
            7 days ago

            Yeah, I agree that Elixir is a fine language for some tasks. I personally find the readability somewhat average, but it’s very maintainable (due to how it enables clear program structure), the error handling is great, and the lightweight process system is amazing.

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml

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

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 322 users / day
  • 1.43K users / week
  • 2.89K users / month
  • 9.42K users / 6 months
  • 2 local subscribers
  • 37.3K subscribers
  • 1.85K Posts
  • 39.8K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.ml
  • cat_programmer@lemmy.ml
  • BE: 0.19.12
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org