Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Any (Active)perl influence on PowerShell?

by sg (Pilgrim)
on Sep 24, 2007 at 04:22 UTC ( #640652=perlquestion: print w/replies, xml ) Need Help??

sg has asked for the wisdom of the Perl Monks concerning the following question:

Microsoft, who I gather funded ActivePerl for about 3 years, has a new shell (called PowerShell) and a new console/terminal (called PowerShell Plus) Variables in the PowerShell begin with '$' -- but this is just a highly superficial resemblance to perl.

Question 1: Is there any meaningful impact of perl on PowerShell, and if so, what?

Supposedly commands in PowerShell are piped by passing objects (rather than streams of text); I don't know enough to say what that is let alone to say whether that is good or bad; but I guess instead of piping/streaming textual data, it merely pipes a pointer to the structured data.

Question 2: Does PowerShell allow that notion of piping entire objects to be imparted to any script or will a scripting language have to do something special to support that notion?

  • Comment on Any (Active)perl influence on PowerShell?

Replies are listed 'Best First'.
Re: Any (Active)perl influence on PowerShell?
by mr_mischief (Monsignor) on Sep 24, 2007 at 05:30 UTC
    From some example scripts, I'd say that Perl is one of several direct and indirect influences. For comparison, look at how they use Perl in their examples here here.

    There's even an example of a grep-like tool that looks like Get-Shapes | Where-Object {$_.Color eq "Orange"}, complete with '$_'. That's found in the PowerShell Manual and the Where-Object doc is at the 'cmdlets' docs.

    There's also some PHP touches to the syntax that I see. It's also inspired by actual shells, as you can dot-source other files.

    It appears that anything written in PowerShell is going to emit objects, but that it's smart enough to handle text instead when confronted with scripts in other languages.

    The interview with the chief architect of the package, Jeffrey Snover, says he likes several languages, including Perl, but that they all have shortcomings he's trying to alleviate in PowerShell and the related utilities.

    JS: Like most people, I have a love/hate relationship with the existing tools. I love the interactivity and composability of KSH/utilities but I hate their inconsistency and the need to do text parsing. I love the power and programmability of PERL and TCL but I hate their idiosyncrasies and their lack of a good interactive experience. I love the consistency and production-orientation of VMS DCL and AS400s CL but I hate their composability model. I love the UNIX model of surfacing everything through the filesystem but I hate the anemic semantics of the filesystem.
    I have to say, the language itself doesn't look bad. PowerShell, the terminal, and some other tools are aimed primarily at Windows admins, though, and not at general-purpose programming tasks. The docs, examples, and interview responses all seem to point to WSH, VB for Applications -- er, I mean VBScript, and such as the comparable technologies. I'd expect about the same support for developers as with those toola -- that is, not much compared to Visual C++ and Visual Basic .NET environments, documentation, and updates.
Re: Any (Active)perl influence on PowerShell?
by KevKev (Acolyte) on Sep 25, 2007 at 22:46 UTC

    There is significant influence in Powershell from many other languages as mr_mischief points out. There are a few things that I'd like to expound upon that I believe mr_mischief missed or didn't mention.

    As he says, powershell if not a general programming language. For applications use one of the .Net languages. However, that is not to say Powershell is lacking in capability. Where power is required, power can be found. If powershell does not include functionality, you can leverage existing .Net Libraries or COM objects. If the library doesn't exist it can be written in .Net as a powrshell cmdlet or as a normal .Net library and be used from powershell either way. As such, winforms can be done if that's what you want/need it's just not as fun from powershell as it is from .Net. But then again, based on my experience non web GUIs aren't fun from perl either :)

    Never underestimate the beauty of everything being an object. Piping a directory listing to where-object and filering on random properties can be a very useful thing. Or get-service | where-object %{ $_.status -eq running } These things can be done by processing the text output but it's not as easy or intuitive and can be a major pain when presenting output to a user.

    Powershell is being positioned as the underlying administrative architechure. This means that all of the GUIs are going to start calling powershell to do what they do. This means that Windows admins no longer need be laughted at by Unix admins due to their lack of ability to script tedious tasks. System Center Operations Manager (a Monitoring and operations management tool for medium to large Windows environements similar to tools like IBM Tivoli or HP Openview) and Exchange have both moved to this method of administration. Want to delete all users who's Mailbox is over 500MB?

    get-mailbox | where-object %{ $_.size -gt 500MB} | delete-qaduser
    I haven't verified/tested that syntax but powershell has proven to be just about discoverable enough to make it simple to figure out what the command is supposed to be and almost always be correct.

    A concept nobody else has that most admins immeidately see the benefits of is the -WhatIf switch. Think you have that script set to delete only the exchange mailboxes of users who have been fired but you're not entirely certain you have it all correct? throw a -WhatIf flag on all of your calls to destructive processes (you can pass this through your scripts but that's another syntactical discussion) and instead of doing them, it'll tell you what it would have done. This has saved my bacon on quick and dirty oneliners several times and helped me get things done faster and more accurately.

    Having used powershell to complete many windows administration tasks, I have found it to be extremely usefil for both large production scripts and quick one liners hacks in large production environments, I can say that it is an excelent step forward for the administrator in windows environments.

    I didn't intend for this to be quite so evagelistic, but I guess me entusiasm for Powershell leans me in that direction.

      Lots of Unix tools have a flag that means to only report what would be changed. It's certainly not a first.

      It's not exactly the same, but I usually do run find(1) with a -print action before I use an -exec action, for one.

      The idea of having a standard object structure among all the cmdlets and having it fall back to text is what I'd consider the biggest win, followed by having the system actually used by other tools within the Windows system.

      There have been many tools for Windows that could have been the basis for such a standardized approach, but it's good to know they have an interest in making proper system out of it. WSH and VBScript or some random collection of COM objects would not have been as nice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://640652]
Approved by ikegami
Front-paged by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2022-12-05 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?