The basics of Imba

Imba is an indentation based language. If you have written any Ruby or Python then a lot of the syntax will feel familiar. Even though the syntax and semantics of Imba is much more related to Ruby than JavaScript, it does compile down to plain JavaScript, and is fully compatible with any existing JavaScript libraries. Imba does not extend any native types from JavaScript. Arrays are arrays, strings are strings, numbers are numbers, classes are constructors with prototypes and so forth.


All the fundamental types are the same as in JavaScript, so for documentation about available methods see MDN Object, Function, String, Number, RegExp, Array, Date, Math.


var single = 'single quotes'
var double = "double quotes"
var interpolation = "string has {double}"


var integer = 42
var float = 42.10


var object = {name: 'Imba', type: 'Language'}

If you can't stand the curly braces then indentation will also work

var object =
name: 'Imba'
type: 'Language'


var array = [1,2,3,4,5]

Regular Expression

var regex = /number is (\d+)/


for num in [1,2,3]
for own key, value of object


def hello name="world"
return "Hello {name}"
console.log hello!
console.log hello('you')


class Dog
def constructor name
name = name
def bark
"woof woof"


var item
item = 100 # set value of item
item ||= 100 # set if value is falsy
item &&= 100 # set if value is already truthy
item ?= 100 # set if value is null or undefined
# comparators
item == 10 # check
item === 10 # strictly equal
item != 10 # not equal
item !== item # strictly not equal
item > 10 # greater than
item < 10 # less than
item >= 10 # greater than or equal
item <= 10 # less than or equal

Bitwise Operations

a & b # Bitwise AND
a | b # Bitwise OR
a ^ b # Bitwise XOR
~ a # Bitwise NOT
a << b # Left shift
a >> b # Sign-propagating right shift
a >>> b # Zero-fill right shift

Edit on GitHub