Building a Clear Programming Language for Newcomers

This is a joke

Introduction

Many new programmers are often confused about a very important concept in programming: the variable lifespan. For example, one could not understand why the variable “a” is “not defined” when it’s clearly there:

1
2
3
4
5
6
int x=3;
{
int a=4;
}

a; //Compile Error

Another problem newcomers face when they are first presented callback functions are that they are not able to convert sequential code into callback functions. When the program gets complicated, it is common for a professional programmer to combine the callback functions and sequential coding. When this happens, newcomers may not know the correct order of execution, leading to frustration.

One more problem comes from the “impossible” mission for coding: naming things. Professional coder might use what are called “defensive programming” by naming variables weirdly, like just calling them q fa wps sht etc.

In order to make programming more accessible to beginners, we have developed the latest programming language: CLang!

Naming things

To solve the problem with naming things, in CLang we force the variable name to include its type at the beginning (for int, long long, bool, byte, etc) or at the end (for complex types). Instead, you do not need to explicitly write out its type:

1
2
3
4
iAge #int32 age
llAnswer #int64 answer
myBook #Book my
newObject #Object "new"

Program Structures

In a standard program, we might write program in a sequential order:

1
2
3
4
5
6
7
8
9
10
11
int main(){
int a;
cin>>a;
if(a<0){
int out=-a;
cout<<out;
}else{
int out=a;
cout<<out;
}
}

However in CLang we force everything to have a callback function and the scope is defined explicitly using {}! So no more sequential and the order of execution has no worries!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
mainFunc(){ //define Func called main
ia{ //int a. in the {} is where this variable 'a' exists
inputF(function(data){ //signature: inputF/inputFunc(callback)
(ia=data).then(function(){
if(a<0,function(){ //if(cond,true_callback,false_callback)
iOut(-ia){ //give iOut an initial value
outputF(iOut,function(){})
}
},function(){
iOut(ia){
outputF(iOut,function(){})
}
})
})
})
}
}{}

The function are defined using the following syntax:

1
2
3
4
5
nameF/nameFunc(parameters):returnType{
codeBlock
}{
defined scope
}

For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
absF(ia):int{
return ia>0?ia:-ia;
}{
//you can use absF here
mainF(){
ia{
input(function(data){
(ia=data).then(function(){
output(absF(ia),function(){})
})
})
}
}{}
}

Defining a class is weird but understandable:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Animal{
public{
iAge,nameString;
barkF(contentString){
output(nameString+" says "+contentString,NF) //wow you can use NF for empty functions!
}
}
}{
class Dog:Animal{
private{
typeString;
}
public{
barkF(contentString){
output(nameString+" barks "+contentString,NF)
}
}
}
}