3 ms·
I am a big fan of Powershell, yet...and there had to be a "yet", now didn't there?...the Bash based criticism is well grounded even if not always perfectly arti
by brudgers 11y ago
I am a big fan of Powershell, yet...and there had to be a "yet", now didn't there?...the Bash based criticism is well grounded even if not always perfectly articulated.
I see it this way, the great thing about Powershell commands is that I get back an object. The great thing about Bash commands is that I get back text. The object is great because I don't have to parse it. The text is great because I can parse it.
The downside of Powershell is that if I don't have technical expertise in regard to the object a command returns, I have to go read deep into a manual to figure how I can do something simple. The downside of Bash is that if I have deep technical expertise about the text that is returned, I still have to parse it as text to do something simple.
The high level abstractions of Powershell are better suited for dealing with known processes and contexts where I care about the semantics of the returned value. The low level abstraction of text is better for dealing with unknown processes and contexts where I don't really care about the semantics of the value.
- aembleton 11y agoI've never used Powershell. Is it possible for Powershell to output the object as JSON so that you can see what you can read from the object?
- kuma4 11y agodir | ConvertTo-Json dir | ConvertTo-Html dir | ConvertTo-Xml dir | ConvertTo-Csv
- brudgers 11y agoIn the world of Powershell, reflection would be the way to go because then I still have an object. A rough analogy would be the window object in Javascript where I call `window.open(something)` directly. Serializing a value returned by a Powershell command to JSON eliminates being able to call `returned_value.some_method(something)` because converting it into JSON puts me in the world of text and parsing. At that point, I either know the name of the method I'm looking for or I don't. In the first case the conversion to JSON doesn't do me any good because I can just call the method directly using `object.method(value)`. In the second case, it doesn't do any good because I don't know the method I want. Reflection looks more like this: http://stackoverflow.com/questions/9952391/use-get-member-for-reflection http://stackoverflow.com/questions/9952391/use-get-member-fo...