|
|
Back to UserFriendly Strip Comments Index
| Which looks better? |
by jpprater |
2009-05-08 19:28:45 |
A 26-line script that requires an ad-hoc conversion from an enumerated non-sortable collection to an array, or a 1-line command that does the same thing?
Background: I've just written a WSH script that captures processes using memory over a certain amount (20MB, for instance) and prints them out sorted. That script takes 26 lines. The nature of the language and the process data means the process list gets pulled as a collection that has to be enumerated, and it can't be sorted without being converted item-by-item to an array.
The same task can be done in PowerShell with a single line, consisting of 3 commands in a pipeline:
gwmi -computername mycomp -class Win32_Process -filter "WorkingSetSize >= " + [string](20*1024*1024) | sort WorkingSetSize | ft Name,WorkingSetSize
Python is very nearly as simple (half the lines of the script described above). Only Microsoft's built-in WSH scripting languages make it complicated. |
|
[ Reply ] |
|
|
[Todays Cartoon Discussion]
[News Index]
|
|