Giter VIP home page Giter VIP logo

little's Introduction

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`

little's People

Contributors

shaharms avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

little's Issues

Support `sin()`, `cos()`... in math equations

what currently happens is that the language tries to look for functions with those names, and fails since those arent loaded. those functions should either be preloaded or made an exception to the error checker, since formula already handles those functions

Non-bodied condition calls fail in some scenarios

for example, this:

if (a) h()

yields:

 └─── Function Call
       ├─── Condition
       │     ├─── if
       │     ├─── Expression
       │     │     └─── g
       │     └─── h
       └─── <empty array>

instead of putting the function call on the h. Parser problem.

Add support for arrays

underlying stuff is implemented. Consider adding this as a macro maybe? or inserting a new parsing level. Both can work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.