views:

152

answers:

4

Some time ago I've started with PowerShell that is really great. I can code almost everyting I know, I can use .NET framework, WMI, even WIN API. Features like piping help me a lot to write manageable and readable code. V2 added advanced functions, modules, background jobs, remoting (woow) etc.

As I said, I can do almost everything with PowerShell, but I'd like to learn a new language. The main reason is further self-education. Other reasons (not so important):

  • some limitations (e.g. it's not easy to work with threads in PowerShell or generics support)
  • speed (it's probably costs of wrapping all to PSObjects and not working with objects directly)
  • cross-platform development (e.g. I can run Python on my Symbian, which probably won't be possible with PowerShell)

What language would you recommend me that can beat PowerShell in some areas? For example in readability, language consistency, documentation, usefullness, libraries, stability, WTF moments...
If it is able to deal with the limitations I pointed out, the better.

I prefer scripting language because of the REPL loop and because it's not too verbose as e.g. C#, but that's not a requirement.

I've had a quick look at IronPython. The main reason was hosting as presented at PDC 2009. However, I miss piping, it's too verbose and somewhat clumsy compared to PowerShell.


My background: I've worked (at least as a beginner) with these languages: with c#, c++, javascript, tsql. I had a quick look at python, but that didn't convince me to give it a try (maybe a mistake).

I don't think this question should be closed because it is specific to PowerShell and comparison to other (scripting) languages. If you vote for closing though, please leave at least a comment why.

+2  A: 

If you want another scripting language, then I would suggest either VB Script (to be able to read all the examples of Windows scripting you will find), or JavaScript (complementary use cases: web client programming is a different area of development).

Equally you could look at C#: both to write .NET code, and to extend PowerShell. It will also make it easier to understand the capabilities of the .NET Framework (no examples for most of the framework in PowerShell, but C# examples everywhere).

Richard
Thx Richard for your answer, I hoped for at least one ;) In fact I'm a c#/web developer, so in some way I know JavaScript. However, for my purposes (the area where Posh is strong - files, registry, xml, downloading web content, discovering foreign assemblies, ...) it is not so suitable. I'll edit the question. I fully agree that learning c# is big leap for anyone who in some knows PowerShell.
stej
+1  A: 
Richie Cotton
What IronRuby offers what PowerShell does not have? Just curious, cause I don't know anything about (Iron)Ruby. And isn't then IronPython better than IronRuby? It seems that IronPython will be integrated to VS as C# or Visual Basic.
stej
IronPython is very stable and already being used in commercial apps, but IronRuby is not far behind. Their goal is to be stable and competitive with other Ruby platforms in the near future.
Greg Bray
+3  A: 

While not a "scripting" language per-se, F# is worth taking a look at. It does support piping (|>) and a number of other higher level features like pattern matching. And there is an interactive console that is provided within Visual Studio as well as a standalone console interactive prompt. There is also the functional nature of F# that is a bit "mind-bending" but in a good way. :-)

Keith Hill
I plan to buy book written by Tomas Petricek *Real-World Functional Programming*. But so far I considered it as a language which sources have to be compiled. Is it possible to store f# scripts and run then as well as ps1?
stej
I proofed the manuscript on that book a while back and I'm now just starting the released book. Looks good so far. BTW, you can run uncompiled script files using fsi.exe e.g. `fsi hello.fsx`
Keith Hill
F3 is definitely a good way to expand your knowledge, as it adds a functional programming aspect to the primarily Object Oriented worlds of most languages. I haven't worked with it much, but I have watched some of the videos on Channel 9 and it is being pushed heavily by Microsoft. http://channel9.msdn.com/shows/Going+Deep/C9-Lectures-Dr-Don-Syme-Introduction-to-F-1-of-3/
Greg Bray
+2  A: 

Not sure which version of IronPython you tested, but I would strongly suggest looking at it again. The latest version of IronPython is built against the 2.6 standard, which is the version of python that most other users are using. It can be a bit more verbose than some scripting languages, but feels more like a full programming language ala C# to me then a scripting language. Doing work with classes and multiple threads is much easier in IronPython then in Powershell. Plus you get the benifit of being able to utilize .NET libraries and assemblies like you can in Powershell. (For cross platform code you would need to stick with just python classes)

My typical approach is to use Powershell when I need to hack something together or do system managment tasks (files, registry, wmi, etc), IronPython if it is more complex or a small side code project, and then C# for commercial grade code. They each offer a different way of thinking (pipes, dynamic typing, static typing) but all use the same basic .NET libraries so I don't have to figure out how to parse datetimes again when changing between languages.

As for your requirements, IronPython/python seem to fit them very well:

  1. Readability and consistency are two primary goals of python
  2. Languange documentation is good and code documentation is a pillar of python
  3. Usefullness, libraries: You get the full power of .NET, so same as what you could do in Powershell
  4. Stability: latest IronPython is very stable (Resolver One uses and is built completely in IronPython)
  5. WTF moments... Can't help you there, but it still is a REPL so you can at least poke around to find what's wrong :-P

The one area that I would say the IronPython is lacking severely is in tool support. Powershell has some great script editors, but so far the best editor I have found for IronPython is a combination of Notepad++ and, oddly enough, Resolver One's built in python console, which has decent code completion and is easy to pipe data out to a grid since it is a spreadsheet application. Also you sometimes have a problem of "Living in two worlds", where there is a python way to do something and a .NET way of doing something and you have to choose (compatibility vs .NET familiarity). And while IronPython can be used for simple scripting, if you are mainly dealing with simple files, the registry, or xml then Powershell is by far the way to go. Ironpython just helps to fill the gap between a pure scripting language and a full programming language.

Hope that helps. I have some examples of IronPython and Powershell on my blog. I have only been using IronPython for about a year now, but having come from a C# background it is very interesting to see how programming in a dynamic language works. Also the TryPython.Org site is a great way to start using IronPython right from your browser!

Best of luck!

Greg Bray
Greg, you persuaded me to give IronPython another chance ;) One more reason why I had a look at IPy was a possibility to host it in c# and provide some sort of plugin mechanism - to call IPy scripts that can change the state of c# objects (there is a link to screencast from PDC in my question). You somehow confirmed my suspect that PowerShell is awesome language :)
stej