NOTICE: progress is currently being made on the branch branch/functional-programming
.
Little is a simple programming language that can be used to teach children how to program.
The language is designed to be as international as possible - names of variables & actions allow non-english characters, and keywords can be changed to anything, including phrases in other languages (as long as they don't contain any spaces)
The language itself is cross-platform, as it's programmed in haxe.
Other than teaching, the language has many benefits, some already mentioned before:
- cross platform
- relatively small bundle size
- Extendable
- fast interpreter
- Multilingual coding
- Easily interfaces with external Haxe elements
- both low level & high level programming supported
- Understandable errors that actually explain what went wrong and where
- easy and accurate access to runtime details & definition values
The language is very minimal by design, and only has a couple of reserved words:
Notice - the language is still in development, syntax may change in the future
define
- used for variable declaration.action
- used for function declaration.as
- used for expression typing, for example:define x as Number
return
used for returning action values.nothing
- the language'snull
value.
The resereved words' translations may change a bit across different languages to make programming more intuitive, and to keep the same code structure.
Want to change up the keywords to ones that are quicker to type?
Maybe even change everything up to a whole new language?
Examples:
Alternative names:
define x = 3, x = x + 6 action getX() = { return x } print(getX()) |
var x = 3, x = x + 6 fun getX() = { ret x } log(getX()) |
Different languages (English, Hebrew, Arabic):
define x = 3, x = x + 6 action getX() = { return x } print(getX()) |
הגדר ס = 3, ס = ס + 6 פעולה קבל_ס() = { החזר ס } הדפס(קבל_ס()) |
السياج ع = 3, ع = ع + 6 فعل يحصل_ع() = { استرداد ع } مطبعة(يحصل_ع()) |
Code blocks, represented by enclosing lines of code/expressions with (by default) curly brackets, can be used for everything! For example:
- expression generation:
x = {define y = 0; y += 5; (6^2 * y)} //180
- runtime variable declaration
define {("hey" + 1)} = 3
print(hey1) //3
the same syntax always does the same thing, without any special cases:
define consistent = 5
define consistent.newPropertyDeclaration = 6
action declaredJustLikeVariables(define parametersAreDefinedTheSame = 6) = {
print("Function Bodies are also assigned using `=`")
}
for (define i from 0 to 1) {
print("And for loop variables are also declared like normal variables.");
}
define hey = 3
action getHey(define negative as Boolean) = {
// if negative is false, negative.toNumber() is 0, and the positive is returned (hey - 0).
return hey - (hey * negative.toNumber() * 2)
}
define i = 0
while (i <= 10) {
print(i) //0, 2, 4, 6, 8, 10
i = i + 2
}
if (i == 9) {
print("How?")
}
for (define i from 0 to 4) {
print(i)
}
for (define j from 0 to 20 jump 5) {
print(j) //0, 5, 10, 15
}
define i = 2
after (i >= 5) {
print("i is " + i + "!")
}
whenever (i >= 3) {
print("woah")
}
i = i + 1 //woah
i = i + 1 //woah
i = i + 1 //woah, i is 5!
i = i + 1 //woah
"""
Retrieves the value of `x``
"""
define x = 3
""" Increments the value of `x`` """
action incrementX() = { x = x + 1 }
print(x) //3
print(x.documentation) //Retrieves the value of `x`
print(incrementX.documentation) //Increments the value of `x`