Skip to content
javascript dialect
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
modules
README.md
ribbit.js
wood.js

README.md

Ribbit (WIP)

Ribbit is a javascript dialect that I've been working on it for a few years now. Originally, Ribbit was a small library that made it easier to define properties on the fly. Now, it has grown into something bigger.

Over the years, it has grown a typing system, a matching system, and lots of other shortcuts that I like to use. This has involved trying to meld Javascript into something quite different, which can result in some very odd-looking code.

When making Ribbit, I always do what makes sense to me, even if I know it won't make sense to other people. Therefore, other people might find it strange or just dumb. Despite this, I'm quite fond of it. I really enjoy using Ribbit to write Javascript.


Types

Ribbit has its own type system.


Type Checking

["Joe", "Flora"].is(Array) == true


Type Conversion

"24".as(Number) == 24


Type Assertion

let age  = Int(24)
let name = String(24) //Error: Type Mismatch


Custom Types

let UpperCase = new Type ({
	base:    Text,
	convert: text => text.toUpperCase(),
})

"HELLO".is(UpperCase) == true


Static Typing

let scores = new Int[_]
scores.push(4)
scores.push(7)
scores.push(4.2) //Type Error!

Properties

Define properties easily.


Getter

luke.name = "Luke"
luke.surname = "Wilson"
luke._.fullname.get = o=> `${luke.name} ${luke.surname}`
luke.fullname == "Luke Wilson"


Static Typing

luke._.name.type = Text
luke.name = 24 //Type Error!


Full definition

player._.health = {
	value: 10,
	type: Number,
	set: (v) => {
		player._.health.value = v
		if (v <= 0) print("You died!")
	},
}

Patterns

Use pattern matching to save time and space.


Match

input.match (
	Text,       "It's some text",
	"Luke",     "It's my name",
	[Num, Num], "It's a list of two numbers",
	_,          "It's something else",
)


Matcher Function

let fibonnaci = matcher (
	[0],   0,
	[1],   1,
	[Int], n => fibonacci(n-1) + fibonacci(n-2),
)

Functions

Ribbit gives you more options for how you work with functions.
Some might seem more useful than others.


Bracketless
You can call functions without brackets.

print.x= "Hello world!"
friends.o.forEach.x= friend => print (`Hello ${friend}`)
friends.o.for.o(10).x= friend => print (`You're in my top 10 friends!`)


This
You can use arrow notation to make a function-scoped function.

luke.grow = f(self => self.age++)

Classes

Use Ribbit's type system to extend and/or create classes.


Extend Class

Number.O.multiply = f((self, num) => self * num)
(3).multiply(2) == 6

Even.O._.half.get = f(self => self / 2)
(4).half == 2
(5).half //Type Error!


Create Class

let Person = new Type ({
	[X.name]: Text
	[X.age]:  Number
	[O.grow]: o=> this.age++
})

let luke = new Person ("Luke", 24)
luke.grow()
You can’t perform that action at this time.