1. 7
  1.  

  2. 3

    Hi.

    I translate snippets from other languages to NGS from time to time. I’ve added your example to the comparisons page.

    https://github.com/ngs-lang/ngs/wiki/Code-Snippets-Comparisons#astronauts-from-json-api

    1. 1

      Nice, thank you.

      I like some of the things ngs seems to be doing, perhaps some time I can write more examples of janet shell to compare with ngs.

      You mention “``” is special syntax for parse and execute json in ngs, in Janet Shell the syntax is a bit uglier as a lisp inspired language, but the power this trade off gives us is that users can define operators like this for themselves that are no less powerful or ‘first class’ than the ones janet shell provides.

      Another thing the comparison might not capture is that the importing of json is a user defined thing, so it is quite flexible if you want to support new (or old) formats that are not json. Not sure what the ngs ffi looks like, or what writing a parser for a different format would look like in ngs.

      To quote your readme:

      General purpose programming languages (Python, Ruby, Go, ...) are not a good fit for typical Ops tasks. Show me one where echo my_string >my_file is as easy and as concise as in bash.
      

      Well, technically Janet is a general purpose language where this is possible as a library (Janet Shell is really just a library), though there are some corner cases that make it slightly worse than bash, but also other cases that are much better than bash.

      1. 1

        Another thing the comparison might not capture is that the importing of json is a user defined thing

        It’s wiki, you can add comments in or near the code

        You mention “``” is special syntax for parse and execute json in ngs

        It’s execute and parse, not specifically JSON.

        operators like this for themselves that are no less powerful or ‘first class’ than the ones janet shell provides.

        You mean read-time macros?

        • In my mind, it will not be a straightforward task to define bash-like commands syntax with variables interpolation, etc
        • I’ve defined execute-and-parse syntax in NGS because this is very common pattern. From my perspective, it would make sense to have this in all shells, including Janet.

        quite flexible

        In NGS, the double-backtick syntax eventually calls a multimethod and is easily extensible. If nothing more specialized parses the output, built-in method tries to parse JSON.

        ngs ffi looks like

        As not much at the moment: https://github.com/ngs-lang/ngs/wiki/FFI-Design , very partially implemented, not worth discussion at the moment.

        what writing a parser for a different format would look like in ngs

        Not very good. Until FFI is ready, if the format simple, that will be implemented in NGS; if the format is complicated, I’ll add C library wrapper in NGS.

        general purpose language

        You picked a language in which one can define a syntax so making a good shell is possible (without new language). $$ is Janet syntax, right?

        I knew about Lisp and reader macros. On the other hand I think Lisp is mentally far from Ops tasks and Ops people, including me. (That’s in my environment, your perspective might be different). That’s why I’m developing NGS, in which syntax and all features were designed with Ops in mind.

        1. 1

          the double-backtick syntax eventually calls a multimethod and is easily extensible

          That sounds cool.

          $$ is Janet syntax, right?

          it is a normal macro.

          On the other hand I think Lisp is mentally far from Ops tasks and Ops people, including me. (That’s in my environment, your perspective might be different). That’s why I’m developing NGS, in which syntax and all features were designed with Ops in mind.

          I don’t know exactly what you mean by having Ops in mind, It is easy from janet shell to use ssh/google cloud/aws or write a library for using these.

    2. 1

      Can we please tag this “Lisp”

      1. 2

        It’s up to users to suggest tags - check the “suggest” link near the title.

        1. 1

          I don’t know if it is lisp, some people think lisp means common lisp specifically. Janet is it’s own language, I guess it is in the lisp family.

          1. 2

            To me, if I see “paren soup”, then it’s lisp.

            1. -1

              Some people can’t tell the difference between Japan, Korea and China either.

              1. -1

                If you have a better tag for “unreadable langauges with too many parenthesis”, let me know

                1. -1

                  Your loss, enjoy javascript and bash.

                  Btw, count semantic parens:

                  Janet:

                  (fn [] (print "hello"))
                  

                  Javascript:

                  function () { print("hello"); }
                  
                  1. 0

                    No one writes functions in JavaScript like that. They do it like this:

                    const aa = function(bb) {
                       console.log(bb);
                    };
                    

                    Or:

                    const aa = function(bb) console.log(bb);
                    

                    Or:

                    const aa = bb => console.log(bb);
                    
                    1. 2

                      const aa = function(bb) console.log(bb);

                      In all my years of using JS, I’ve never seen function without a {} block.. and indeed for a reason:

                      SyntaxError: missing { before function body
                      
                      1. 1

                        Still same number of parens though (except for the last one).

                        1. 1

                          the point is that with lisp, every paren deepens the nesting. that doesnt happen in any of the JS examples…