I’m trying to understand where you’d want to use PowerShell over Python. What’s something that’s in-between bash and Python?
Comment on What are the recommended scripting languages for complex shell scripts beyond bash?
MajorHavoc@lemmy.world 1 year ago
When I’m doing too much to maintain in bash, and not enough to merit Python, I use PowerShell.
My controversial take: if you’re looking for a better scripting language and haven’t tried PowerShell, you should give it a try.
It’s weird that Microsoft made a real shell.
PowerShell is actually open source, and it runs everywhere, including Mac and Linux. On Windows and Ubuntu, it’s already installed.
Powershell’s quality JSON and CSV handling is a huge game changer for quick scripts. The webrequest module is high quality. File operations are a breeze. Unlile bash, PowerShell can be formated to be pretty readable, when you care. Environment variable handling is mildly improved. Resusable code via modules is huge for quality of life.
PowerShell is the bash rewrite with lessons learned we all have wanted, but it’s not on a lot Linux folks radar because Microsoft published it.
thesmokingman@programming.dev 1 year ago
MajorHavoc@lemmy.world 1 year ago
Good question.
The Python subprocess module is a huge pain in the ass.
PowerShell has about 80% of the power and readability of Python, while actually being a native shell.
thesmokingman@programming.dev 1 year ago
Yeah, that’s fair. I was wondering if you’d call that out.
Popen
is rather opaque. I don’t know that I’d go so far as to try to remember yet another language to avoid it. I respect the decision though, especially with the portability of modern PowerShell.catastrophicblues@lemmy.ca 1 year ago
Thunderwolf@lemmy.world 1 year ago
This 100%. I liked bash scripting when I was in college. Took some time to actually learn powershell, and it’s been amazing. Steep learning curve in the beginning, but it’s worth it
aluminium@lemmy.world 1 year ago
not to mention that you have all the dotnet ecosystem at your fingertips. Wanna write a WPF application? Go ahead. You want to use ML.net? A bit clunky but doable.
ReluctantMuskrat@lemmy.world 1 year ago
Couldn’t agree more. It’s a great shell and scripting language. It’s object-oriented nature, native support for virtually every text format (csv, json, xml) and great libraries for others (yaml, excel), awesome regex and web/rest services support… it’s hard to beat and works on virtually every platform.
Too few people in the Linux community will even look at it though since it has MS name on it.
adept@programming.dev 1 year ago
Alternatively try nushell. Its basically powershell without ms
MajorHavoc@lemmy.world 1 year ago
Oh, nice. I’ll check it out.