Skip to content

Experimental interpreted programming language with Smalltalk syntax

License

Notifications You must be signed in to change notification settings

AaronC81/babble

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Babble's logo, showing a colon character inside matching square braces - both items of punctuation which appear often in Babble code.

Babble

Language tour | API documentation | VS Code extension


Babble is a very experimental interpreted programming language, which takes inspiration from Smalltalk and Ruby's syntax, and Rust's algebraic data type model.

Babble aims to have as few language constructs as possible, instead implementing control-flow like conditionals and loops using methods and blocks (closures).

impl Integer {
    func factorial {
        self lessThanOrEquals: 1 $
            ifTrue: [ 1 ]
            else:   [ self * (self - 1) factorial ]
    }
}

Console println: 7 factorial.

If you'd like some more examples:

Data Types

Unlike Smalltalk, Babble isn't object-oriented; data is expressed with sum and product types like Rust or Haskell. Specifically, the naming from Rust is used - structs hold known fields, and enums have multiple variants which can each optionally hold a different set of fields:

struct Person name age occupation.

enum Occupation {
    Student.
    Lecturer.
    SoftwareEngineer.
    Other title.
}

me = Person name: "Aaron" age: 22 occupation: Occupation#SoftwareEngineer.
you = Person name: "The Reader" age: 99 occupation: (Occupation#Other title: "Unknown!").

Usage

Babble is complete enough to use for simple scripts, but there are plenty of rough edges and gaps in functionality.

To run a file of Babble code:

cargo run --release -- -f <file>

(Running in release mode is strongly recommended! It's very easy to overflow the stack without...)

To-do list

  • Mixins - a way of implementing shared functionality, like Rust's traits
  • Pattern matching - implemented with match-blocks, which take patterns as parameters and return Match#Hit returnValue or Match#Miss depending on whether the pattern was actually matched
  • Better parser errors
  • Better runtime errors
  • Complex assignment targets (e.g struct fields)
  • Collection types and literals
    • Arrays
    • Dictionaries
    • Sets
  • String interpolation
  • More access control
    • Private fields
    • Private constructors
  • Keyword to allow function arguments to appear in any order, for constructors
  • Core mixins on types (e.g. Equatable but static) for more consistency between types and values

About

Experimental interpreted programming language with Smalltalk syntax

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published