Skip to content

A programming language designed around portability, flexibility and ease of use. Every, single, keyword, is customizable!

License

Notifications You must be signed in to change notification settings

ShaharMS/Little

Repository files navigation

NOTICE: progress is currently being made on the branch branch/functional-programming.


Little

What is it?

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.

Why does this programming language exist?

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

Syntax

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's null value.

The resereved words' translations may change a bit across different languages to make programming more intuitive, and to keep the same code structure.

Language Features

Keyword & Standard Library Modification

Want to change up the keywords to ones that are quicker to type?
Maybe even change everything up to a whole new language?

You're Welcome!

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
فعل يحصل_ع() = {
    استرداد ع
}
مطبعة(يحصل_ع())

Everything can be a code block

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

Consistency is key!

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.");
}

Examples

Define Variables & Functions

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) 
}

While Loops & If statements

define i = 0
while (i <= 10) {
    print(i) //0, 2, 4, 6, 8, 10
    i = i + 2
}

if (i == 9) {
    print("How?")
}

For Loops

for (define i from 0 to 4) {
    print(i)
}

for (define j from 0 to 20 jump 5) {
    print(j) //0, 5, 10, 15
}

Whenever & after events

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

Documentation

"""
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`

About

A programming language designed around portability, flexibility and ease of use. Every, single, keyword, is customizable!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published