3 ms·
I'm skeptical about academia being capable to help shell evolve. The paper is a good example why - they focus on justifying themselves and then on obscure acade
by effie 5y ago
I'm skeptical about academia being capable to help shell evolve. The paper is a good example why - they focus on justifying themselves and then on obscure academic ideas they like to pursue (POSIX formalization, highly parallel data processing) rather than usability for most users. Sometimes these align, but most of the time they don't.
Your description of Elvish is much better in that respect. I'd love more capable shell with modern advancements like types and static checking. However, I don't get why structured data over pipelines is useful. You can already exchange any kind of data over pipeline as string of bytes. Sender and receiver have to be aware of the format in any case.
- pxc 5y ago> I don't get why structured data over pipelines is useful. You can already exchange any kind of data over pipeline as string of bytes. The Elvish docs have a pretty good answer to this here[0], but I'll give my own answer, too. There are a few things. Structured pipelines spare you from having to do escaping and transformations in order to preserve structure.[1] It's also a natural complement to a type system. Some other next-gen shells call their structured pipelines ‘typed pipelines’ instead.[2] Structured pipelines also provide a nice mechanism for separating the visual/textual representation of data from its structure, so you can ‘convert’ values between different display formats without doing any parsing, in a convenient, extensible way. PowerShell has this with Format-List[3] and Format-Table[4], for example. This kind of pretty-printing isn't implemented in Elvish yet, but Kurtis Rader helped me outline one possibility in an open GitHub issue.[5] On some level, structured pipelines just mean that commands ‘native’ to the shell language (builtins and functions written in the shell language) all understand the same types or data structures. This means you can ingest data from some external format (JSON, CSV, TOML, a SQL result, whatever) and then use common tools. Nushell's first example for working with pipelines[6] hints at one of these benefits: you can use a single command, like `inc` to increment the value associated with a certain key in a map, with data that comes from any format, and `inc` doesn't have to know anything about data formats or parsing. Another way to think about it is that it lets pipelines have the same kind of type checking as functions called with arguments. In a typed language, you get type checking for your arguments when you call a function like (some_command arg0 (another_command arg1 arg 2)) but in a way, pipelines are an alternative to subshells.[7] If you want passing values through the pipes to be as robust as passing them as arguments, you need structured pipelines. You're right that if you are using a lot of external commands in a ‘raw’ way, you don't get to take much advantage of the structured pipeline. Imo PowerShell proves that in practice, if you have a big enough library ecosystem, you can leverage wrappers and ‘pure’ tools written in your shell language to get a pretty nice programming experience. — 0: https://elv.sh/learn/unique-semantics.html#motivation https://elv.sh/learn/unique-semantics.html#motivation 1: https://elv.sh/learn/effective-elvish.html#returning-values-with-structured-output https://elv.sh/learn/effective-elvish.html#returning-values-... 2: https://murex.rocks/docs/user-guide/pipeline.html https://murex.rocks/docs/user-guide/pipeline.html 3: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/format-list?view=powershell-7.1 https://docs.microsoft.com/en-us/powershell/module/microsoft... 4: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/format-table?view=powershell-7.1 https://docs.microsoft.com/en-us/powershell/module/microsoft... 5: https://github.com/elves/elvish/issues/1149#issuecomment-705705345 https://github.com/elves/elvish/issues/1149#issuecomment-705... 6: https://www.nushell.sh/book/pipeline.html#basics https://www.nushell.sh/book/pipeline.html#basics 7: https://elv.sh/learn/effective-elvish.html#prefer-pipes-over-parentheses https://elv.sh/learn/effective-elvish.html#prefer-pipes-over...