-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the Cmple wiki!
A language that is as easy to use as python but the speed of C. This language will be called Cmple (pronounced 'simple') whose syntax is a mix between C (in terms of variable declaration) and python (everything else). A translator to C, called cmple2c, would translate the Cmple code to C and then, compiled using C compiler.
Functionality is borrowed from various programming languages (Nim, Julia, Python, C) to allow better abstraction and ease of use.
Nim is the nearest to my liking but I still find it too complicated. Nim is like Pascal and my preference is C in terms of simplicity.
Attempts are made to make coding and typing easier. For example, to comment a code, typing '//' or ''' is so much easier compared to typing /* */. Also, python-like expressiveness is attempted and cymple2c will do the hard work of translating them to equivalent C code.
Blocks are grouped by indentation, python-style. The following Cymple statement
if 2 < x < 111
z = 5
y = 0
else
z = -22
y = 22
will be translated to this equivalent C statement
if (2 < x && x < 111) {
z = 5;
y = 0;
}
else {
z = -22;
y = 22;
Notice that unlike python, no need for ':' at the if line. }
Use '//' to designate comments as follows:
// this is a comment
x = 4 // another comment
cmple2c will translate this to:
/* This is a comment */
x = 4; /* another comment*/
Use ''' for longer comments as follows:
'''
This is a longer comment
spanning several lines
'''
cmple2c will translate this to:
/*
This is a longer comment
spanning several lines
*/
Functions are always declared in C-syle:
int f(int x, float y)
Variables need not be declared if it could be derived somewhere else.
x = f(5, 3.4) // no need to declare x
Since we know that f() returns an int, the cmple2c would automatically create the declaration for you
int x; // <- automatically created by the translator
x = f(5, 3.4);