Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Well, PowerShell docs are next to useless. Maybe the other parts are better. But I think this mythos of great docs for proprietary MS stuff is just that, a myth.


They're not as good as they were. The win32 docs are a a thing of beauty. I used to actively enjoy writing win32 code, in stark contrast to my experiences with Core Audio which is a similar sort of C API but documented by Apple, which is to say not at all. It is hell on earth.

Powershell, though. I don't know how you could even document powershell. It's insane.


Powershell is so weird to me. It never does what I expect it to do but it’s also full of powerful features. When looked at as a programming/scripting language it feels totally insane and disjointed. I just jump into C# or Python instead of dealing with it, because it just doesn’t make any sense to me as an engineer. But whenever I’m looking up how to manipulate some obscure bit of Windows, a cut and paste powershell one liner always makes an appearance.

Does anyone know if there’s any sort of reflective documentation or anything in powershell? Like, is there a way to ask it what arguments exist for a command?


Get-Help cmd ? But you can even leave out the arguments and it will query for the mandatory ones.

Also just FYI, it can fuzzy match on arguments, so you can specify only the first letter, or substring of the whole name. I think from this aspect, it is far superior to the UNIX tools.


I learned a lot of different programming languages. But I’ve never seen something as cryptic as power shell.

Sometimes I write the same script as PS and as bash script. For PS I usually need 3x more characters than for bash.

There are some features though that are really useful. But most of the time you won’t know about them when you need them.


> Sometimes I write the same script as PS and as bash script.

That's your mistake! Don't write bash scripts in PowerShell, and don't write PowerShell scripts in bash. Don't be surprised if the shopkeeper can't understand you, when you're speaking "French" by translating an English sentence word for word.

PowerShell is much more readable, terse, and elegant than Bash. It absolutely blows it out of the water... on Windows, where its inputs are the streams of objects that it's designed for. If you're trying to shoehorn text-based streams like in Linux into a PowerShell script, you're going to have a bad time.

See this earlier comment I made and the linked comments for some examples of PowerShell-vs-Bash: https://news.ycombinator.com/item?id=23423650


PowerShell elegant? Wow. No way. I've written hundreds of thousands of lines of PowerShell on Windows over the years. PowerShell is great for one-liners and very short scripts. It also has many cool hooks into the OS that makes things more comfy. That said, as soon as you need to write a modestly long script or need something remotely performant, you're going to want to reach for the nearest pencil to shove into your ear. I'll take Bash with all its limitations and arcane warts every time. I vastly prefer Python to either Bash or PowerShell for anything serious.

A sterling example of PowerShell's inanity is its brain-dead, ivory tower implementation of function return values. Anything that outputs to stdout gets added to the return value object for your function. Forgetting for a moment how non-standard and unexpected this is, consider that it’s impossible to completely silence many, many Windows commands CLI programs and utilities. Even with all the silent flags, output redirection, etc. it is simply impossible to silence stdout. What you end up with is... you just can't ever use return values in functions since it's so unreliable. This, coupled with PowerShell's atrocious performance (it's the worst performing scripting language I've used by far) instantly makes PowerShell a second class language for anything apart from very small scripts.

I've never heard anyone call PowerShell “terse” until today. It is currently winning the competition with Java for “Language whose inventor is most likely paid per keystroke”. PowerShell's arguments are extremely verbose and lines tend to become quite long as a result.

Disclaimer: I’m a recovering Windows Admin and haven't used PowerShell in a few years. I'm told that none of these problems have been fixed, but I don't know for a fact.


An observation I've made over decades of development in dozens of languages on many platforms is that humans often confuse frequency for speed. They assume that because they are making "many actions per unit time" that they are getting to their solution goal faster.

This is most obviously noticeable (to me at least), when debating ergonomics with people that prefer UNIX platforms, especially bash and text-based configurations. There was a study that showed that an action like moving a mouse to select a file feels slow because there's one slow movement, but selecting the file through typing at a console is perceived to be faster because there are many keystrokes in quick succession. People report that they prefer the latter for "the speed" even if it's an order of magnitude slower than the mouse if measured with a stopwatch.

The terse two-character commands of the UNIX world were an optimisation for teletype. As in a literal typewriter banging away on paper, at a rate of something like 10-30 cps. Modern (four-decade-old!) computers have tab complete, which makes this largely irrelevant.

Verbose commands are an enabler. They enable novice users to read scripts, instead of only masters being able to write them. Long, systematically and consistently named commands enable discovery through wildcard searches.

You cannot now -- nor ever will be able to -- do something like this in the Bash world:

   Get-Command Get-Az*Disk*
That's not an option because Bash doesn't actually follow the UNIX philosophy: it's not composable, it's not orthogonal, it's not designed, it's not self-consistent, etc...

It's a clever hack around byte streams that people have slowly built up over decades, evolving over time haphazardly. There was an 'sh' for example!

PS: You talk about using Python instead of scripting languages, which is actually a fine choice that I won't argue with. But have you considered writing "heavyweight" PowerShell modules in C#? As in, a proper DLL module? It's mindblowing how productive it is compared to trying to write a command line tool in C/C++, or any other language for that matter. Automatic input validation, input parameter name tab-complete, pipeline handling, all wired up with a handful of attributes...


> Verbose commands are an enabler. They enable novice users to read scripts, instead of only masters being able to write them. Long, systematically and consistently named commands enable discovery through wildcard searches.

For short scripts, this works great and improves discoverability for newcomers. This is the siren's song of PowerShell. However, the long commands and particularly the often unneeded/overly verbose parameters frequently creates a wall of text. This really hurts readability for everyone in all but the shortest scripts. Additionally, this wall-of-text that is all to common in PowerShell scripts is very intimidating to newcomers.

Regarding Tab completion in PowerShell, it frequently isn't terribly helpful. To work yourself up to something like Get-ItemPropertyValue is quite an incantation to remember, while being worse than a lot of bash ergonomics.

> have you considered writing "heavyweight" PowerShell modules in C#?

That is an interesting approach and would make life more bearable in MS-only shops. However, I can do the same thing with Python, which is superior to PS in so many ways and doesn't suffer any huge, glaring flaws (as PS does).


The performance problems, at least, have had some TLC applied to them and are much better in PowerShell core (the one that goes by pwsh), to the point that I don't hate using PowerShell interactively now.


Character count is not generally a good measure of the quality here. I think the biggest issues aren't the verbosity but how complex it can be to express some of the most common operations.

Filter is harder than it should be[0]. Same thing for map

[0]: https://www.concurrency.com/blog/august-2018/powershell-basi...


Bash is the worst abomination that has ever existed on the world. If a bash script has more lines than 2 (that is including the #! one), it sucks.


Yeah, I’ve tried a handful of Microsoft products and MSFT’s docs are ok for tutorials, but I’ve often found it hard to find useful reference documentation: e.g. the tutorial bits of Appcenter’s Codepush and UI Testing documentation are ok, but the reference documentation for both is ambiguous and/or incomplete.


With Microsoft, generally the documentation around the edges isn't great. The edges being the "Microsoft condoned solutions and generally anything coming from the Office/Enterprise side. On the Enterprise side they often have fantastic documentation but they have an amazing talent for making it unfindable.

It's like they hire an army of noob-level interns who churn out "getting started" articles, with the end result being that you have to dig 5 pages deep into Google result to get meaningful documentation (4 of those pages are of people asking questions on Microsoft Connect or the-site-that-shall-not-be-named or something).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: