← Back to context

Comment by majkinetor

4 hours ago

Powershell is so good that I find it strange it didn't get to be default at least in some Linux distributins (or some proper fork/redo of it). I even used it for integrative feautures for some of my state projects serving millions of user. The fact that I have proper language, designed for shell, very efficient, not needing an IDE or anything, is quite liberating.

I use it for all kinds of stuff. Here is an example that creates MusicBrainz collection from my local audio folder, solving the browsers proof of work in between: https://github.com/majkinetor/musicbrainz-userscripts/tree/m...

If I am nitpicking, performance could be better, although MS did a lot in previous years and even that just in theory as I was never really blocked by that. But if it could be performance beast too, I would think we can stop researching new shells and just use it everyhwhere.

JSON support is amazing - you don't learn anything new like with jq, it just works. Selecting stuff is amazing, I love it more then SQL. HashTables are epic for configuration (you have a real language in it, unlike in lets say YAML).

Scripts that look horrible in bash are few lines of beautiful in pwsh.

If you didn't try it, or didn't give it a chance, you are missing out for sure.

All of the alternative shells are in a tough spot. Bash is lousy, but it is installed everywhere. If you are going to use an alternative, why not a more widespread tool (Python, Perl, etc) that can potentially do more than piping commands together.

I believe nushell is the closest Linuxy Powershell implementation with structured data.

https://www.nushell.sh/

I must ask, do you not find Powershell's commands to be too huge and unwieldy to easily type? Or do you use autocomplete often enough that having to write complex camel case with hyphens for every single command is not a problem? That's where I trip up when writing anything for Powershell.

  • Yup. IMO the syntax is unusably awful for interactive sessions. Scripting, where you want to come back a year later and tell at a glance what it's doing, sure. Not for daily driving though.

    It feels like the difference between old-timey classical English vs street talk. "Greetings, dearest companion, how fare you this fine Autumnal day?" is a lot of syllables for someone you're familiar with. "Hey! Enjoying the day?" says the same thing, but conversational. There's a time and place for the former, mainly when writing dialog set in 1500 or something. I'd much rather say the latter when bumping into my neighbor at the cofee shop. Similarly, I could see why someone might want to write

      Get-ChildItem -Filter *.txt -Force
    

    in a script so that it's clear-ish what that means later, but if I'm spending my time in a terminal, I'd vastly rather learn what

      ls -la *.txt
    

    means. It's terse to the point of inscrutability, and not beginner friendly at all, but once you type it a few thousand times it's second nature.

    All things considered, I'll stick to Fish, thanks.

    Edit: Related, but once I learned how Unix shells typically expand globs, that feels like the right layer for handling that and similar other things. "ls" doesn't know what a glob is. When you type "ls -la .txt", the shell* expands that into a list of matching files, like "ls -la foo.txt bar.txt baz.txt", then "ls" operates on each one of those in turn. You don't have to teach every program how to interpret globs. The shell has to learn that, once, then every other program automatically benefits from it. Type "echo *.txt" and you'll see the list of matching names. Echo has no idea what that means. It only knows that it got a list of worlds to write out with no idea where it came from. I think Bash/zsh/fish/etc. do this the right way, and that implementing that in every tool is the wrong way. It just feels weird and inefficient and prone to have odd, subtle deifferences.

  • No. I use aliases so its as quick as with bash, but I am faster as I don't have to lookup for params due to fantastic discovery and usability features.

    With longer commands, auto complete is also viable. I hate some long forms, like % vs ForEach-Object and ? vs Where-Object, its just ludicrious that someone would insisit in using full forms of those.

    Things like `ps | ? name -like w*` or `1..10 | % { irm https://.../$_ }` can't really get shorter and I use them all the time

    Auto complete on params is epic. Type -e and ctrl space to see all params starting with e along with their aliases. Verbosity is good thing in that case, as -ea doesn't mean much when you are new to this.

        ps -e<CTRL+SPACE>
        ErrorAction    ea             ErrorVariable  ev
    

    The verbose practice is not meant for interactive use, but for sharing scripts.

It's not really a fit culturally. For example the syntax aesthetics are offputting for people coming from *ix.

  • That is just common invalid trope. You can make scripts look shorter and more "culturally fit" than bash. Its just that people prefer more verbose variants for some rasons (I don't). There are automatic converters too. The legit reason is to make script cross platform, as that is easier with verbose form.