• udon@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago
    1. it’s easy to make fun of
    2. it makes every other programming language look better in comparison
      • KillingTimeItself@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        0
        ·
        1 year ago

        bash would be a scripting language, though to be fair, i also consider bash to be pseudo code as well.

        If JS is a scripting language, than any other language is a scripting language. And technically, every language can be used to script, so therefore, is a scripting language. i’m referring to the aspect of a scripting language being generally constricted.

        • meteokr@community.adiquaints.moe
          link
          fedilink
          arrow-up
          0
          ·
          1 year ago

          Pseudo code is literally fake code. Scripting is an actual type of code. Scripted languages while not strictly defined, usually refers to languages you don’t compile before running them. Bash is considered a scripting language because you don’t ship a binary compiled executable, but rather ship a file that is human readable and converted into machine code when it is run. Scripting languages are compared to compiled languages, like C or Rust. Where the file you run is already compiled, and executed directly.

          What do you mean by this?

          i’m referring to the aspect of a scripting language being generally constricted.

          Any Turing complete system, or this case language, can do anything any other one can, depending on the level of suffering you are willing to endure to make it happen. Anything JS can do, Rust can do. Anything Rust can do, Bash can do. The differences between languages is the assumptions they make, and performance characteristics as a result of those assumptions. Functionality is not practically different from one another, though some absolutely make it easier for humans to do.

          • KillingTimeItself@lemmy.dbzer0.com
            link
            fedilink
            English
            arrow-up
            0
            ·
            1 year ago

            Pseudo code is literally fake code.

            hence why i specified why i consider it to be as such. I just think pseudo code shouldn’t exist. Plain and simple. Bash scripting is close to a language in the same way that pseudo code is also technically code.

            What do you mean by this?

            i just mean the simple fact that you could technically probably run bash on windows, but really wouldn’t want to. I don’t consider bash to be a programming language, though it is technically a scripting language, because it’s primary existence is in the shell environment of a system. I.E. constricted, but that’s just my view of it.

            • meteokr@community.adiquaints.moe
              link
              fedilink
              arrow-up
              0
              ·
              1 year ago

              Bash being on the same level as actually fake code is a pretty hot take to me. What are your opinions on Python, or Ruby, or any other interpreted language? You could very well use them as your login shell, just like Bash if you wanted. In your eyes, if Bash *isn’t * a programming language at all, how do you describe a programming language? Languages that express code are just the same as languages that write stories, and whether you do it in German or Vietnamese makes no difference on what story you can write.

              When you describe a language as constricted what do you mean? Bash can do anything Python or Rust can do, each of them is just specialized to being better at specific aspects for human convenience in writing code. There is no inherit limitation on what can be done by the language you use to express it.

      • palordrolap@kbin.social
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Depends on how you define “scripting language”.

        Older techs remember when it was only browser-based and they thought of, and perhaps still think of, “scripting languages” as something that would run from some command-line or another. Starting a GUI browser to run a mere script was a ridiculous concept. (There was also that JavaScript had no filesystem access. At least initially. And then it became a gaping security hole, but I digress.)

        Today, there exist command-line accessible versions of JavaScript but even there (I figure) most people wince and choose anything else instead. Maybe even Perl.

        But another definition of “scripting language” is “(any) interpreted programming language” and where it runs is unimportant.

        From that perspective, sure, JavaScript qualifies. And so does QBASIC.

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

          A script is just a file that can execute a series of commands without the need to compile

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

            They compile in some point of time because CPU don’t know shit about Javascript. But that is for some other discussion.

            Edit: typo

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

      It’s also not a scripting language.

      It definitely is a scripting language.

      hello-world.js:

      #!/usr/bin/env node
      
      console.log("Hello world");
      

      Your favorite command line tool:

      chmod +x ./hello-world.js
      ./hello-world.js
      

      You just need to install npm, eg via apt-get install npm.

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

      This must be a “hold my beer” kind of joke and someone wanting to see how far they can take it.

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

      What’s even wilder is if you look at the code of that package, all it does is include the is-odd package and then return !is-odd. And the is-odd package isn’t much better, it does some basic checks on the input and then returns n % 2 === 1.

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

        I thought I was missing something. JS is one of my main languages and I always just write the is-odd function myself since it’s like 10 characters. It boggles the mind that is-even has 176k weekly downloads

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

          Also there are 40-something packages depending on it, so I guess it gets pulled automatically when they are used.

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

          To be fair having a name can make things easier to read. I get that i % 2 == 0 is a common pattern and most programmers will quickly recognize what is happening. But isEven(i) is just that much easier to grok and leaves that brainpower to work on something else.

          But I would never import a package for it. I would just create a local helper for something this trivial.

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

            Exactly what I would do if I had to reuse it, especially now since I know that adding a package would actually add 2. It all just seems so…inefficient

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

              Even if the code isn’t reused adding names to sub-expressions can be very valuable. Often times I introduce new functions or variables even if they are only used once so that I can give them a descriptive name which helps the reader more quickly understand what is happening.

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

                Yeah, I do that with pretty much every separate operation in c# since our solutions are pretty big. Most of my JS scripts are just done in ServiceNow which are separated and named appropriately.

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

          If youre lazy/busy enough, doing basic checks on the input is enough boilerplate to package out.

  • SGG@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 year ago
    1. It runs in browsers
    2. If you hate your co-workers, then they will also feel your pain.
  • heavyboots@lemmy.ml
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    1 year ago

    Browsers love it!

    Practically anything you write will execute without all that scope and well formed statements nonsense.

    Mind you, number 2 is also its biggest flaw as well, but…

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

    1 - Easiest way to run a script in your browser
    2 - Always finds its way if inputs are bad
    Nan - undefined

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

        To be fair, this is actually reasonable. But it does look stupid on the face of it.

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

        When my console throws a NaN I kinda think of it as an Halloween kid receiving a fruit instead of a candy. They won’t say “That’s a fruit”. They’ll say “That’s not a treat”.

        I’m personally pissed more often by a falsy 0.

        Did you know that early analog computers would literally explode when asked to divide by 0?

        Now computers just say “Hey stupid, that shit is not even a Number in a mathematical sense, but sure I’ll add one to it.” instead of “Why would you kill me like this?”

        You can’t really define Infinity as a number, yet it is part of their world.

        So typeof NaN === ‘number’ totally makes sense in that regard.

        If you ever worked with arrays of dates, don’t judge NaN too harshly.

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

          Falsy zero? What’s wrong with that, 1 is true and 0 is false. I thought that was standard logic?

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

            in javascript a property is truthy if it exists

            myThing.property = "some string"
            
            if (myThing.property) { // true
              // do something
            }
            

            It works with everything except of course for falsy values

            myThing.number = someNumberThatShouldNotBeEqualToZero
            
            if (myThing.number) {
              // do something very important with that number that should not be equal to zero
            }
            
            // This can fail at anytime without warning
            

            So you’ve got to be extra careful with that logic when you’re dealing with numbers.

            I am not saying it’s wrong though. I’m saying it’s often annoying.

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

              ah ok , I think I write this a bit more verbose when using other languages, instead of

              if(thing)
              {
                 stuff;
              }
              
              

              I do

              
              if(thing != null)
              {
                 stuff;
              }
              

              so checking for numbers being truthy & existing didn’t seem like an issue