1. 4

    Maybe you should try asking such questions on StackOverflow or CPP forums ;)

    JFTR, this should be called print_contents because I don’t like uppercase variable names and it’s not getting anything, just printing. So, there you have your option C :)

    1. 1

      StackOverflow or CPP forums ;)

      Mmm… nice. I think I’ll get there if there will be not enough answers here… since I already started here. I guess next time this kind of question goes straight there.

      1. 2

        It’s probably too opinionated for Stack Overflow; it’s likely to get closed there.

        1. 1

          … also makes sense

    1. 2

      The Getter returning void already gives some info that it’s not actually getting anything.

      Regarding which side I’m on. I think the discussion can be avoided by renaming the function to Print_Contents, which more accurately reflects the actual behaviour. I also think you should rename it to print_contents or PrintContents but I’m trying to be consistent.

      1. 1

        The Getter

        Side B claims it’s not a getter. Side A and you thinking it’s getter because of the naming convention you are accustomed to.

      1. 1

        Thanks, all!

        I guess I remembered incorrectly that reject() was in Lisp. Smalltalk + Ruby that is. I now see that in Scheme it’s called remove which I think is somewhat more reasonable than reject. Is it?

        It was interesting to hear that without and reject “read almost equivalently”. Maybe I should gather a bit more opinions because I might be in minority that thinks that without is more “natural”.

        As of this moment I’m a bit in favor of removing without but I will be thinking about this.

        1. 2

          memory size is almost unlimited

          I’ve started working on Next Generation Shell at 2013. My impression that GC pressure was and still is an issue. Therefore, NGS does have “primitive” types which fit into 64 bits and pass-by-value as opposed to “regular” heap-allocated / passed-by-reference. At the time I checked, Ruby did something very similar. Judging by documentation and how things work - Java is the same. I assume many other languages also did that.

          The main issue I experienced with NGS is that these “primitive” values can not have metadata associated with them as opposed to “regular” objects. For example fetch() method can read JSON from file. I would like to attach metadata to the read object - the file name. Then store() method instead of having mandatory destination can have optional destination and store(myobj) would save the data into the file it was read from. Unfortunately it breaks because the file could contain valid JSON such as 1, which would deserialize into the “primitive” value 1.

          I am wondering whether it’s a good time to revisit these considerations (regarding GC pressure and memory usage).

          do almost the same thing but have slightly different performance characteristics

          Trying to avoid this in NGS.

          Furthermore, the misleading theoretical simplicity of “encapsulated” objects or abstract data types implies regarding methods as belonging to classes and having implementation entirely in a single class

          CLOS doesn’t do that, Next Generation Shell doesn’t do that.

          1. 2
            Blog post about naming

            I’m writing a blog post titled “On Naming in Software Engineering”.

            I guess I do love this philosophical titles and topics :)

            TL;DR bunch of naming tips coming from repeating issues during code reviews

            For each tip, it will include code from code reviews, reviewer comments and discussion.

            I will certainly not finish this blog post this weekend.

            Next Generation Shell

            If I’m lucky enough to have enough time, I’ll continue working on Streams in NGS. Actually need to think whether I’m switching to Netty-like channels. Whatever I do for I/O is important milestone on my way to finally work on UI, for which I have a bunch of ideas.

            1. 1
              Ruby

              Ruby also figured that out some time ago.

              https://www.igvita.com/2009/02/04/ruby-19-internals-ordered-hash/

              Next Generation Shell

              (author here)

              Hash (a dictionary) was ordered from the beginning.

              $ ngs -pi '{"a": 1, "b":2, "c": 3}.keys()'
              Arr of size 3
                [0] = a
                [1] = b
                [2] = c
              

              Set is also ordered and in NGS it is thin wrapper around Hash (79 lines of NGS code, methods documented at https://ngs-lang.org/doc/latest/generated/Set.html )

              In both cases the comparison is order-sensitive. Thinking of it now, while it does make sense that Set comparison would ignore order, I didn’t have the use case yet. I guess I might need to change it sometime. Meanwhile less elegant workaround exists:

              $ ngs -pi 's1=Set([1,2]); s2=Set([2,1]); s1<=s2 and s2<=s1'
              Bool: true
              
              1. 2

                Thinking of it now, while it does make sense that Set comparison would ignore order, I didn’t have the use case yet.

                I often use it in tests where I need to compare a set of actual results with expected ones, and the function under test produces result in an undefined/changing order.

                1. 1

                  Mmm.. I didn’t have this situation yet. Probably because both Hash and Set are ordered and other algorithms I have at the moment are deterministic. I guess I can have this situation in future, when dealing with external input.

                  Interesting that meanwhile my mini test framework has assert_hash_keys_values() that does check that expected key-value pairs are in actual input but does not check that actual has no extra fields. I guess I made it for future-proof tests.

                  ...
                  expected.each(F(k, v) {
                  	assert_base(actual, "key '$k' with value '$v'", {has(actual, k) and actual[k] == v}, "to have", title)
                  })
                  ...
                  

                  Source: https://github.com/ngs-lang/ngs/blob/v0.2.7/lib/autoload/test.ngs#L145-L155

              1. 5

                Hey, I like your ideas about innovating in the shell/terminal (which I’ve ranted about a bit myself: https://matklad.github.io/2019/11/16/a-better-shell.html)!

                1. 3

                  OK. That will take some time to digest. Quite a few ideas there.

                  1. 1

                    There is quite a big overlap in thinking with https://matklad.github.io/2019/11/16/a-better-shell.html#new-shell

                    • “A GUI application” - I’m planning on Web UI and text UI, which will both have very similar functionality. (As opposed to GUI application)
                    • “UI framework for text-based UIs” - still thinking about that
                    • “tilling frame management”. Not sure yet but there must be some kind of management.
                    • “Some concept of process-let, which can occupy a frame” - thinking in same direction
                    • “A prompt, which is alway available, and smartly (without blocking, splitting screen if necessary) spawns new processlets.” – yes!!
                    • “An API to let processlets interact with text UI.” - yes
                1. 13

                  Keep text editing pure! Any semantic understanding by the text editor is undesirable, other programs should handle that. You don’t want to complicate the text editor.

                  ^^ Ever heard of Acme/Sam?

                  Why use a car when bicycle is so much simpler?

                  I think this point is quite relevant. I much prefer bikes over cars, because most of the time I don’t have to 50km+, and just hopping on a bike is easier to “setup” (just sit on the bike), gives me more freedom (I can get off and push it through a pedestrian zone), and doesn’t quite me to spend several hundreds of $$$ to be allowed to drive it – let alone own/maintain it. I don’t want software to be like cars, at least when it doesn’t have to.

                  The shell is broken, and saying that is an understatement. But at the same time, it exists in a real context (that being all the tools and programs that happen to run on *nix systems), within it’s not really feasible to just fix the shell. All attempts to compromise have failed.

                  1. 7

                    I think this sort of discussion reveals that minimalism, no matter what kind, can’t just be self-fulfilling but purposeful to be useful. And not just purposeful, but purposeful when contextualized; the justifications for computing minimalism in the 70’s aren’t usually so purposeful several decades later when the conditions that spawned those decisions no longer exist. Although that isn’t to say that the “dumb” shell doesn’t make total sense, it’s simply within the framework of specific (and sometimes outdated) requirements and decisions that it does. To quote Donald A. Norman’s foreword in The UNIX Hater’s Handbook:

                    Unix was designed for the computing environment of then, not the machines of today. Unix survives only because everyone else has done so badly. There were many valuable things to be learned from Unix: how come nobody learned them and then did better?

                    When it comes to the minimalism provided by bikes, I can’t help but also think that in our world today we could really use the “less” of bikes and benefit more from that. But at the same time I look at the urban design of cities along the sunbelt and think dreadful thoughts of cyclist lives lost trying to navigate sprawling, hostile suburbs. Some things may not be considered minimalist because there’s no real problems in choosing to do those things, since minimalism is universally, I believe, something that is difficult. But of course we shouldn’t give up pursuit of things for how difficult they may be.

                    1. 2

                      Need to look into acme/sam. Thanks! This might take a while.

                      Yes, everything should change. Meanwhile I was thinking about interoperability with existing mess (with degraded functionality), wrappers, and gradual creation of alternate utilities.

                      All attempts to compromise have failed.

                      I don’t understand here. Can you please elaborate?

                      1. 2

                        Need to look into acme/sam. Thanks! This might take a while.

                        It’s not that complicated. The concepts revolves around just what you mentioned, being an “integat-ing” (as opposed to an “integrat-ed”) editor. Russ Cox has a video here, and it’s also mentioned in this introduction to Plan 9.

                        I don’t understand here. Can you please elaborate?

                        A claim I have made before is that it’s just feasible to really overcome the limitations of contemporary operating systems (ie. Unix and Unix-likes) and their paradigms within the system itself. If you try to “make unix nicer to use”, you’ll eventually either loose what you wanted to keep, become a fantasy (eg. Plan 9), or your system will degrade to a point where it’s basically just as bad, just as much of a problem. Or so it seems.

                      2. 1

                        Took a look at Acme. Very interesting approach.

                        What I had in mind for “integrating” in Next Generation Shell was something resembling plumbing rules. I planned to parse the output of running commands to get “real” objects on the screen.

                        I guess I need some time to digest this and see which other ideas I can steal^W be inspired by.

                      1. 4

                        I like the UI although I despise that the demo runs in a browser.

                        A fundamental problem: Do you expect a command like “vim” or “tmux” to work as expected? If no, the lack backwards-compatibility makes the shell undesirable. If yes, you inherit all the baggage of terminals.

                        1. 1

                          I was planning on distinguishing programs that need terminal and the ones that just dump the output. For compatibility NGS will need to deal gracefully and make the programs that need terminal work.

                        1. 19

                          This article seems to confuse limitations of the shell with limitations of the operating system. stdout/stderr are operating system facilities that the shell is surfacing. The way these are combined from all child processes is how the operating system implements inheritance. If a shell launches a program and that in turn launches another program which generates output, the shell isn’t involved at all.

                          It’s true that this can be reimagined into a more semantically rich environment, but doing so requires not only a new shell but new programs and a new communication mechanism. This is the approach Powershell took. There’s nothing wrong with the approach, but rewriting all of the useful tools that a shell wants to interact with is a large undertaking.

                          So (shameless plug for where I work) if you want to have a semantically rich command line environment for manipulating your cloud computing deployment, there’s always Azure Powershell.

                          1. 4

                            I kept thinking “PowerShell has this” quite a lot while reading this. The object oriented nature of it makes it simple to select the data you want. The way the terminal displays objects is also available to be modified so an object can be much richer than what it initially displays. That makes it possible to actually work with the objects without having the cmdlets barf thousands of lines on your terminal when I only need to see a few of the properties of the objects.

                            It’s still lacking a few of the features the author talks about; namely the automatic redirection and the mouse interaction (though you could pipe the command through Out-GridView with -Passthrough to the new cmdlet), but in my opinion it’s a very good step in the new direction.

                            The only thing I despise doing in PowerShell is writing complex modules as it’s way too easy to shoot yourself in the foot. Since all values are in a global namespace they get changed around a lot and you never really know what is going to happen when you import something. There’s also a very irritating limitation on importing classes in the older versions of the shell, but that might have been fixed in a later version (but the problem then becomes targeting the version of the shell and so on…).

                            It’s a gigantic leap in the right direction, but it’s still lacking quite a few features before it becomes as comfortable to work in as the author imagines a shell could be.

                            1. 1

                              The main idea is not to have text dump but instead objects on the screen that you can interact with. I don’t think PowerShell has it. I didn’t see it anywhere in the documentation.

                              quite a few features before it becomes as comfortable to work in as the author imagines a shell could be.

                              I know there is a lot of work but what you mean here?

                              1. 3

                                The main idea is not to have text dump but instead objects on the screen that you can interact with. I don’t think PowerShell has it. I didn’t see it anywhere in the documentation.

                                You are right that there is no built in feature like that in PowerShell, but you can insert Out-GridView in your pipeline to get something similar, so for example Get-ChildItem | Out-GridView -Passthru | Remove-Item. That will pop up the result of Get-ChildItem and let you select the item you want to delete. This isn’t the same as what the author wants, and I really want what the author is imagining, but it does give you a somewhat similar workflow.

                                I know there is a lot of work but what you mean here?

                                Well, lets see then.

                                • PowerShell already has the ability to understand the input and output from commands (Errors are set to the $Error variable to inspect later if you are interested. Out-Host and Write-Warning allows you to write informational text in the terminal that is to be ignored when processing the pipeline.)
                                • The formatting of objects being output on the screen can be modified by a ps1xml. That gives you some control of how much text is going to be barfed out in your terminal, but not perfect control. An automatic application of less when the shell sees that there will be a lot of output would be nice.
                                • Automatic redirection isn’t a thing. You could have made a job to do it, but this is the same as what you’d have to do in bash to not have your terminal lock up because the command is still being processed.
                                • The semantic understanding is still lacking. While you could use Out-GridView as I suggested earlier, you still have to manually copy-paste things around instead of just clicking on things to make things happen. Imagine how awesome it would be if all object methods would automatically become a dropdown list element? Using the mouse or keyboard to select a previous object? All of that kind of understanding is lacking from the shell.

                                So yeah… There’s still a lot missing until it will be as good as the author is imagining, but in my opinion it’s a giant leap from bash.

                                1. 1

                                  I see. Thanks!

                                2. 3

                                  Have you used Lisp Machines, Userland, or Mathematica? They have a lot of what you would want, like command lines (and documents made of command lines) with rich objects embedded. (Some environments that get close, but not quite would include Domain/OS pads, MPW, Emacs…)

                                  Honestly, I think a lot of this could be done pretty easy with web technology…

                              2. 1

                                I haven’t tried Azure (or Azure Powershell) - does it have the user interface features of Windows Powershell ISE? I think the power of the semantic-objects approach is to build additional UI and interaction on top of the object model. Without that interactivity, there’s not much difference from shell tools that just spit out easy-to-parse text streams.

                                1. 1

                                  Azure Powershell is a collection of cmdlets to manage Azure that expose Azure concepts as objects. Those cmdlets run in Powershell. You can run Powershell as part of ISE (or anything else if you want); the two are fully complimentary.

                                  1. 1

                                    Ah - I assumed this was like Google’s Cloud Shell that gives each account in the cloud service a semi-ephemeral shell in a browser window.

                                    1. 1

                                      I think what you are describing would be Azure Cloud Shell (Imaginative name…). Azure PowerShell is simply a module you can install on your computer via the built in module manager in PowerShell. Simply type Install-Module -Name Az and it’s installed. Might need admin permissions unless you install it to a user context.

                                      1. 1

                                        Azure Cloud Shell is the hosted semi ephemeral shell in a browser window. Files you write in your home directory in it are persisted but processes you start close when you close the terminal, AFAIK.

                                        If you want to run PowerShell on not-Windows, there is PowerShellCore.

                                  2. 1

                                    If a shell launches a program and that in turn launches another program which generates output, the shell isn’t involved at all.

                                    Correct.

                                    I had another use case in mind: prog1 & and then prog2 &. Result: dumpster on your screen, combining outputs of both, while the shell could give these two programs different file descriptors and handle the output from there. Non-trivial but sounds feasible.

                                    new programs and a new communication mechanism.

                                    Yes. Meanwhile I plan:

                                    • Wrap most commonly used. The wrappers would provide semantic information.
                                    • Make this wrapping easy so that others could solve their own “problems”.
                                    • Maybe make some alternatives to existing utilities.
                                    1. 1

                                      I had another use case in mind: prog1 & and then prog2 &. Result: dumpster on your screen, combining outputs of both, while the shell could give these two programs different file descriptors and handle the output from there. Non-trivial but sounds feasible.

                                      Fair enough. In my spare time I’m writing my own shell, and I had the same thought about the trailing “&” operator not being ideal for today’s use. Typically when invoking a command in the background I don’t want to see its output. So I made a “&!” operator which runs it in the background and captures the output back to in-memory buffers owned by the shell, where stdout and stderr have different buffers. This means it’s possible later on to go and inspect the contents of a buffer if something went awry, but it won’t randomly preempt my next action.

                                      1. 1

                                        I’ll take a look at your shell.

                                        I was thinking about small text box for commands where one can see last few lines (updated as output is produced) and the box can be focused and expanded.

                                  1. 6

                                    One major argument I’ve heard is that in many environments you can’t bring your own shell. I don’t think this is the best argument, but it is also the argument I’ve heard for being proficient in vi and awk since they are tools you can guarantee exist on most *nix systems.

                                    1. 0

                                      Coming from startups background, I’m solving the problem for this environment first. No SunOS and the shell runs locally most of the time or at least on servers that you as Ops person (main target audience) control.

                                      1. 1

                                        I think that’s reasonable. Mind you anyone that has given me that argument, I’ve generally told just scp a static binary if it’s that urgent.

                                        One thing I would like is some GIFs of what you have in mind in action.

                                    1. 2

                                      I will be continuing working on changing the top level syntax in Next Generation Shell.

                                      The initial idea that a simple script should look like

                                      ls -l
                                      some_prog
                                      my_other_prog
                                      

                                      clashed with the reality, where most scripts that we wrote (at work) in NGS are actually comprised of mostly other things and not running external programs. After this realization, I looked into random bash scripts and confirmed: lots of

                                      • variables assignments
                                      • ifs
                                      • cases
                                      • loops

                                      In addition, considering the built-in functionality of Next Generation Shell, it will be calling less external programs than bash.

                                      Now, the change.

                                      Old style (top level is commands syntax):

                                      touch xyz # example of external prog
                                      {
                                        big_chunks.of_code() 
                                      }
                                      

                                      New style (top level is expressions syntax):

                                      $(touch xyz)
                                      big_chunks.of_code()
                                      
                                      1. 2

                                        Start working on changing top level syntax in Next Generation Shell ( https://ngs-lang.org/ ). I do sorry that instead of thinking deeper, when I started NGS it was “of course top level syntax should be subset of bash so that if you have just couple of programs to run it should be easy”.

                                        In practice, not only our scripts in NGS but others’ bash scripts contain a lot of other things besides running external commands.

                                        … and if you only run couple of external programs you don’t need NGS.

                                        I guess I will think about this a bit more before starting.

                                        1. 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.

                                            1. 1

                                              On related note, here is a script that parses the certificate chain, checks issuer against previous subject and prints the info in aligned table (or JSON if not on TTY) including in how many days the certificates expire.

                                              https://github.com/ngs-lang/ngs/blob/56dd0d6ca0224c3eedb75378c83828aa00633386/bin/parse-trust-chain.ngs

                                              Language: Next Generation Shell. I’m the author.

                                              1. 1

                                                Do you so a textual match on issuer and previous subject? Cool to see a shell with .map 🙂

                                                1. 1

                                                  Yes, the script compares output of the openssl command. Previous certificate issuer must be current certificate subject. The order is from leaf to root.

                                                  Not only map but a bunch of data manipulation functions :)

                                                  https://github.com/ngs-lang/ngs/wiki/Data-Manipulation-Use-Case

                                              1. 2

                                                I am preparing slides for the PerlCon 2019.

                                                I am giving there two talks.

                                                1. 4

                                                  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. 2

                                                    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. 2

                                                        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.

                                                  1. 1

                                                    I will continue working on NGS.

                                                    As part of working on what could be innocent “pmap() - limit number of concurrent threads”, I’ll continue working on Executor (new type) and specifically ThreadedExecutor (new type) so that when finished, one should be able to mydata.pmap(ThreadedExecutor(10), myfunc) to map mydata in parallel, using 10 threads.

                                                    The details might change but the general direction will stay the same.

                                                    1. 4

                                                      I like that you’re building out a language that puts these things front and center, but I wonder if building your own language (aside from it being incredibly fun!) is the most practical way to reach your goal? Contrast this method to say, creating a distribution of Lua that includes well appointed standard library support for common devops tasks, selected integrated primitives from lume or luafun, etc.

                                                      I admit that I don’t have a great solution for a CLI interface, but would point you to the work that’s happening in rash which uses hints to interpret shell commands or otherwise. In the case of a lua based thing like I’m suggesting it might be as simple as cat @filter(function(x) ... end, ls()) where the @ in this case flattens the returned array, and also indicates the next thing is Lua. The command interpreter then actually does something like loadstring("sh_run("/bin/cat", unpack(filter(function(x) .. end, ls()))")

                                                      1. 1

                                                        most practical way to reach your goal

                                                        • I think yes if you don’t want to compromise on syntax.
                                                        • It would also be difficult/awkward to have the types/multimethods system which I think is the best for the Ops tasks in any other language (except maybe Lisp)

                                                        solution for a CLI interface

                                                        I’ve got design for UI/CLI but it’s not implemented yet.

                                                        rash

                                                        https://github.com/ngs-lang/ngs/issues/280

                                                        cat @filter(function(x) … end, ls())

                                                        Somewhat similar. In NGS you can cat ${CODE HERE}) or cat $*{CODE HERE} (for splat). The syntax is consistent with $ substitution in strings and * splat in other places in NGS. And then using NGS types/multimethods system you can customize how to:

                                                        • Convert your type to command line argument
                                                        • How to run particular command (any customization)
                                                        • How to treat exit codes of your particular command (NGS knows several programs out of the box). If the exit code is not logically OK, NGS throws an exception
                                                        • How to parse the output of a particular command (NGS knows about JSON)

                                                        I can’t think about every other detail now but on intuitive level you can’t be 100% on the spot if you don’t build the language ground up with Ops tasks in mind. You can’t be 100% on the spot even if you do but that’s another story :)

                                                      1. 0

                                                        What does it have that PowerShell does not ?

                                                        This started 5 years ago, and Powershell was open sourced 3 years ago. I understand that during propriatery era of posh this made a lot of sense but not so sure now. Powershell is using .NET framework so you can literally create anything in it that is possible with C# - that is the feature level that is very hard to approach to by any foss tool that isn’t backed up by huge company.

                                                        One potential problem with posh is that it is far from fast shell. Not sure how relevant this is in majority of use cases.

                                                        Looking trough use cases I literally use everything there in posh today:

                                                        • Testing shell/cli/whatever with Pester (I even test WebApi with it), cross platform
                                                        • Build system with Invoke-Build, cross platform. Easy and powerful.
                                                        • Data manipulation is native in posh - ConvertTo/From - CSV/Json/XML/Yaml/HTML is there OTB. There are bunch of other functions too and even ConvertFrom-String which is total academic mumbo jubmo.
                                                        • Filtering is there OTB with select-object, where-object etc.
                                                        • Running processes in number of ways - with redirection. Even creating entire process inside of the script, compile it and run it.
                                                        • Parallel connects to servers and execute scripts….

                                                        And then there are bunch of things that aren’t in uses cases here: workflows, custom drives (anything as file system), universal package management, desired configuration, etc

                                                        Its very hard to get all that from 0.

                                                        Saying all that, I have high hopes on Guile and Guix - its backed up by GNU foundation and since its Scheme impl. it is even more powerful then posh … or it can be eventually. Adoption will probably be lower due to the language having strong math background.

                                                        1. 1

                                                          I’m onboard with all your points but my good is powershell far from consice . I know that it comes from having a systematically and well built up object model that is it’s strength. As you write Net in essence.

                                                          1. 0

                                                            It also comes with majority of Unix aliases as the original team came with that background.

                                                            This problem came into existence by force buy the NO ALIAS crew which includes MS and all MVPs. And its total BS. I fought their invalid arguments time and time again without any luck. I use default aliases majority of time so my code is as concise as it could be.

                                                            They think that Get-ChildItem is more readable then ls or Get-Process more readable then ps. They think that Get-ChildItem | Where-Object {} is more readable then ls | ? {}. Well maybe it is for n00bs but everybody else knows what ls/ps is since kindergarden and to n00bs themself any variant is equally new.

                                                            The only reason for not using aliases might be the pwsh (i.e. cross platform scripts) since posh 6 changed many of them (for the first time since first version of posh). For example ls now calls native thing instead of oo powershell thing.

                                                            1. 1

                                                              I just played around with Powershell a little and I’m not sure about this alias-or-not styling. I doubt that Powershell-ls is not exactly POSIX-ls or GNU-ls, so can’t you get confused there? I get confused between bash-builtin and coreutils sometimes.

                                                              1. 2

                                                                Alias confusion is not specific to posh. Yeah, posh-ls is nothing like posix-ls or gnu-ls but that is the whole point - we don’t need multiple ls’s and if we sometimes do, there are better ways to introduce them without breaking compatibility with existing variants (see proxy objects). Also, this is not specific to aliases - what happens if you have the same executable on path on different locations? Posh has good way to specify so called fully quolified cmdlet name which is then guarantied to call what you want on any system. This is better then for example knowing the exact path of executable which might differ from system to system.

                                                                Anyway, I gave on SO shortest version of your experiment. Its shorter then bash variant and way more readable.

                                                              2. 1

                                                                Maybe it’s a generational thing, those who learnet coding with autocomplete and those by reading manuals / reading source code. Then again I wouldn’t say that the powershell in itself doesn’t have that cool an autocomplete.

                                                                But I think that the argument for shorter names could be made! Less text would make the code quicker to read.

                                                                While coding myself I tend to prefer shorter code. So mv instead of move pv instead of player_velocity p0 instead of initial_position and so forth. To say that this would be worse is quite silly just take a look at all math or physics that ever has been written. What I’d really would like to see in code however is more usage of UTF-8 / math symbols.

                                                                1. 1

                                                                  To say that this would be worse is quite silly just take a look at all math or physics that ever has been written

                                                                  Indeed. Plus, its not only reading less, but also scrolling less, visually keeping related concepts closer together, easier way to combine expressions etc.

                                                                  To me, all that looks like millennial/politically-correct shenanigans and from the rest of us it is required to take on a babysitting.

                                                                  1. 1

                                                                    Exactly my thoughts,couldn’t have said it better myself

                                                            2. 1

                                                              I know a bit more now about PowerShell so I need to update the comparison section but meanwhile:

                                                              https://github.com/ngs-lang/ngs#have-you-heard-of-project-x-how-it-compares-to-ngs

                                                              1. 1

                                                                Nice comparison. Maybe its better to put in in a wiki so other people can easier contribute and reference.

                                                              2. -1

                                                                This appears to be cross-platform, while powershell is not

                                                                Edit: Apparently powershell runs on more than just windows. Oops.

                                                                1. -5

                                                                  PowerShell is x-platform (i.e. in what cave did you live past 3 years?). Toast is done in C but that doesn’t magically make it x-platform and, certainly, there are no windows binaries or instructions of any kind (nor it is tested on windoze).

                                                                  1. 4

                                                                    i.e. in what cave did you live past 3 years

                                                                    Apparently a cave in which I don’t pay attention to all the crap microsoft throws over the wall

                                                                    Also, no need to be an ass here. This isn’t ‘hacker’ ‘news’, reddit, or twitter. A simple ‘actually it is cross platform, see here’ would have been sufficient.

                                                                    Toast is done in C but that doesn’t magically make it x-platform

                                                                    The readme in the repo shows build instructions/tools for multiple platforms. It’s cross-platform.

                                                                    1. -9

                                                                      Apparently a cave in which I don’t pay attention to all the crap microsoft throws over the wall

                                                                      Still a cave :) And please, do not be melodramatic. It was a test, to see if guys here can tolerate something a 13 year old girls probably would or we can’t be honest here.

                                                                      Actually, such an attitude is already known and well understood. Honestly, “the cave” expresses the best what I had in mind, if you have trouble with that, probably grow up? Or exit the cave? Or LMGT4U. I do not use bunch of things (Oracle/SAP/OSX/whatever) but still follow the crappy tech, if anything, then to know its crappy.

                                                                      1. 5

                                                                        It was a test

                                                                        Don’t “test” people, that’s just called “being a dick and then not taking responsibility for it”.

                                                                        1. -1

                                                                          Don’t be a dick about it, I take a full responsibility! We all have our caves.

                                                                        2. 4

                                                                          It was a test, to see if guys here can tolerate something a 13 year old girls probably would or we can’t be honest here.

                                                                          I don’t think I want to visit the cave where the only way you can be honest with another human is by first insulting them. There are other platforms on the internet which are better suited for this method of ‘discussion’.

                                                                          1. 0

                                                                            It was an honest thing to do :). I wish people do it to me more often for my caves.

                                                                            It’s also more like adjective, not a discussion. In discussion you give arguments (which I did, I wouldn’t put x-platform multiple times in comment above if it wasn’t; I could equally argue that replied comment was insulting because it implies I am sloppy and my words can not be trusted).

                                                                            Lets end this with typical finalizer: lets agree to disagree ;)