Sunday, June 27, 2010

OO Hello World - Oxygene



The Hello World version of the program in Oxygene is here.

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.
namespace;

interface
uses  
 System; 

type Greet = class
 private
  var name : string;
 public
  constructor(name : string);
  method Salute;
 end;

type
 GreetProgram = class    
  class method Main(args: array of string);
 end;

implementation

constructor Greet(name : string);
begin
 self.name := name[0].ToString().ToUpper() + name.Substring(1, name.Length - 1);
end;

method Greet.Salute;
begin
 Console.WriteLine("Hello " + name + "!");
end;

class method GreetProgram.Main(args: array of string);
var
 g : Greet;
begin
 g := new Greet("world");    
 g.Salute();
end;
end.


Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.
namespace GreetProgram;

interface
uses  
 System; 

type Greet = public class
 private
  var name : string;
 public
  constructor(name : string);
  method Salute;
 end;

type
 GreetProgram = public class    
    public
  class method Main(args: array of string);
 end;

implementation

constructor Greet(name : string);
begin
 self.name := name[0].ToString().ToUpper() + name.Substring(1, name.Length - 1);
end;

method Greet.Salute;
begin
 Console.WriteLine("Hello " + self.name + "!");
end;

class method GreetProgram.Main(args: array of string);
var
 g : Greet;
begin
 g := new Greet("world");    
 g.Salute();
end;
end.


The Program Output:









Oxygene Info:
“Oxygene provides a cross-platform development solution and robust programming language for rapidly developing .NET, Mono, ASP.NET, and data-driven applications for Windows, Linux, and Mac OS X. Delphi Prism combines easy-to-learn syntax based on the Delphi language with features not available in other .NET programming languages” Taken from: (http://www.embarcadero.com/products/delphi-prism)

Appeared:
2008
Current Version:
Developed by:
RemObjects and Embarcadero Teams
Creator:
Marc Hoffman + RemObjects Team
Influenced by:
Object Pascal (Niklaus Wirth, Anders Hejlsberg) and Delphi (Borland)
Predecessor Language
Oxygene
Predecessor Appeared
2005
Predecessor Creator
RemObjects Team
Runtime Target:
CLR
Latest Framework Target:
4.0
Mono Target:
Yes
Allows Unmanaged Code:
Yes
Source Code Extension:
“.pas”
Keywords:
134
Case Sensitive:
No
Free Version Available:
Yes
Open Source:
Yes
Standard:
No
Latest IDE Support:
Visual Studio 2008 for Prism2010 (shell, pro)  (only for paid edition)
Visual Studio 2010 for Prism2011 (shell, pro)  (only for paid edition)
MonoDevelop 2.2
Language Reference:
Extra Info:

No comments:

Post a Comment