Wednesday, June 30, 2010

OO Hello World - Groovy



The Hello World version of the program in Groovy! A dynamic language for the JVM runtime with a very Java-like syntax.


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 {
  def name
  Greet(name) { 
      this.name = name[0].toUpperCase() + name[1..-1]
  }
  def salute() { 
      println "Hello $name!"
  }
}

// Greet the world! 
g = new Greet('world')  
g.salute()

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

package GreetProgram

private class Greet {
  private def name
  public def Greet(name) { 
      this.name = name[0].toUpperCase() + name[1..-1]
  }
  public def salute() { 
      println "Hello $name!"
  }
}

// Greet the world! 
g = new Greet('world')  
g.salute()

The Program Output:









Groovy Info:
“Groovy is an object-oriented programming language for the Java platform. It is a dynamic language with features similar to those of Python, Ruby, Perl, and Smalltalk. It can be used as a scripting language for the Java Platform.
Groovy uses a Java-like bracket syntax. It is dynamically compiled to Java Virtual Machine bytecode and interoperates with other Java code and libraries. Most Java code is also syntactically valid Groovy.” Taken from: (http://en.wikipedia.org/wiki/Groovy_(programming_language))

Appeared:
2003
Current Version:
1.7.5 and 1.8 Beta 2  (latest version in "Languages" page
Developed by:
Guillaume Laforge
Creator:
Guillaume Laforge
Influenced by:
Java (James Gosling)
Predecessor Language
Predecessor Appeared
Predecessor Creator
Runtime Target:
JVM
Latest Framework Target:
JDK 6
Mono Target:
No
Allows Unmanaged Code:
No
Source Code Extension:
“.groovy”
Keywords:
57
Case Sensitive:
Yes
Free Version Available:
Yes
Open Source:
Yes
Standard:
JSR 241
Latest IDE Support:
NetBeans
Eclipse
IntelliJ IDEA
Language Reference:
Extra Info:


OO Hello World - Nemerle



The Hello World version of the program in Nemerle (a C#-like language with functional features) is here!

Could it be a combination of C# and F#? not in the example below, but based on the features it supports it probably is.


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.

using System;

class Greet 
{
    mutable name : string;
    public this(name : string) 
    {
        this.name = name[0].ToString().ToUpper() + name.Substring(1, name.Length - 1);
    }
    public Salute() : void
    {
        Console.WriteLine("Hello {0}!", name);
    }
}

// Greet the world!
def g = Greet("world");
g.Salute();     

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

using System;
namespace GreetProgram
{
    internal class Greet 
    {
        private mutable name : string;
        public this(name : string) 
        {
            this.name = name[0].ToString().ToUpper() + name.Substring(1, name.Length - 1);
        }
        public Salute() : void
        {
            Console.WriteLine("Hello {0}!", this.name);
        }
    }

    // Greet the world!
    public module GreetProgram
    {
        public static Main() : void
        {
            def g = Greet("world");
            g.Salute();            
        }
    }
}

The Program Output:













Nemerle Info:
“Nemerle is a high-level statically-typed programming language for the .NET platform. It offers functional, object-oriented and imperative features. It has a simple C#-like syntax and a powerful meta-programming system.
Features that come from the functional land are variants, pattern matching, type inference and parameter polymorphism (aka generics). The meta-programming system allows great compiler extensibility, embedding domain specific languages, partial evaluation and aspect-oriented programming.” Taken from: (http://nemerle.org/What_is_Nemerle)

Appeared:
2003
Current Version:
Developed by:
Kamil Skalski, Michal Moskal, Leszek Pacholski and Pawel Olszta
Creator:
Kamil Skalski, Michal Moskal, Leszek Pacholski and Pawel Olszta
Influenced by:
C# (Anders Hejlsberg) | Lisp (John McCarthy), ML (Robin Milner)
Predecessor Language
Predecessor Appeared
Predecessor Creator
Runtime Target:
CLR
Latest Framework Target:
2.0
Mono Target:
Yes
Allows Unmanaged Code:
Yes
Source Code Extension:
“.n”
Keywords:
60
Case Sensitive:
Yes
Free Version Available:
Yes
Open Source:
Yes
Standard:
No
Latest IDE Support:
Visual Studio 2008 (shell, pro)
MonoDevelop 2.2
Language Reference:
Extra Info:


Sunday, June 27, 2010

OO Hello World - Zonnon



The Hello World version of the program in Zonnon (another Pascal/Oberon inspired language) 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.
module Main;

type {ref} Greet = object 
 var  
  name : string;

 procedure {public} Salute(name: string);
 begin 
  self.name := name.Substring(0, 1).ToUpper() + name.Substring(1, name.Length - 1);  
  writeln("Hello " + name + "!");
 end Salute;
begin
 name := "";
end Greet;

var 
 g: Greet;
begin 
 g := new Greet();
 g.Salute("world");
end Main.


Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.
module Main;
import System;

type {public, ref} Greet = object 
 var {private} 
  name : string;

 procedure {public} Salute(name: string);
 begin 
  self.name := name.Substring(0, 1).ToUpper() + name.Substring(1, name.Length - 1);  
  writeln("Hello " + self.name + "!");
 end Salute;
begin
 self.name := "";
end Greet;

var 
 g: Greet;
begin
 g := new Greet();
 g.Salute("world"); 
end Main.


The Program Output:









Zonnon Info:
“Zonnon is a general purpose programming language in the Pascal, Modula-2 and Oberon family. Its conceptual model is based on objects, definitions, implementations and modules. Its computing model is concurrent, based on active objects which interact via syntax controlled dialogs.” Taken from: (http://en.wikipedia.org/wiki/Zonnon)

Appeared:
2003
Current Version:
Developed by:
Jürg Gutknecht
Creator:
Jürg Gutknecht
Influenced by:
Pascal, Oberon, Modula (Niklaus Wirth)
Predecessor Language
Predecessor Appeared
Predecessor Creator
Runtime Target:
CLR
Latest Framework Target:
2.0
Mono Target:
Yes
Allows Unmanaged Code:
No
Source Code Extension:
“.znn”
Keywords:
59
Case Sensitive:
Yes
Free Version Available:
Yes
Open Source:
No
Standard:
No
Latest IDE Support:
Visual Studio 2008 (shell, pro)
Zonnon Builder
Language Reference:
Extra Info:


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: