Sunday, April 7, 2013

OO Hello World - Golo



The OO Hello World in Golo, "... Yet another one. A simple one.", is here!

Golo is a simple and lightweight dynamic language for the JVM.

You can see the OO Hello World series 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 blog.series

function Greet = |name| ->
    DynamicObject(): 
    name(name: substring(0,1): toUpperCase() 
            + name: substring(1, name: length())): 
    define("salute", |this| -> println("Hello " + this: name() + "!"))

function main = |args| {
    let g = Greet("world")
    g: salute()
}

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

local function Greet = |name| ->
    DynamicObject(): 
    name(name: substring(0,1): toUpperCase() 
            + name: substring(1, name: length())): 
    define("salute", |this| -> println("Hello " + this: name() + "!"))

function main = |args| {
    let g = Greet("world")
    g: salute()
}

The Program Output:










Golo Info:

Golo is a simple, dynamic and weakly-typed language that favours explicit over implicit and that runs on the Java Virtual Machine. It also supports the latest JVM features such as invokedynamic.

Appeared:
2013
Current Version:
Developed by:
DynaMid research project members of the CITI Laboratory
Creator:
Julien Ponge
Influenced by:
Java (James Gosling)
Predecessor Language
N/A
Predecessor Appeared
N/A
Predecessor Creator
N/A
Runtime Target:
JVM
Latest Framework Target:
JDK 7
Mono Target:
No
Allows Unmanaged Code:
No
Source Code Extension:
“.golo”
Keywords:
33
Case Sensitive:
Yes
Free Version Available:
Yes
Open Source:
Yes
Standard:
N/A
Latest IDE Support:
Language Reference:
Extra Info:



No comments:

Post a Comment