PowerShell is slow

I was going to start the new year with a positive note, but then I thought, lets get a PS1 pet hate out of the way first.

PowerShell is slow.

There are many ways to demonstrate this, but for this case I’m going to use a small snippet of code I found to render the mandelbrot set to the console window. It’s not my code and don’t know where it came from, but algorithm is fairly well known.

The code to demonstrate this is in a zip file here.

If you run ./mandel2.ps1 you get this pretty picture.

There is a Windows Scripting Host version. Run this with cscript mandel2.wsf.

There is a JScript.NET version. Compile it with JSC and or run the supplied one with ./mandel2.js.exe.

There is even a javascript-embedded-in-a-HTML-page version, just click on mandel2.html.

Now on my machine (a 2.66ghz quad core MacPro running XP in Parallels Desktop), I get these results:

PowerShell 1510 ms
Windows Scripting Host 90 ms
JScript.NET 160 ms
HTML (IE7) 110 ms
HTML (Firefox 2) 140 ms
HTML (Safari on OSX) 103 ms

OK, so the existing javascript engine in Windows (used by IE and WSF) are pretty good at this. Safari’s is pretty good (using KJS). So why is this brand spanking new language, PowerShell, so very poor?

It’s more than an order of magnitude slower than Microsoft’s previous attempt at a scripting environment!

This tardiness really shows itself in other inappropriate projects I’m working on in PS1. I really hope the PowerShell team at Microsoft address this for version 1.1 – maybe they should go speak to the jscript team.

Happy New Year

Just over half a day left of 2006 here in London, the weather is cold, windy and wet, the coffee is on, and I write my first post!

I’ve been using PowerShell (abbreviated to PS1 from now on) since it was RTW (released to web) some time at the end of November 2006. A few of my colleagues also starting playing with it, and as some of us were unix/Mac people, we set about mocking it :-) .

Speaking for myself, I was quite impressed but less so with the documentation and other online resources. I’ve also become less and less impressed with it over the last several weeks, but then it’s quite common for the shine to wear off new toys.

First Impressions

A pipeline – yay!
Scripting .NET and COM
Looks like it might have closures and rubyesque features.

Second Impressions

It didn’t have have closures after all.
Very very slow
snip

Space Invaders

Anyway, this didn’t stop me trying to do inappropriate and silly things with it. e.g., getting the MS Agent (Merlin etc.) to insult you.

It’s always been a pet hobby of mine to try to write Space Invaders in any new language I learn. Usually it just goes as far as writing something that moves the alien hoard in an authentic way, as you don’t really get input event support in languages like COBOL or CMD.EXE batch language.

Joy! PS1 gives you access to the host console via $host.ui.rawui, so the work began.

Between myself and 3 colleagues, we did get a perfectly playable version of Space Invaders, and I plan to put it up here in a future post.

That’s it for now. Happy PS1 scripting in 2007!