1. 5
  1.  

  2. 3
    a = [1, 2, 3]
    arr = a.map(X*2) # arr is now [2, 4, 6]
    

    https://github.com/ngs-lang/ngs#arrays

    Respectfully, arent you just reinventing the wheel here? That looks pretty similar to Ruby:

    a1 = [10, 20]
    a2 = a1.map { |n1| n1 * 2 }
    

    Wouldnt it be better to just have a dumb shell, that can call programs to do heavy lifting (read: programming languages). This way you have a “division of labor”. Shell works best for launching executables, and programming languages work best for handling data structures and algorithms.

    I have found when one trys to borrow too much from the other you get bad results. For example, when a shell trys to add too many programming features, you get a slow bloated result. Compare Bash versus Dash. Similarly programming languages should avoid calling executables when possible, as it leads to performance bottlenecks. For example using LibcURL instead of cURL and LibGit instead of Git.

    1. 1

      Regarding similarly to Ruby. You picked one part which does look superficially similar. Even that part has syntax that Ruby doesn’t. It works completely different underneath.

      That’s not how you compare two languages and conclude wheel reinvention.

      1. 0

        I think that the domain of the shell has changed. I will write blog post about this. For now, some of my thoughts regarding this issue are here:

        https://ilya-sher.org/2018/09/10/jq-is-a-symptom/

        1. 2

          The fact that Bash has scope creep doesnt justify it. Its an easy road to go down, as Bash is popular and JSON is popular, so why cant Bash do JSON?

          Next one might say, well Bash is popular and HTTP client is popular, so why cant Bash do HTTP client? Why do we need to call cURL? Its a slippery slope, so as a community people need to think critically, outside of current Bash feature float and decide: where is the line?

          For many years I tried to do everything with Bash. Then I tried to do everything with AWK. Eventually you realize where the limits are, and you want to push them. But the better option is to use the right tool for the job. Remember Zawinski’s law:

          Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.

          https://en.wikipedia.org/wiki/Jamie_Zawinski

          1. 1

            The blog post will take a while. Preliminary tldr: you don’t tell developers to use notepad instead of IDE. That’s because you want UX and productivity.

            I want productivity but I can’t imagine implementation of the features that I envision as external proceses, hence new, non posix shell (I don’t suggest bolting additional features to bash).

            Also fixing issues such as your-terminal-as-dumpster when you run background process(es) seems to belong to a new shell.

            Note that notepad does have it’s place.

      2. 2

        Reminds me of blocks in C and C-inspired languages, except it has a name. Which allows you to tie intent to the block.

        1. 1

          I’ve been trying to come up with a nice solution for this for about 20 years now. I don’t really feel a lot closer, so long as we’re committed to keeping everything as dead 1d strings of ascii.

          1. 1

            Heed the siren call of PowerShell!