You are on page 1of 5

Cloud Programming Language

Official Specification Overview


©2008 CloudNine Web Services
1) Overview
a) Introduction to Cloud
b) About this document
c) Note for programmers coming from C# and Java
d) Note for programmers coming from PHP and Perl
e) Introduction to Cloud structure

2) Language Overview
Overview

Introduction to the Cloud Programming Language

Cloud is a multi-purpose programming language developed by CloudNine Web Services. It was


designed to operate as both an improved C# and an improved PHP, as well as a functional transition language
between the two. Cloud can be scripted and run as an interpreted language on the web, or compiled and run
as a clientside application on the desktop, will full support for GTK# and other C# packages.

Compilers are currently working on Linux, BSD and Mac OS X, and a Windows compiler is nearing completion.
Interpreters are available for Linux and BSD, with OS X / Windows going into development shortly.

About this document

This is a partial, basic overview at the Cloud programming language, which is still actively in
development. For more information, refer to the online documentation at http://cloud9nine.net. This
document expects the reader to be proficient in either C# or Java as well as PHP or Perl, and as such, gives
only example code, without explanation.

Note for C# and Java Programmers

If you’re proficient in C# or Java, writing clientside Cloud should be exceedingly easy, as it’s structured
very similarly, with some much-needed missing functionality added – though it’s condensed like a more
modern scripting language.

Note for PHP and Perl Programmers

Cloud on the web is very much like PHP or Perl – it can be written in a procedural or object oriented
format, or Cloud-style, as it can be clientside.

Introduction to Cloud Structure

Cloud is programmable both procedurally and like standard object-oriented code, but also maintains a
custom structuring method, simply named Cloud Structure. Cloud Structure can best be defined as a
combination or half-way point of Procedural and Object Oriented – its use will become apparent throughout
the documentation.
Basic Language Overview

Hello World
<<cloud interpreted>>
print “Hello, World!”;
<<cloud end>>

Basic Syntax
// This is a comment in Cloud.
// Variables can be assigned a hard type or left as a dynamic/typeless block.
$a = 1; declare $b;
//Create dynamic variable a and assign it to 1 and initialize dynamic variable B
double a = 1.0; long b;
//Create static type variables – these must be initialized like in C# or Java

Working with Types in Cloud


<<cloud interpreted>>
string foo = “5”;
foo++;
This code will fail with the error:
(Cloud) Error interpreting on line 2, position 1: Incompatible types.

To get around this, we can either typecast:


foo->int;

Or, we can convert foo into a dynamic type:


$foo;

Now we can execute the original foo++; without error.

Arrays
array foo = $array(1, “hello”, math.pi);
intarray foo = array(1, 2, 3); or array foo = intarray(1, 2, 3);

doublearray bob = array(1, 2.2, 3.3);


bob[] = 15;
print bob[1];

foreach(bob as a)
{
print a;
}
Working with Classes and Orientation
Classes in Cloud are independent of their file name.

<<cloud compiled>>
public class cloudTest() {
public dynamic doStuff() {
print “Hello there!”;
}
}

public class mathController(classwide dynamic a) {


public sdynamic double() {
return a*2;
// sdynamic type will result in either an int, double, or long – the smallest possible without losing precision
}
public sdynamic halve() {
return a/2;
}
<<cloud end>>

Cloud Style Structure


public class cloudstyle() {

include(someotherclass.cloud);
$a = 1;
// some code out of scope, which works fine as procedural

public void someFunction($a) { … }

Other things of note:

Single functions can be imported in Cloud.


Cloud methods and variables are case-insensitive except in cases where the user explicitly defines classes with
the same name but different casing.
Cloud can generate a number of common things for the user on the fly, like CSS, Glade, and some other
markup languages!
“Standard” functions (IE, methods from commonly used classes) can be accessed procedurally without being
imported; the rest can be referenced as static methods or as PHP-style OO Functions!

The absolute basics of Cloud have been covered. This isn’t the documentation, so let’s get right into some
code examples!
Cloud Example Code

Simple web script to query a PostgreSQL database for posts and display them nicely

<<cloud interpreted>>
import cloud.web;
import cloud.db.sql.postgre;
runtime.walkthrough.linebyline(true, “ “, “<br>”);
sql = sql.postgre;
sql.connect(localhost, dbname, dbuser, dbpass);
sql.query(“SELECT * FROM posts”), sql.format.array, => $result;

web.generateCSS(bg => white, text => black, link => blue);

foreach($result as $a) {
$output += “<b>” + $a.mytable.posttitle + “</b><br>” + $a.mytable.postcontent + “<br>”;
}

print web.htmlformat($output);
<<cloud end>>

Drawing a rotating 3D cube with GTK

<<cloud compiled>>
import cloud.gtk;
import cloud.opengl;
import cloud.easydrawing;

create cloud.gtkwindow(“My 3D Cube!”, 800, 600, true);


$cube = easydrawing.drawshape(“Cube”, 3, random(cloud.color));

$cube acts(easydrawing.rotation) as polls(cloud.input.cursorlocation) updates(onChange);

gtkwindow.autocomplete;
gtkwindow.draw;

You might also like