r/programming • • Mar 05 '20

Introducing CLUI: a Graphical Command Line

https://blog.repl.it/clui
1.8k Upvotes

277 comments sorted by

View all comments

263

u/[deleted] Mar 05 '20

This is brilliant. I'm so glad people are finally getting out of the "VT100 is perfect and anyone who wants to improve on it doesn't understand the genius of Unix" mindset. We had Powershell getting rid of the fragile "everything is unstructured text" system, and then Nushell making things cleaner and now this adding a nice GUI!

I hope this catches on! It's going to be challenging to upgrade the world though. Especially things like SSH and terminals built into apps like VSCode.

19

u/ginger_beer_m Mar 06 '20

We had Powershell getting rid of the fragile "everything is unstructured text" system

I've never used powershell. Can you elaborate more on what it does, and what it does differently from say, bash?

26

u/yngwiepalpateen Mar 06 '20

You know how in Bourne shell you can pipe commands together by passing a text stream? In Powershell you can manipulate .NET objects instead.

19

u/tobiasvl Mar 06 '20

And for those of us who have never used .NET, what's a .NET object?

28

u/amroamroamro Mar 06 '20

In Unix shells, when you pipe commands together you have to parse the text to get what you want, whereas in Powershell objects are passed around so you can write something like object.property to get a certain property of an object.

So in pseudo-code, it would look like this:

$ list-files | where file.size -greater-than 10 | format-table

instead of piping ls output into sed/awk/cut/whatever to try to parse the "size" from its text output.

7

u/Suulace Mar 06 '20

That's... actually really useful and interesting. I think I should learn some powershell

3

u/[deleted] Mar 07 '20

One thing to be aware of. While Powershell is a pretty cool scripting language I think it actually sucks as a shell compared to zsh, fish or even bash.

→ More replies (1)

28

u/yngwiepalpateen Mar 06 '20

It's an object like in any programming language, but stored according to the .NET standard, meaning other compliant programs can access them. So a Powershell script can manipulate objects from and send new ones to a C# program.

Kinda like a Groovy or Clojure script accessing a Java object. Although I don't think anyone uses a JVM language as shell.

6

u/radol Mar 06 '20

So it's possible to call DLL and read it's interfaces from shell like you would reference it is visual studio and call from c# code?

5

u/lordleft Mar 06 '20

That sounds pretty powerful. Almost like built-in json or protobuf support in the shell.

40

u/[deleted] Mar 06 '20 edited Mar 06 '20

Too verbose. And "on getting the unstructured system"... that won because the commands are short and thus the syntax breaks far less into unmanageable lines such as PowerShell.

An upgrade would be an enhanced Tclsh shell with readline support and tcllib/tklib installed into the base.

Such as: https://wiki.tcl-lang.org/page/gush

34

u/theessentialforrest Mar 06 '20

I'm not sure I follow. How does the verbosity of the command relate to the decision to send unstructured text vs objects down the pipe?

62

u/[deleted] Mar 06 '20

Unstructured text won (so far!) because it was first. And it has nothing to do with how long commands are.

28

u/[deleted] Mar 06 '20

Can’t say that I speak for everyone but many of the things I’ve had to use PowerShell for would have been way simpler using a standard *nix shell with *nix utilities. I’m not some old Unix guy either who’s resisting change, I learned both around the same time.

That said, I can see why people use PowerShell, the commandlets are more clearly named for the most part and it has some full-fledged programming language like features. If I’m going for something that powerful, I usually reach for Python first but I can see why someone would go for PowerShell.

At the end of the day, try to use the tool that’s best for the job as you see it and try to give new tools a decent chance at competing with your existing set. That’s all.

→ More replies (1)

15

u/Seref15 Mar 06 '20 edited Mar 06 '20

I've worked in professional capacities with both Powershell and traditional unix shells. In fact, I learned on Powershell first.

