Windows PowerShell : Variables, Types, and Operators

Play Windows PowerShell : Variables, Types, and Operators

The Discussion

  • User profile image

    I don't like the choice of the relational operators. Everything in Powershell flows and looks natural, except these relational operators. Less than, equals, greater than, etc. Instead of using the natural and easy to remember and easy to type <, >, <=, >=, != and == symbols, which every programmer, from the beginner to the advanced, knows, you used the counter-intuitive -lt, -gt, -ge, -ne, etc, strings. I know, I know what you are going to say: "Other shell languages use similar things." But isn't this what Powershell wanted to change, namely the mess of the other shells. Instead of using inconsistent esac and fi and other end of block delimiters, Powershell simply uses the highly intuitive { and }. Very good! Instead of words which one has to memorize, Powershell uses punctuation like () and [] and , which is common to most imperative languages. Easy to learn and also easy to reuse in other programming tasks using other languages. Why then have you used these strange combinations for the relational operators? If it was for compatibility with the < and > operators in cmd.exe, it is not worth it since < does not work in Powershell anyway and > is problematic since many time one has to change the encoding anyway and so one has to type "| -encoding ascii filename". In any case, > piping simantecs is unnecessary, ambiguous and less flexible than the "|" to an "out-something" commandlet. Also, < and > piping does not fit into the simplistic model of Powershell which does not use extra operators when not needed. So, there is really no excuse?

  • User profile image

    I would also be interested in knowing why they chose -eq etc. instead of the standard operator set.

  • User profile image

    A "crapload of operators" that sounds like a lot. Big Smile

  • User profile image

    I was in the v1 beta group back in MSH days.  We fought over this for months.  As both an (ex) ksh guy and a c-style programmer, I was on the side of using the normal operators like yourself.  The real hangup was the ">" redirect operator (and to a lesser extent the  ">>") as already taken.  DOS and unix legacy scripters won, because the common use of that operator is well understood and they felt it would be too much of a change.  It was really a SHELL -vs- language argument and a choice needed to be made.  Not being able to use ">", also ment they could not really use the others ("<=", "==", etc) because the symmetry was now gone.   Personally, I still think they made the wrong choice, but understand the other side.  It would have been better to have the normal programmer operators and use something else for io and let the io folks deal with the change.  Now with LINQ logic needing those operators and the fact that people want PSH integrated with things like VS and others , I am guessing some folks may be kicking themselfs.

  • User profile image

    Windows Power Shell its very good



    Free sms kostenlos

Add Your 2 Cents