‹ Back
2021/01/20

PowerShell: Built To Be Inferior

Let's not get things mixed up; PowerShell cannot compete with bash. By digging into PowerShell's history, we can see that the original architects were planning on improving the shell offering for Windows, but only managed to produce a slightly better shell than the older Windows command line while shunning standards that could have greatly improved the usability and compatibility of PowerShell for developers on any operating system.

To understand the philosophy of PowerShell, we need to look at it's origins. According to one of the early creators of PowerShell, Bruce Payette, "The core PowerShell language is based on the POSIX 1003.2 grammar for the Korn shell". In his book, "Windows PowerShell in Action", Bruce claims that PowerShell was "intended to fix the weaknesses in existing Windows command-line and scripting solutions". Standing on the shoulders of the mature Korn shell, Bruce and his team set out to improve the shell offering in Windows. So why is PowerShell so different than other POSIX compliant shells like bash, korn, or zsh?

Bruce had previously worked on Interix, a POSIX-conformant Unix subsystem for Windows NT. There was obviously enough experience in the early PowerShell team to work towards creating a shell that was both better than Windows command line, but also followed the POSIX standard. One marketplace advertisement for Bruce's Windows PowerShell book states "PowerShell replaces cobbled-together assemblies of third-party management tools with an elegant programming language and a powerful scripting shell for the Windows environment." Understanding his background with Unix shells, we can deduce that Bruce wasn't a fan of shoehorning POSIX standards into a Windows compatible shell. So instead, they decided to write their own standard. What could go wrong?

In this Hacker News front-page article, Matteo Guadrini walks users through installing PowerShell on Linux. His reasoning for such nonsense is that there is a shortcoming of bash in that "any output is a string and must be treated as such". He claims that in comparison, PowerShell outputs are objects that can be interacted with more programatically. However, Alexander Larsson expresses my thoughts very eloquently in his post "Rethinking the shell pipeline". Referring to projects like HotWire (now defunct) and PowerShell, Alexander states that "Although these are cool projects I think they step too far away from the traditional interactive shell pipelines, getting closer to 'real' programming, with more strict interfaces (rather than freeform) and not being very compatible with existing unix shell tools." It is precisely because bash doesn't dictate output formatting and typecasting that it is a much more flexible tool and allows developers to get creative with pipelines.

The original PowerShell team set out with good intentions to make a shell that was better than any shell they had used previously. However, in taking the path of least resistance and straying away from the POSIX standards that make current Unix shells so great, they created a "usage silo" (as Microsoft does) for a shell that is certainly better than Windows command line, but falls short of the usabilility, compatibility, and flexibilty of more mature shells like bash, korn, and zsh to name a few.


References
1, 2, 3, 4