The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

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]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)