this post was submitted on 23 Jan 2024
200 points (95.5% liked)
Programmer Humor
32479 readers
253 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Look what they need to mimic a fraction of our power.
Text Based OS > Object Based OS
Everything that is wrong with PowerShell in my opinion is driven by the Object Oriented nature of Windows as an OS.
Since everything in Linux is text, grep is king.
Don’t you think immediately getting the property you’re interested in from an object is easier and more readable than first grepping some output to get the line you want and then removing the leading and trailing garbage on that line manually?
I thing PS scripting would be much more fun if the words weren’t so annoyingly long.
That's not what we do, though. Give me a more concrete example, and I'll let you know how I would expect to do it in a nix environment. I'd be curious to compare. Since I have zero experience with powershell, I am not really sure what to expect. The couple times I've glanced at a powershell script it looked awful, but I could be falling into Paul Graham's blub paradox there. OK, I don't think so, but maybe.
For instance: Get the temperature of the “Composite” sensor from this output:
Without a cryptic awk incantation that only wizards can understand, that would be:
sensors | grep Composite | grep -Po 'Composite:.*?C' | grep -Eo '[[:digit:]]{1,2}\.[[:digit:]]'
I think I misunderstood you, when you said "manually", to mean as a human intervention in the process. What you're showing here is an extra processing step, but I wouldn't call that manual. Just want to clear that up, but I'm still down to play.
Instead of three greps, you could use one sed or awk. I don't think there's anything particularly wizardly about awk, and it would be a lot less cryptic, to me, than this chain of greps.
But a much better idea would be to use
sensors -j
to get json output, intended for machine reading, and pass that tojq
. Since I don't have the same sensors output as you, I'm not sure exactly what that would be, but I am guessing probably something like:I look forward to seeing how you would do this in PS. As I said previously, I don't know it at all, so I'm not sure what you're comparing this to.
Yes, it’s not manual by the dictionary definition, but it is an extra step. This is another meaning of manual in my particular bubble [Edit: that I didn’t think to specify].
This is my initial point, exactly. Dealing with objects is way easier than using the ‘default’ line-wise processing. Only Powershell made that the default, while in Linux you need to hope that utilities have an option to toggle it on – and then also have
jq
installed to process the objects.[Edit, since I forgot to answer your main point:] I don’t program in PS. I don’t like the verbosity. But I do think MS has a point in pushing objects as the prime unit in processing instead of lines.