• ulterno@programming.dev
    link
    fedilink
    English
    arrow-up
    6
    ·
    12 days ago

    While C feels fine without having a keyword for function, I feel like bash would have benefitted from it.

    • excess0680@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      12 days ago

      Bash (specifically Bash, not POSIX sh) does have a keyword for functions (function), but it’s optional.

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

        Ooh nice.

        The optional bit messed it up, because even though I can make my scripts easier for me, other’s scripts won’t be.
        But then bash had to be usable with sh scripts, so I get it.

        • excess0680@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          11 days ago

          Right. It’s optional so that Bash remains backwards compatible as a superset of POSIX sh. If you’re working with exclusively Bash, though, it’s nice to use as syntactic sugar if nothing else.

  • count_dongulus@lemmy.world
    link
    fedilink
    arrow-up
    13
    ·
    12 days ago

    Not exactly aimed at language keywords (although it is aimed at the language designers who decided abbreviations in keywords are acceptable):

    I hate abbreviations in source code so fucking much. Reading is more of software engineering than writing. If you cannot be bothered to type a whole word because typing is hard for you, find a different job. Do not force others to engage in mental gymnastics to understand what the fuck a variable or function is supposed to mean.

    • Static_Rocket@lemmy.world
      link
      fedilink
      English
      arrow-up
      11
      ·
      12 days ago

      There was a rather famous piece of software at my last job. Guy writing it wanted job security. A lot of the core variables of the application were named based on the sounds a helicopter made. God damn onomatopoeia variables. Pretty sure that shit is still in use somewhere.

      • MonkeMischief@lemmy.today
        link
        fedilink
        arrow-up
        4
        ·
        12 days ago

        I can’t imagine writing something like that. Job security? Hah, I’d end up in an inescapable labyrinth of my own making if I named things something that wouldn’t be obvious to my 3-months-later self!

        Maybe that’s the play: He intentionally confuses himself so it takes extra paid time to remember what the heck “SOISOISOI” does, compared to “Whopwhopwhop”.

    • crimsonpoodle@pawb.social
      link
      fedilink
      arrow-up
      3
      ·
      12 days ago

      I get that but also can be kinda nice to have density so that you can read more of the program on a single display.

    • masterspace@lemmy.ca
      link
      fedilink
      English
      arrow-up
      11
      ·
      edit-2
      13 days ago

      The equivalent in JavaScript / TypeScript would actually be function () {}, this is the syntax for named functions.

      C# is the same as bash though.

          • SpaceCowboy@lemmy.ca
            link
            fedilink
            arrow-up
            1
            arrow-down
            5
            ·
            13 days ago

            Yeah for whatever reason, FE devs want to make everything a const. It’s like a religious belief or something, it’s really kinda weird.

            const fun = () => { const something = “whatever” const array = []; array.push(someting)

            for (const thing of array) { if (thing === ‘whatever’) blah(thing) } }

            Semicolons? Optional. Which quotes you should use? Whatever you feel like! But you must declare things as a const wherever possible! Even if it’s an array that you’re going to be changing, declare it as a const because you should know that you can push things into a const array, and since it’s possible to declare it as a const, you must declare it as a const.

            Why is this? Nobody knows, but it’s important to FE devs that you use const.

            • brian@programming.dev
              link
              fedilink
              arrow-up
              2
              ·
              13 days ago

              semicolons? quotes? use a formatter and don’t think about it. I think js world has basically done this already.

              const is simpler. why would I declare an array as let if I’m not reassigning? someone can look at it and know they don’t have to think about reassignment of the reference, just normal mutation. ts has the further readonly to describe the other type of mutation, don’t abuse let to mean that.

              const arrow over named function? gets rid of all the legacy behaviors and apis. no arguments, consistent this, and no hoisting or accidental reassignment. the 2 places you should ever use named fn are generator or if you actually need this

              • SpaceCowboy@lemmy.ca
                link
                fedilink
                arrow-up
                1
                arrow-down
                4
                ·
                13 days ago

                Stylistically, you’re changing the array when you add something to it. Javascript is a janky language in the best of times, but FE devs like to artificially introduce additional unnecessary complexities on top of the jank.

                const is simpler. why would I declare an array as let if I’m not reassigning?

                Why would you declare a const that’s going to have different data every time to function is called?

                Now I’m thinking it’s a form of gatekeeping. Just an excuse for FE devs to throw out terms like “immutable” to make it sound like they know what they’re taking about. Y’all need to constantly sound like you know what you’re talking about when dealing with users, pretending weird stylistic choices have real technical reasons for them. But the BE devs know what you’re saying is complete bullshit LOL.

                • brian@programming.dev
                  link
                  fedilink
                  arrow-up
                  2
                  ·
                  12 days ago

                  knowing the programming language you’re working in at a basic level is gatekeeping I’m ok with

                • masterspace@lemmy.ca
                  link
                  fedilink
                  English
                  arrow-up
                  2
                  ·
                  edit-2
                  13 days ago

                  You are literally just describing the conceptual differences between functional programming and object oriented programming. It has nothing to do with front end vs backend, except for the fact that React has vastly popularized functional paradigms on the frontend.

                  If you come from a Java / Spring background, that will seem foreign, if you come from an express background it will feel natural.

                  Functional programming is extremely pleasant though. Its been described as what object oriented would look like if you actually followed all the SOLID principles. You should keep an open mind.

              • Mr. Satan@lemmy.zip
                link
                fedilink
                arrow-up
                1
                ·
                13 days ago

                semicolons? quotes? use a formatter and don’t think about it. I think js world has basically done this already.

                It’s nice when a codebase has sane formatter conventions. I can’t say that my workplace does, tho…

                const arrow over named function? gets rid of all the legacy behaviors and apis. no arguments, consistent this, and no hoisting or accidental reassignment. the 2 places you should ever use named fn are generator or if you actually need `this

                How is having arguments and this an issue? If one doesn’t need them, then it can be just left unused. I really don’t get this argument. It makes everything visually a variable. I see no benefit to this convention and actively despise it.

                • brian@programming.dev
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  12 days ago

                  I’ve worked at several places that didn’t have formatters when I started. they did by the time I left. you can incrementally adopt them and if it’s automated most people at worst don’t care. advocate for things you want

                  reassignment and hoisting are the significant ones. behavior around this does just seem more intuitive than otherwise when it comes up, so I think telling especially new devs to use const arrow fn everywhere but classes is a reasonable rule

                  hate to break it to you but it behaves like a variable either way. function just behaves closer to a var variable. const fns are less like variables since no assignment. intellisense/devtools all show them just fine. it really is just a minor aesthetic difference on the definition

            • Ghoelian@piefed.social
              link
              fedilink
              English
              arrow-up
              9
              ·
              13 days ago

              The reason is very simple, performance. If a value doesn’t need to be changed, don’t declare it as mutable. This isn’t just a front-end thing btw.

              • SpaceCowboy@lemmy.ca
                link
                fedilink
                arrow-up
                1
                arrow-down
                6
                ·
                13 days ago

                Pushing something onto an array isn’t changing the array? It’s not changing the reference to the array, but from a style standpoint it doesn’t make sense.

                And if you’re declaring a const within the scope of a function, it’s still allocating memory when it enters the scope and disposing it when it leaves the scope, same as a variable. There’s no performance benefit to do this.

                Something like const CONSTANT_VALUE = “This never changes” has a performance benefit and is actually how other languages use constants. The value will always be the same, the compiler understands this and can optimize accordingly. If you’re declaring an iterator or the result of calling a webservice to be const it’ll be a different value every time it runs that code, so it’s not something a compiler can optimize. In style terms, it’s a value that’s different every time you get to that line of code, so why would you want to call it constant?

                You’re comment indicates the FE dev obsession with always using const stems from a misunderstanding of how computers work. But of course many religious beliefs originate from a misunderstanding of the world. Whatever man, I just make it a const to make the linter happy, because it’s dumb FE bullshit LOL.

                • masterspace@lemmy.ca
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  ·
                  13 days ago

                  Lol.

                  Pushing something onto an array isn’t changing the array? It’s not changing the reference to the array, but from a style standpoint it doesn’t make sense.

                  So you’re arguing for writing things as they seem, not the way that computers treat them?

                  You’re comment indicates the FE dev obsession with always using const stems from a misunderstanding of how computers work.

                  Maybe rethink this.

  • krooklochurm@lemmy.ca
    link
    fedilink
    arrow-up
    11
    ·
    12 days ago

    Bash was derived by a team of criminally insane programmers in the bowels of a South American asylum so deep in the jungle no country can rightfully claim it as its own. It is the product of the demented keystrokes of the damned, possessing a singular logic so alien that its developers can hardly be said to be human at all.

    And I wouldn’t have it any other way.