Saturday, June 26, 2010

OO Hello World - IronRuby



Let’s have a look at the hello world program in IronRuby; another language implemented to run on the DLR runtime.

By the way, you can see my previous post here: http://carlosqt.blogspot.com/2010/06/oo-hello-world.html
where I give some details on WHY these "OO Hello World series" samples.

Version 1 (Minimal):
The minimum you need to type to get your program compiled and running.
class Greet
 @name = ""
 def initialize(name)
  @name = name.capitalize
 end
 def salute
  puts "Hello #@name!"
 end
end

# Greet the world!
g = Greet.new("world")
g.salute


Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.
require "mscorlib"

module GreetProgram 
 class Greet
  @name = ""
  def initialize(name)
   @name = name.capitalize
  end
  def salute
   puts "Hello #@name!"
  end
 end
 
 # Greet the world!
 g = Greet.new("world")
 g.salute  
end


The Program Output:










IronRuby Info:
“IronRuby is an Open Source implementation of the Ruby programming language for .NET, heavily relying on Microsoft's Dynamic Language Runtime.” Taken from: (http://www.ironruby.net/)

Appeared:
2007
Current Version:
Developed by:
John Lam + DLR Team
Creator:
John Lam
Influenced by:
Ruby (Yukihiro Matsumoto)
Predecessor Language
RubyCLR?
Predecessor Appeared
2006
Predecessor Creator
John Lam
Runtime Target:
DLR
Latest Framework Target:
4.0
Mono Target:
Yes
Allows Unmanaged Code:
No
Source Code Extension:
“.rb”
Keywords:
38
Case Sensitive:
Yes
Free Version Available:
Yes
Open Source:
Yes
Standard:
No
Latest IDE Support:
SharpDevelop 3.2/4.0 (beta)
Language Reference:
Extra Info:


No comments:

Post a Comment