81 points · by nailer · 8y ago · 55 comments
What's wrong with a good idea, even if, especially if, others are already doing it. It's not like stealing IP; it's about making tooling nicer.
I for one actually like this (granted, I use PowerShell regularly).
We use it in tooling for tons of things that would otherwise be done in Python and have no issues. Especially once you get it set up on Server Core and run the jobs in Cron.
I just don't get all the negativity towards it. There's a reason so many vendors are providing great PS modules for their products: VMWare, AWS, etc.
While there may be something “brittle” from time to time, in my experience this just means it was possible to tackle the problem with text when the alternative would have been to have no way to do it at all.
PowerShell feels like it wants everything to be structured perfectly, and “perfect is the enemy of the good” applies. Sometimes, I don’t care if there is a way to perfectly structure a particular input because many use cases just don’t have stringent requirements.
(The above is just a guess. I have zero scientific backing.)
What? PowerShell has been around for 11 years already!
Furthermore, a console scripting language was added precisely because many people were bending Microsoft's ear and asking for one. Say what you like about Microsoft, but they've got a long consistent history of responding to customer requests and feedback; granted it took them years to respond to this request, though (!).
All the resources in the world but absolutely glacial progress.
This is an erroneous description (which in fairness originated with Aditya Patwardhan of Microsoft not with the author of the headlined article here, who is just parrotting it). As Thomas Dickey points out, VT100s had no notion of multiple colours at all. This is not VT100.
* https://github.com/PowerShell/PowerShell/pull/6926
* https://invisible-island.net/xterm/xterm.faq.html#what_vt220
> It just feels… odd.
M. Pleau rightly points out the odd division of labour in the commands, here. Oddly, the conversion command not only generates an abstract syntax tree object, it also (but optionally) renders that AST into HTML or text with ECMA-48+T.416 control sequences. The "show" command then picks one of those two renderings from its input.
A more conventional division of labour would have been one tool to create the AST, another tool (or indeed tools) to render the AST into HTML and ECMA-48+T.416 text, and the usual already existing PowerShell tools to paginate/display HTML and ECMA-48+T.416 text.
(I add T.416, by the way, because the examples include T.416 SGR control sequences for indexed colour. Interestingly, they use it for a reverse video effect, for which there already was an ECMA-48 control sequence: SGR 7/SGR 27.)
bash (by Feross):
find . -type d -name "eslint-scope" -print0 | xargs -n 1 -0 -I % sh -c "(cat %/package.json | npx json version) && echo '(at %)'"
pwsh: $results = @{}
ls -recurse -filter "eslint-scope" | foreach {
$file = "${_}\package.json"
$version = cat $file | convertfrom-json | select -ExpandProperty version $results.Add($file,$version)
}
echo $results | format-list
I quite like the Powershell version, even though the syntax is unfamiliar. $results is a real hash object, the JSON tools are built in and formatting is up to you (you could have it output Excel or markdown if you wanted). I don't really like '_' as the iteration variable but otherwise I prefer it.First of all, there's no _ in sight in regular identifiers (99,99%). They're always CamelCase and Kebab-Case when including the verbs.
Secondly, it's case insensitive so you don't even need to go CamelCase. Just lowercase-itallthewaytothebank :D
Thirdly, it depends on what you want to do. You can use $_ and % and various Perlish shorthands for faster CLI usage, but it's your call. You don't have to mix, you can go full C# and just use the names or go full Perl and use the shorthands, it's up to you.
And fourthly, that bureaucracy makes things very discoverable. Now you're used to bash, but bash & ecosystem suck hard the first few months, until you accumulate the baggage, sorry, the knowledge to use them proficiently :)
The scripters, probably the more experienced folks would use abbreviations, shorthand and all-lowercase. The programmers like myself would predominantly use powershell on less-frequent occasions to glue our apps together and PascalCase and verbosity has already been burnt into our brains.
Powershell, like perl, took that philosophy that welcomed both parties to write code as they pleased.
But then powershells 2 and 3 and 4 came out, and all that stuff I learned in v1 became deprecated. And I wanted a powershell script that would just reliably run on any, say, windows machine 2003 or beyond. But when I google for something like 'how do I invoke an osql.exe query command? how to escape the quotes?', or, 'how to load a dll and having an adjacent config file and run a method?' I get so many different answers ranging from woefully misguided to version-specific to syntax so wildly different to the untrained eye they look completely different yet being effectively equivalent. I inevitably spend hours crawling google and cobbling together the bits that work cross-platform, document heavily and sit in amazement at how much work it took to do something one would think was simple.
It's a shame but my experiences with powershell as an occasional user have shifted from enthusiasm to seeing it as an arcance even punishing experience when I'm used to bash or python.
I hope this doesnt sound mean in any way, its just that when youre talking with a computer, words like grep/sed/awk and regular expressions bear a learning curve but once you get past that barrier it is much easier to communicate succinctly with the computer with what you really want to do.
I don't do much actual Powershell scripting, but I can tell pretty easily what this should be doing without going to man files.
That would allow your powershell script's object to be shown as pretty markdown tables.
Your post is a little like complaining over a functional programming language adding OO-features or vice versa and saying they are late to the party.
* http://jdebp.info./FGA/tui-console-and-terminal-paradigms.ht...
It's what you'd expect from 30 years of hindsight.
This isn't a walled garden any more than zsh is! It's an alternative shell. If you wanted bash on windows, you could have and still can get it from various vendors. Microsoft simply distributes a linux compatibility layer as a whole.
Still seems odd, as markdown by definition isn't really meant to be displayed in a terminal.
Markup: "the process or result of correcting text in preparation for printing."
This further confirms my suspicions about Microsoft's motives. If they wanted to make a `man` system, they would have made one, instead of working on markdown in the terminal which sounds quite trendy amongst Linux users.
So, where’s the equivalent offline bash script zero dependency sed awk contraption that is the reason we don’t get “nice things” in our trusty workhorse shell.
Or is the answer to “quick” offline markdown to html conversion on Mac/Linux “install pandoc”?
* https://softwarerecs.stackexchange.com/a/172
* https://stackoverflow.com/a/18517404/340790
Even though you and they missed that there is an off-line tool that is the basis for dingus.