3 ms·
Powershell's syntax is so fucking weird and verbose. I guess if you live in Microsoft land all day and write code in C# it's fine, but I would really like it if
by pdntspa 2y ago
Powershell's syntax is so fucking weird and verbose. I guess if you live in Microsoft land all day and write code in C# it's fine, but I would really like it if we all could collectively agree on one set of syntax rules. I don't even care what they are. But as a polyglot I am so sick of having to learn yet another syntax. cmd.exe does everything I need to and batch is actually kind of flexible.
Also, I don't know what it is with shell programmers (and I've worked for one) but bash syntax is similarly insane. I am so glad I've never had to write an init.d service because 20 years into my linux career I still can't read that shit. Like I can launch and fork a process in like 10 lines of C, but it's five pages of gobbledygook shell script?
- gwervc 2y ago> I guess if you live in Microsoft land all day and write code in C# it's fine I write C# daily but I'm not fine with powershell syntax. It seems harder than it should be.
- Aloha 2y agoI always joke and PowerShell must have been created by someone who types 300 WPM ;-)
- doubloon 2y agothats what Copilot is for. You just go "please tell me how to work this grep | awk command in powershell"
- dpkirchner 2y agoIs there a cmdlet that will do this automatically?
- pdntspa 2y agoI kind of see these AI tools like a superhero's toolbelt -- great, when it's on you. But one doesn't always have the luxury of internet access. It is best not to overrely on AI, or any cloud service for that matter.
- doubloon 2y agoif you dont have internet service and you are on a windows box, you are SOL in the first place.
- pdntspa 2y agoThis is an absolutely awful attitude. All you need to do to witness lack of internet yourself is drive a couple hours' north of San Francisco. Now imagine that a huge chunk of the world is far worse off than this.
- doubloon 2y agoif i was in an environment without internet, i would be using open source software.
- pdpi 2y agoAnd, presumably, I'd prompt copilot to write those things for me... from within powershell? Using what command? Generative AI can do a lot of fun things, but we're talking about a but it does not belong anywhere near an interactive shell.
- supernovae 2y agoon windows copilot is built into the task bar with a popout window on right side bar showing output that can work with clipboard. You can talk to it, copy in an image or screenshot and ask for details too. if you prompt for PowerShell it gives you a code block with a copy button. (oh and also reference links to learn more... which is much nice)
- RajT88 2y agoI've had some great success with C# and Powershell and Copilot/ChatGPT. It writes impeccable code - but doesn't always get the question right. I've found most of the time, even when it gets the question wrong, it turns you onto the right path forward. Definitely has saved me a lot of time researching things.
- supportengineer 2y agoI always thought Lisp or Smalltalk might be good for a shell.
- robomartin 2y ago> Powershell's syntax is so fucking weird and verbose. Yeah. At a certain point it is almost impossible to internalize that complexity. As someone suggested...in the era of AI, this might not matter at all.
- pdntspa 2y agoAI is many things, but deterministic with natural language it is not.
- mr_toad 2y ago> bash syntax is similarly insane At least it’s terse, which is good when you’re typing commands on the fly on the command line. PowerShell on the other hand is so unwieldy on the command line. Even the pervasive use of case slows down typing.
- MatejKafka 2y agoWith aliases, powershell can be quite terse as well, and since it's case-insensitive, you can just type everything in lowercase.
- MatejKafka 2y agoE.g. instead of the script presented in the article: (Get-ChildItem -Filter '*.txt' | ForEach-Object { $_.Length } | Measure-Object -Sum).Sum You can do ls *.txt | measure -Sum Length | % Sum
- faeriechangling 2y agoIt’s weird on account of dealing with a legacy of Microsoftisms, including from cmd.exe which is why it has to use -gt as a comparison operator and not >. Batch is not nearly as flexible as PoSH although the interpreter still boots faster so I use cmd.exe all the time.
- RajT88 2y ago> Powershell's syntax is so fucking weird and verbose. You're not wrong. I think it's that way because of trying to increase readability. Best practice for Powershell cmdlet development is verb-noun. Of course they throw that out the window with aliases. Examples: wget and curl both are aliases for invoke-webrequest iex is an alias for "invoke-expression" - which lets you execute a string as powershell code in your same session (note: I originally wrote scriptblock, which was incorrect - otherwise something I wrote this week wouldn't work at all, due to change of scope). This ability gets me out of a lot of weird jams. The other thing too which makes it so weird is that it is built on top of .Net. The overarching principle of Powershell is that it's your Windows swiss army knife. You can access .Net classes by loading the assemblies. I have on occasion built a small WinForms app in powershell. You can create and invoke COM objects (new-object cmdlet). > But as a polyglot I am so sick of having to learn yet another syntax. Personally, I try to avoid "language specific sugar" when I am writing sample scripts for people (I am in a customer facing role). But goddamn I love the shorthand way you can do a for loop in Powershell using the range operator: 1..100 | % {Write-Host $_} > cmd.exe does everything I need to and batch is actually kind of flexible. OK, so you haven't really gotten to know Powershell very well if you're saying things like this. lol Scripting in batch files is like living in the dark ages. They are "kind of flexible" whereas Powershell is "very flexible, most of the time". And that "most of the time" caveat is no longer there if you are on the latest powershell (which doesn't work with the ISE as ISE is 5.x only, and the way of the future is the universal PWSH). My biggest gripe was fixed I think in Powershell 7, which was manipulating files with grave marks in the name. I build a lot of stuff in Powershell, as you can probably tell. Given all the interop stuff it has, once you know how to use it all, the point where it makes sense to build it in C# is farther down the line than you might think.