Discuss Online
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
JPDev@programming.dev to Programmer Humor@programming.dev · 1 year ago

ifn't

programming.dev

message-square
127
link
fedilink
758

ifn't

programming.dev

JPDev@programming.dev to Programmer Humor@programming.dev · 1 year ago
message-square
127
link
fedilink
alert-triangle
You must log in or register to comment.
  • Trailblazing Braille Taser@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    207
    arrow-down
    1
    ·
    1 year ago

    I propose a new, more threatening kind of control flow.

    do {
      /* something */
    } or else {
      /* you don't want to find out */
    }
    
    • gex@lemmy.world
      link
      fedilink
      arrow-up
      58
      ·
      1 year ago

      Some C++ style guides suggest the following naming convention for functions that crash on any error

      OpenFileOrDie()
      
      • xmunk@sh.itjust.works
        link
        fedilink
        arrow-up
        26
        ·
        1 year ago

        PHP has the always wonderful (and perfectly functional) syntax of

        logUserIn() or die();

        • msage@programming.dev
          link
          fedilink
          arrow-up
          6
          ·
          1 year ago

          Or Perl

          • frezik@midwest.social
            link
            fedilink
            arrow-up
            10
            ·
            edit-2
            1 year ago

            Perl also has unless() for the very purpose in OP, which is a more sensible choice.

            Oh, and if you need to reinforce your belief that Perl is a mess, the single-quote character can be used as a package separator instead of “::”. This was set in the 90s when nobody was quite sure of the right syntax for package separators, so it borrowed “::” from C++ and the single quote from Ada (I think).

            That means the ifn't() in OP can be interpreted as calling the t() function on the ifn package.

            The “::” separator is vastly preferred, though. Single quotes run havoc on syntax highlighting text editors (since they can also be used for strings). About the only time I’ve seen it used is a joke module, Acme::don't.

          • evatronic@lemm.ee
            link
            fedilink
            English
            arrow-up
            3
            ·
            1 year ago

            Where do you think PHP stole it from?

            • msage@programming.dev
              link
              fedilink
              arrow-up
              2
              ·
              1 year ago

              Bash?

      • Kissaki@programming.dev
        link
        fedilink
        English
        arrow-up
        10
        ·
        1 year ago

        Personally, I like to call catched exception variables up, so for a rethrow I can throw up;.

        • TwilightKiddy@programming.dev
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          Except rethrowing an exception in C# is just throw;, anything else is a crime against the person who reads your stacktraces.

      • MonkderZweite@feddit.ch
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        I mean, it makes sense to call ComplainToErrorAndExit just ‘die’, no?

      • Vorthas@programming.dev
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        One of the modules in a project I’m working on is called VulkanOrDie which always makes me crack up when I see it in the compilation messages.

      • OpenStars@startrek.website
        link
        fedilink
        English
        arrow-up
        4
        arrow-down
        1
        ·
        1 year ago

        It’s funnier when you try to SysCallAndDie() :-P

        (that’s a real thing in perl btw - I guess that function didn’t get the memo)

      • yum13241@lemm.ee
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        Now what about GZDoom’s GoAwayAndDie();?

    • Strawberry@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      41
      ·
      1 year ago

      this is just a menacing try/catch!

    • moody@lemmings.world
      link
      fedilink
      arrow-up
      23
      ·
      1 year ago

      It_would_be_a_shame_if(condition)

    • Mesa@programming.dev
      link
      fedilink
      arrow-up
      10
      ·
      1 year ago

      The better try-catch. More intuitive if you ask me.

    • jadelord@discuss.tchncs.de
      link
      fedilink
      arrow-up
      8
      ·
      1 year ago

      It exists, kind of. Python has this construct

      for item in iterable:
          ...
      else:
           ...
      

      which always puzzles me, since it depends on a break statement execution. I always have to look it up when the else block is executed.

    • OpenStars@startrek.website
      link
      fedilink
      English
      arrow-up
      8
      arrow-down
      2
      ·
      1 year ago

      You just made me a offer I can’t refuse. I go now to sleep with the fishes…

    • rothaine@beehaw.org
      link
      fedilink
      English
      arrow-up
      5
      ·
      1 year ago
      do {
        /* something */
      } do hast {
        /* something */
      }
      
      • Trailblazing Braille Taser@lemmy.dbzer0.com
        link
        fedilink
        arrow-up
        7
        ·
        1 year ago
        do {
          /* something */
        } do hast {
          /* something */
        } do hast mich {
          /* something */
        }
        
  • OpenStars@startrek.website
    link
    fedilink
    English
    arrow-up
    107
    arrow-down
    2
    ·
    1 year ago

    Please God let this be a humorous post that somehow does not also find a way to manage to come true…

    • jtk@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      88
      ·
      edit-2
      1 year ago

      I would have bought it if they said ifnot instead, it’s the same number of characters and wouldn’t require a major parser overhaul to support keywords with a ’ in the name.

      • Pup Biru@aussie.zone
        link
        fedilink
        arrow-up
        45
        ·
        1 year ago

        i mean, “unless” tends to be the usual term for an “if not” keyword in languages that implement such a thing

        • Fal@yiffit.net
          link
          fedilink
          English
          arrow-up
          24
          arrow-down
          4
          ·
          1 year ago

          Which is awful and incredibly confusing. I hate ruby

          • msage@programming.dev
            link
            fedilink
            arrow-up
            3
            ·
            1 year ago

            And Perl

            • NigelFrobisher@aussie.zone
              link
              fedilink
              arrow-up
              3
              ·
              1 year ago

              And my axe!

          • Pup Biru@aussie.zone
            link
            fedilink
            arrow-up
            3
            ·
            1 year ago

            totally agree; just saying that if it’s GOT to be something, that something should probably be unless… unless . . .

          • frezik@midwest.social
            link
            fedilink
            arrow-up
            2
            ·
            1 year ago

            I find that you need to choose carefully when to use it. Simple cases tend to be alright. Larger, more complex conditions shouldn’t touch it.

      • OpenStars@startrek.website
        link
        fedilink
        English
        arrow-up
        16
        arrow-down
        2
        ·
        1 year ago

        Yeah, to be clear, I don’t like it, I don’t like it one bit:-P.

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

          If not anybody have time for that.

          • OpenStars@startrek.website
            link
            fedilink
            English
            arrow-up
            2
            arrow-down
            1
            ·
            1 year ago

            *ifn’t*

            Oh dear Lord what have I done!? :-P

    • mryessir@lemmy.sdf.org
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      deleted by creator

      • OpenStars@startrek.website
        link
        fedilink
        English
        arrow-up
        2
        arrow-down
        1
        ·
        1 year ago

        Gulp…

         [link]

        Also, just for fun, the prequel:

  • Bappity@lemmy.world
    link
    fedilink
    English
    arrow-up
    98
    ·
    edit-2
    1 year ago

    cap () {

    }
    nocap () {

    }

    • runner_g@lemmy.blahaj.zone
      link
      fedilink
      English
      arrow-up
      46
      arrow-down
      1
      ·
      edit-2
      1 year ago

      nocap(frfr){

      }

  • MagicShel@programming.dev
    link
    fedilink
    arrow-up
    79
    arrow-down
    1
    ·
    1 year ago

    Reduce exclamation marks!? Great Scott!!! Is there a shortage of punctuation in the future!?

    • KairuByte@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      21
      ·
      1 year ago

      You could have saved two, all you had to do was use the interrobang. You’re a monster.

    • SubArcticTundra@lemmy.ml
      link
      fedilink
      arrow-up
      15
      ·
      1 year ago

      All known deposits were depleted

    • jaybone@lemmy.world
      link
      fedilink
      arrow-up
      13
      ·
      1 year ago

      1.21GB!!!

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

      Kernighan, what was I thinking?

  • ohlaph@lemmy.world
    link
    fedilink
    arrow-up
    53
    ·
    1 year ago
    aint (something) {
        somethingElse()
    }
    
    • Facebones@reddthat.com
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      As a Virginian learning coding, this would make my damn day.

      • Threeme2189@lemm.ee
        link
        fedilink
        arrow-up
        11
        ·
        1 year ago
        #define aint(x) if (!(x))
        
    • 15liam20@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      Or maybe

      taint(condition) {}

  • undetermined@lemmy.world
    link
    fedilink
    English
    arrow-up
    60
    arrow-down
    7
    ·
    1 year ago

    deleted by creator

    • JPDev@programming.devOP
      link
      fedilink
      arrow-up
      68
      arrow-down
      1
      ·
      1 year ago

      unlessn’t

    • Goun@lemmy.ml
      link
      fedilink
      arrow-up
      29
      arrow-down
      1
      ·
      1 year ago

      I’m sorry, I hate the “unless” so much

      • NotSteve_@lemmy.ca
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        At one of my first jobs, I was tasked to rewrite a bunch of legacy Perl scripts in Python and the unless lines always made me trip up. I don’t know why but it really messed with my mental flow when reading Perl code

    • chaogomu@kbin.social
      link
      fedilink
      arrow-up
      11
      arrow-down
      1
      ·
      1 year ago

      Basic used “else”.

      It’s nice. “if”, “then”, and “else”. I spent a year programming a shitty roulette game on an Apple 2e back in high school. I still remember the joy of using if/then/else paired with goto to make a horrible mess of spaghetti logic.

      But yeah, “else” is nice.

      • SubArcticTundra@lemmy.ml
        link
        fedilink
        arrow-up
        7
        ·
        edit-2
        1 year ago

        Using a standalone ‘else’ would tickle my brain in the same nice way that being able to declare a variable inside an ‘if’ statement as if it were a ‘for’ loop (which you can do in modern C++) does.

        • Lmaydev@programming.dev
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          Many languages let you scope variables.

          In c# you can create an arbitrary scope to declare variables in. Most likely in others as well.

          • SubArcticTundra@lemmy.ml
            link
            fedilink
            arrow-up
            2
            ·
            1 year ago

            Ah clever, didn’t think of doing this. Not having to encapsulate if statements in scopes would still look cleaner though

            • Lmaydev@programming.dev
              link
              fedilink
              arrow-up
              1
              ·
              edit-2
              1 year ago

              It’s handy if you’re creating temp variables for single use that you don’t need to use again.

              Although I admit I’ve only ever done it a couple times lol

              Again in c# you can omit the scope and only the next statement is part of an if or loop.

        • Amaltheamannen@lemmy.ml
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          Or a rust “if let”

          • SubArcticTundra@lemmy.ml
            link
            fedilink
            arrow-up
            3
            ·
            1 year ago

            Ooh yes. Rust is king when it comes to this sort of inline stuff. Inline match. Mmmmmm!

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

          Block scoped variables are bad?

          • SubArcticTundra@lemmy.ml
            link
            fedilink
            arrow-up
            1
            ·
            1 year ago

            🤷‍♂️

      • Deceptichum@kbin.social
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        Let’s just scrap every language except various forms of BASIC.

        • pearsaltchocolatebar
          link
          fedilink
          arrow-up
          4
          ·
          1 year ago

          Please God, no. I had to unravel terminal scripting code that was written in some propriety BASIC language with basically no documentation.

          Took me a chunk of time trying to figure out how it worked before I made the realization that it was BASIC

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

            Try PL/SQL.

    • EnderMB@lemmy.world
      link
      fedilink
      arrow-up
      7
      ·
      1 year ago

      I haven’t written any Ruby for years, but I still praise it in every conversation I have regarding programming languages. It’s basically a much simpler Python, with some design ideas that are both beautiful and deeply strange.

      • OskarAxolotl@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        1 year ago

        Ruby was designed to evoke joy and they absolutely succeeded. Usually, programming is mostly a means to an end to me. But using Ruby just feels so amazing, it’s almost impossible to even describe to somebody who has never used it before.

    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      1 year ago

      The Perl version of it is even greater!

  • Lung@lemmy.world
    link
    fedilink
    arrow-up
    40
    ·
    1 year ago

    ifn't(!valid) halp?

    • Deconceptualist@lemm.ee
      link
      fedilink
      English
      arrow-up
      40
      ·
      1 year ago

      I believe that resolves the same as

      ain’t!(!untrue)

      • RagingHungryPanda@lemm.ee
        link
        fedilink
        arrow-up
        20
        ·
        edit-2
        11 months ago

        Removed by mod

        • elvith@feddit.de
          link
          fedilink
          arrow-up
          9
          ·
          1 year ago
          {
            put(a, "heartache")
            tell(me, "why")
            ain't(nothing)
            {
              put(a, "mistake")
              //...
            }
          }
          
  • rimjob_rainer@discuss.tchncs.de
    link
    fedilink
    arrow-up
    39
    ·
    edit-2
    1 year ago

    Why not just ifnot? Same count of characters but an o instead of a possibly problematic single quote.

    • Ookami38@sh.itjust.works
      link
      fedilink
      arrow-up
      19
      ·
      1 year ago

      I think it’s just capitalizing on a trend to add n’t to otherwise noy contractions, to make them into contractions. Contractionn’ts, if you will

    • Ferk@kbin.social
      link
      fedilink
      arrow-up
      17
      ·
      edit-2
      1 year ago

      Yes… how is “reducing exclamation marks” a good thing when you do it by adding a ' (not to be confused with , ´,‘or’` …which are all different characters).

      Does this rely on the assumption that everyone uses a US QWERTY keyboard where ! happens to be slightly more inconvenient than typing '?

    • KmlSlmk64@lemmy.world
      link
      fedilink
      arrow-up
      15
      arrow-down
      1
      ·
      1 year ago

      If someone really wanted to add it, probably the best would be to use unless

      • JoshuaEN@lemmy.world
        link
        fedilink
        English
        arrow-up
        10
        arrow-down
        1
        ·
        1 year ago

        I really liked having unless in Ruby; a ! can be easy to miss, while unless made it clear without needing to write out != true.

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

          It’s also cool when you do unless(!condition). I particularly like this.

  • xmunk@sh.itjust.works
    link
    fedilink
    arrow-up
    36
    ·
    1 year ago

    Still not as good as whence

    • fartsparkles@sh.itjust.works
      link
      fedilink
      arrow-up
      14
      ·
      1 year ago

      Is this a reference to something because I’d love to read it if you have a time to share.

      • xx3rawr@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        6
        ·
        1 year ago

        Woah. I did a quick google and it’s not just a meme, but actually used in some major lang’s libraries.

        • jjjalljs@ttrpg.network
          link
          fedilink
          arrow-up
          4
          ·
          1 year ago

          This is one of those “modern Google/search sucks” moments because I couldn’t immediately find examples of it in a programming language.

          • xx3rawr@sh.itjust.works
            link
            fedilink
            English
            arrow-up
            1
            ·
            1 year ago

            I actually used DDG and most I’ve seen, they’re just used as arguments for functions notably in C and Python

      • LeFrog@discuss.tchncs.de
        link
        fedilink
        arrow-up
        5
        ·
        edit-2
        1 year ago

        It is used in ksh korn shell to see what executable responds to a command:

        https://superuser.com/a/351995

        Edit: Oh, what a rabbit hole: Why not use “which”? What to use then?

    • SubArcticTundra@lemmy.ml
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      1 year ago

      Legislation (which feels similar to programming languages sometimes) seems to have some keywords of its own. I remember seeing a lot of Whereas ... and Having regard to ....

  • xia@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    34
    arrow-down
    2
    ·
    1 year ago

    “Help’s with readability”? You know what else helps? Not using contractions and introducing an unbalanced single quote.

    • bdonvr@thelemmy.club
      link
      fedilink
      arrow-up
      44
      ·
      1 year ago

      If they’d’nt’ve done that, it’d’ve been better. Agreed.

      • Cwilliams@beehaw.org
        link
        fedilink
        arrow-up
        3
        ·
        1 year ago

        they’d’nt’ve

        Aside: rip Tom Scott

      • Rob@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        TIHI

    • frezik@midwest.social
      link
      fedilink
      arrow-up
      4
      ·
      1 year ago

      Runs havoc on parsing, too. It’s bad for both humans and robots. I say we ship it.

    • survivalmachine@beehaw.org
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      This feels racist against Appalachia. We naturally speak with contractions and are commonly referred to as “unbalanced”.

  • janabuggs@beehaw.org
    link
    fedilink
    arrow-up
    30
    arrow-down
    1
    ·
    1 year ago

    I’m struggling to understand if this is true or ifn’t true

  • csm10495@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    28
    ·
    1 year ago

    Imagine the regex needed to highlight code with that extra single quote.

  • Caveman@lemmy.world
    link
    fedilink
    arrow-up
    25
    ·
    1 year ago

    I’d take a not or “if not” operator tbh.

    • Lmaydev@programming.dev
      link
      fedilink
      arrow-up
      9
      ·
      edit-2
      1 year ago

      It has a not keyword it’s used for pattern matching.

      if (x is not null)
      
      • Caveman@lemmy.world
        link
        fedilink
        arrow-up
        3
        ·
        1 year ago

        It also has a !=.

        • Lmaydev@programming.dev
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          Pattern matching is different.

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

            Yeah, I just said it since you used it with null. I used it a lot for enums

            • Lmaydev@programming.dev
              link
              fedilink
              arrow-up
              1
              ·
              edit-2
              1 year ago

              The type matching is the most common thing I use it with. Combined with inline variables.

              if (x is string { Length: 5} s)
              {
                  // do stuff with s
              }
              

              And switch expressions.

              As a side note inline variables are amazing haha

      • Patches@sh.itjust.works
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        Stuff can be two things

    • Appoxo@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      ifnt instead of ifn’t

  • taanegl@beehaw.org
    link
    fedilink
    arrow-up
    24
    ·
    1 year ago

    I’m just hoping this paves the way to code with Southern dialect

    iffun is == true
    iffun ain't == false
    
    • timetravel@lemmings.world
      link
      fedilink
      arrow-up
      21
      ·
      1 year ago

      May I introduce you to the joys of #define and creating your own horrible sub language

      • frezik@midwest.social
        link
        fedilink
        arrow-up
        6
        ·
        edit-2
        1 year ago

        That reminds me of an old paper about how to create a compilable C program out of old game ROMs. Decompile to assembly. Implement a bunch of #define statements that implement all the ASM statements. Now compile it to a native binary on whatever platform.

        Won’t likely be faster or more accurate than regular emulation methods, but it’s a neat idea considering that the source code on all this stuff was lost a long time ago.

  • jtk@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    18
    ·
    edit-2
    1 year ago
    ifn't (myNum don't= 3 && myStr ain'tnull'rblankish)
    
    • felbane@lemmy.world
      link
      fedilink
      arrow-up
      14
      ·
      1 year ago

      Please remain calm, we are sending paramedics to your location.

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

        I genuinely lol’d

    • SubArcticTundra@lemmy.ml
      link
      fedilink
      arrow-up
      7
      arrow-down
      1
      ·
      1 year ago

      I hate seeing colloquial terms like ‘ain’t’ in non-comment (ie. standardized) parts of code

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: !programmer_humor@programming.dev

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.

  • 1.43K users / day
  • 4.62K users / week
  • 9.2K users / month
  • 17.6K users / 6 months
  • 77 local subscribers
  • 23.1K subscribers
  • 1.39K Posts
  • 51.4K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.11
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org