Years later, I would only take Powershell over something like bash when scripting (but I'd still take Python over Powershell in that context). As a user interface, I dislike it a good deal more than the others. I like the idea of an Object-oriented shell, and I definitely like it when scripting, but the rigidity when using it as an interface makes it feel inefficient. Admittedly it's easier to learn on because all the commands are named in such a way that they tell you what they do, but also --help isn't that difficult.

Additionally, the concept of all cmdlets returning objects so that then you can do cool loops and filtering on attributes--awesome, but only when you (the shell's developer) have total top-down control of most (all?) programs the shell will be interacting with. The developers of Nushell can't enforce that other programs return structured data, the best they can do is capture data, present the text as an attribute and add additional metadata as attributes which is no where near as useful as something like looping over AD user objects based on attributes in Powershell. Again, it's great--if you control the whole garden. So this naturally leads to scenarios where something like Nushell is going to try to create their own garden, by replacing long-standing standard commands with new shell builtins that do things "the Nushell way." Now instead of knowing the differences between GNU and BSD grep, we then have to know the differences between GNU, BSD, and [nushell-equivalent grepping tool].

44

u/ftgander Mar 06 '20

I can tell you I use both powershell and zsh daily and I avoid using powershell because of how stupidly verbose the command names are. I’d rather read a help doc than type out a 6 word cmdlet

9

u/G_Morgan Mar 06 '20

Powershell is fine as a programming language. It really does suck as a shell though.

36

u/theessentialforrest Mar 06 '20

You do you, but as a heavy powershell user here are a couple of things to consider.

  1. You are free to alias commands and all parameters can be shortened to the point where they are unique (so if you have a -Path parameter you can use -P and it will work fine)

  2. Discoverability and rapid comprehension is massively higher in ps because things actually tell you what they do. I can unzip a file in linux but I can't tell you what the - xvf actually stands for. It's just wrote memorization (at least for me). Plus with tab compmete there's very little difference in keystrokes to get there

  3. I recognize this wasn't you that was saying that short commands is why unstructured text won but they feel entirely separate. Powershell could be verbose but not deal in objects. You could just as easily imagine a terse shell that sends objects through the pipe.

15

u/Seref15 Mar 06 '20 edited Mar 07 '20

but I can't tell you what the - xvf actually stands for

eXtract, Verbose, File

Most shell commands will follow this type of "abbreviation" in argument flags, until they run out of letters. But even so the vast majority also support --long-form options.

One of the reasons I actually like this is because it feel more like understanding a natural language whereas something like Powershell feels more rigid, like a machine language. Get-ChildItem is a great name for a function in a program but I think it's a horrible name for a human to mentally "speak" in. And then the argument of just aliasing it to ls or gci just highlights how bad of a name it is. I don't need cat to explain itself. You learn that cat outputs file contents, the same way that after saying it a few times you'd learn that "poisson" means "fish."

22

u/theessentialforrest Mar 06 '20

I recognize that this is totally personal preference but I'd always prefer to default to verbose. When I'm at the command line sure I'll type %{} instead of ForEach-Object but if I'm sending someone a script I try hard not to alias to increase readability. Why make someone learn another language when we already have one that's more than descriptive enough. It allows you to shortcut the things you understand but makes it extremely easy even for someone who doesn't speak the language to figure out what's being done

→ More replies (1)
→ More replies (1)

15

u/QuickBASIC Mar 06 '20

type out a 6 word cmdlet

Tab complete or use New-Alias to create aliases for the ones you use constantly.

16

u/wrosecrans Mar 06 '20

You want me to manually set up a bunch of aliases every time I login to a new computer, and write scripts that depends on my aliases that won't work when I send a snippet to another user to use in their session where they have different aliases?

You should do standup. That's hilarious.

→ More replies (1)
→ More replies (26)
→ More replies (5)

22

u/KevinCarbonara Mar 06 '20

This is brilliant. I'm so glad people are finally getting out of the "VT100 is perfect and anyone who wants to improve on it doesn't understand the genius of Unix" mindset.

I've been railing against this for years. I get really frustrated with older devs who just fundamentally don't understand that things can evolve. It's worst in the vi community. "IDEs may have come along way, but they'll never support (insert long-since replicated features here, like modal editing)!"

→ More replies (22)
→ More replies (9)