Hello world in Cobra is here! Another Python – Like language which has lots of built in cool features such as Unit Tests and Contracts.
NOTE: The indentation appears to be 1 space when it should be 4. Cobra won't accept anything other than 4 (or one tab per indent). Take it in consideration if you want to test the code :)
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 var name cue init(name as String) base.init #.name = name.toString.toUpper + name[1:] .name = name.capitalized def salute print "Hello [.name]!" # Greet the world! class GreetProgram def main g = Greet("world") g.salute
Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.
use System namespace _GreetProgram class Greet var name as String cue init(name as String) base.init #.name = name.toString.toUpper + name[1:] .name = name.capitalized def salute print "Hello [.name]!" use _GreetProgram # Greet the world! class GreetProgram def main is shared g = Greet("world") g.salute
The Program Output:
“Cobra is a general purpose programming language with: a clean, high-level syntax, static and dynamic binding, first class support for unit tests and contracts, compiled performance with scripting conveniences, lambdas and closures, extensions and mixins... and more” Taken from: (http://cobra-language.com/)
2010-10-18 (latest version in "Languages" page)
Python (Guido van Rossum), C# (Anders Hejlsberg), Eiffel (Bertrand Meyer), Objective-C (Tom Love, Brad Cox)
Latest Framework Target:
Allows Unmanaged Code:
Source Code Extension:
139 (including types)
Free Version Available:
Latest IDE Support: