You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sol is an imperative, statically-typed language designed as a tool for learning
how to program. It is simple, in that it has few language features and can
thus be learned quickly. It is obvious, in that it should be clear from
reading the source code of an application what instructions the computer will
execute.
Many common programming language features that allow programs to be more
expressive were intentionally left out. See non-features
for more details.
Examples
Hello, world!
function main() {
print("Hello, world!");
}
Explicit Type Casts
function main() {
constant answer = 42;
constant message = "The secret is " + String(42);
print(message);
}
Max Number
function maxNumber(numbers Number[]) -> Number {
variable max = 0;
for index, number in numbers {
if index == 0 {
max = number;
continue;
}
if number > max {
max = number;
}
}
return max;
}
function main() {
variable allNumbers = Number[1, 7, 3];
variable bigNumber = maxNumber(allNumbers);
print("The biggest number is " + String(bigNumber)); # The biggest number is 7
}
Recursion
function fibonacci(num Number) -> Number {
if (n <= 1) {
return n;
}
return fibonacci(n - 1) + fibonacci(n - 2);
}
Non-features
What should be of more note to existing programmers is not what features Sol
implements, but rather those it does not. What follows is a non-comprehensive
list, along with the rationale for omitting it.
Mutable Global State
While Sol allows constants to be defined globally, it does not have global
variables. Variables only exist within the scope of a function, and to share
them you must either pass their value or a pointer to them via function
arguments.