The Cyan Programming Language


A prototype example


package program 

private object Box
    private Int n = 0 
    fun get -> Int { 
        ^ self.n 
    }
    fun set: Int n { 
        self.n = n 
    }
end 

object Program 
    public fun run {
        var s = Box clone; 
        var Int a; 
        a = In readInt; 
        s set: a; 
        Out writeln: (s get); 
    }
end
			

Java-like Interfaces


interface Printable 
    fun print 
end 

object Manager extends Person 
       implements Printable 
        // what he/she does 
    public var String profession 
    public fun print {
       ...
    } 
end
			

Hello World


package main

object Program
    public fun run {
        Out println: "Hello World"
    }
end
		

Creating new objects


var Person person; 
    // the same as "person = new Person()" in Java 
person = Person new; 
    // cloning the Person object 
person = Person clone;
person = Person();