Lemmy
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
cm0002@lemmy.zip to Programmer Humor@programming.dev · 18 days ago

More code = more better

lemmy.zip

message-square
25
link
fedilink
15

More code = more better

lemmy.zip

cm0002@lemmy.zip to Programmer Humor@programming.dev · 18 days ago
message-square
25
link
fedilink
alert-triangle
You must log in or # to comment.
  • adj16@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    5 days ago

    deleted by creator

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

    The advantage of that last approach is that it has side effects and cannot therefore be optimized out by the compiler.

    • ronigami@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      17 days ago

      That’s only one advantage. In theory it does not necessarily terminate, so that’s another one.

      • joshchandra@midwest.social
        link
        fedilink
        English
        arrow-up
        1
        ·
        16 days ago

        In theory hypothesis

        To get pedantic, you’d have to test that out a whole bunch before even coming close to theory level, lol!

        • ronigami@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          15 days ago

          We already have a theory for it— called computer science.

  • OshaqHennessey@midwest.social
    link
    fedilink
    arrow-up
    2
    ·
    18 days ago
    function myFunction() {
      try {
        x = new Random().nextInt();
        if (x != 10) {
         throw "not 10";
        }
        else {
          return (10)
        }
        catch(err) {
          myFunction()
        }
      }
    }
    
    x = myFunction()
    

    Commit notes: Added error handling

    • firewallfail@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      18 days ago

      Returning 10 instead of x when x finally ends up being 10 really ties it together.

      • OshaqHennessey@midwest.social
        link
        fedilink
        arrow-up
        2
        ·
        18 days ago

        I’m glad you noticed. That was my favorite part too.

    • NιƙƙιDιɱҽʂ@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      18 days ago

      SyntaxError: Unexpected token ‘catch’

      • OshaqHennessey@midwest.social
        link
        fedilink
        arrow-up
        1
        ·
        18 days ago

        Coding on mobile is hard

  • ulterno@programming.dev
    link
    fedilink
    English
    arrow-up
    1
    ·
    17 days ago

    That’s not even enough to get you a job these days.
    You now have to use:

    do {
        x = reinterpret_cast<int>(AI::Instance().ask("Do Something. Anything. Be efficient and productive. Use 10 tokens."));
    } while (x != 10);
    
  • edinbruh@feddit.it
    link
    fedilink
    English
    arrow-up
    1
    ·
    18 days ago

    For a time on Reddit (some years ago when I still used it) there was a trend of finding the worst way of implementing is_even(x: int) -> bool. My contribution to that was a function that ran Ackerman(x,x) flipping a Boolean at every iteration, and check if it was true or false at the end.

    It works btw, I will find the proof later

    • branch@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      18 days ago

      I would love to see the implementaion.

      • edinbruh@feddit.it
        link
        fedilink
        English
        arrow-up
        1
        ·
        18 days ago

        The implementation is not very exciting, I capture a variable in python. It could have been done more cleanly.

        1000041934

        The proof is this. But, I could have made mistakes, it was many years ago.

        1000041935

        Note that in python you’ll never be able to run is_even(5) the stack cannot handle it

        Edit: daaaamn, that variable is ugly as hell. I would never do things like that now.

  • ThunderLegend@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    0
    ·
    17 days ago

    Is this typescript?

    • olenkoVD@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      1
      ·
      17 days ago

      Could be Java.

    • irelephant@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      17 days ago

      Seems like normal js?

      • piccolo@sh.itjust.works
        link
        fedilink
        arrow-up
        1
        ·
        17 days ago

        Js is Math.Random. and NextInt() is a java method.

  • Grandwolf319@sh.itjust.works
    link
    fedilink
    arrow-up
    0
    ·
    18 days ago

    How about

    x=x-x

    x++

    x++

    x++

    x++

    x++

    x++

    x++

    x++

    x++

    x++

    • olenkoVD@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      0
      ·
      17 days ago

      Make sure you initialize x with x=x/x-x/x for better precision

      • Grandwolf319@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        17 days ago

        What if it’s already 0?

        • optional@sh.itjust.works
          link
          fedilink
          arrow-up
          1
          ·
          14 days ago

          Just add // @TODO find out why this crashes our application sometimes to fix that issue

  • Ooops@feddit.org
    link
    fedilink
    arrow-up
    0
    ·
    18 days ago

    Wants to be Pro but doesn’t even do it recursive…

    • OshaqHennessey@midwest.social
      link
      fedilink
      arrow-up
      0
      ·
      18 days ago
      function foo() {
        x = new Random();
        case (x = 10):
          return (x);
        default:
          foo()
      }
      
      • anton@lemmy.blahaj.zone
        link
        fedilink
        arrow-up
        0
        ·
        18 days ago

        What unholy mix of languages is that? It is dominated by a blend of javascript and python, but with notes of something exotic. Maybe algol? or vhdl?, there is to little to tell.
        Impressive, someone write up a spec and publish it to the esolang wiki.

        • OshaqHennessey@midwest.social
          link
          fedilink
          arrow-up
          1
          ·
          18 days ago

          It’s an incoherent hodgepodge of C#/.NET, PowerShell, and JavaScript, each of which I’ve forgotten more about than I currently know

Programmer Humor@programming.dev

programmer_humor@programming.dev

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: [email protected]

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

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

  • 638 users / day
  • 3.82K users / week
  • 5.39K users / month
  • 5.45K users / 6 months
  • 1 local subscriber
  • 28.1K subscribers
  • 211 Posts
  • 1.91K Comments
  • Modlog
  • mods:
  • adr1an@programming.dev
  • Feyter@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.14
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org