Powershell or Ruby ?

Recently I have been playing with Ruby and I have to say the language is a ton of fun. This one line of code pretty much sold me on the language.
5.times {puts "Hello World"}

Similar to Powershell, in Ruby, everything is an object, including primitive times. In Powershell, I could definitely get into some XML goo and spot-weld a method to System.Int32 called times.

What would be really cool is if in Powershell I could expand the int32 class on the fly and not have to mess with XML, just as I can in Ruby.

mystring = "Hello There"
puts mystring.length
class String
 def myownmethod
  puts "Methods on the fly are pretty cool"

puts mystring.myownmethod

Below is the output from the code

RubyMate r6075 running Ruby r1.8.6 (/usr/bin/ruby)

Methods on the fly are pretty cool

I love Powershell and am a die-hard fan. When it comes to the debate of Powershell vs Ruby I personally take Scott Hanselman’s suggestion. Learn them both and you wil be a better scripter/developer/person. Sure, you can also use add-member for instances of objects, but to be able to create and modify classes in Powershell V2 would be pretty darn cool.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: