PowerShell Complexity

PowerShell Complexity from DOTNET Object System
PowerShell is based on DOTNET Object system.
〔see PowerShell: Object Type, Properties, Methods〕
This is a big source of its complexity, because, since each value is an object, it means they have methods.
So, computation are done by method call syntax obj.met()
.
But this make it very inconsistent with many shell syntax and way of operations.
For example, a string, can be split to a array in the following ways
- by method
"a.b".split(".")
- by an operator
"a.b" -split "\."
For example, here's how to create a ordered hashtable.
$dict = [ordered] @{"a" = 1; "b" = 1; }
The [ordered]
there, is not a dotnet syntax proper, nor typical PowerShell.
It is a PowerShell added syntax.
For example, here's how to create a array of int.
$myar = [int[]]::new(3)
There is no other way except this. It involves, dotnet type, casting, and dotnet static method.
So, you have a bewildering complexity of syntax, and burden on user about which one is the correct choice.
PowerShell Complexity

Been coding powershell kinda semi seriously for a year now. I'd say, it's fairly complex. Far more so than golang, python.
It's complex for 2 major reasons, i think. One is that, the whole thing work on objects, each is object a DOTNET object hierarchy. As opposed to unix just strings.
- So, everything is a object, has methods, and properties.
- But more than that.
- The object that powershell deals with, is more complex than java or python's OOP object.
- Because the object in PowerShell has lots types, very elaborate.
- Not just methods and properties.
- e.g. a special type of property or such called
noteproperties
.
- Then, each value, also have very elaborate types.
- Not just primitive types like int float string.
- But u got file object, object for dir, object for enum types, object to represent type, type for special things...
- Perhaps hundreds of types.
- Then, you also have collection type, which include hash table, dictionary, array, array list, etc.
- When u deal with objects in a shell lang used in terminal, u immediately got the issue of display presentation.
- So that adds a layer of complexity.
- Text output are not really text.
- They are object that got converted to text for display purposes in some automated way.
- The detail of this, is complexity.
- But powershell, is also fully backed by dotnet.
- As far as i know , u can call every dotnet method, and every value is a dotnet value type, meaning, u have the complete access to dotnet methods of that value/object.
- This makes pwsh a full bloat with power, that i think may even surpass python.
- This also means that, there are many ways to do the same thing.
- U can actually almost just call dotnet functions as the main way u code pwsh, and or, for every value, u can use dotnet methods, but u can also use powershell cmdlets.
- And, another major reason of complexity is that, pwsh is a shell lang, meaning, it has a linearized syntax to let u type things and work things interactively.
- That is, reduce nesting in syntax, or many ways to omit brackets or params.
- This, linearization of syntax, necessarily made the syntax very complex, with many variations.