Queen logo

Queen is designed to be a JavaScript ES6 language that includes OCaml's pattern matching and first class functions. Coders everywhere can now create and complete projects on their laptops, tablets, and smartphones while enjoying the expressiveness of emojis. Queen relies on pictures to convey meanings rather than words in the English language.

Queen is also a great way to excite kids about computer science. They will immediately be able to see how fun and creative programming can be. The pictures also help further their understanding. For example, it is easy to understand the idea of "printing" something when it is paired with the printer emoji. Likewise, grasping the difference between None and Some is easier when they are connected to the tangible symbols of no food and some food.

We hope you enjoy seeing your functions come to life as much as we do!

Check out our grammar here!



Features


Emoji keywords

First class functions

Higher order functions

Anonymous functions

Pattern matching

No while loops (pattern matching instead)

No for loops (pattern matching instead)

Static typing

Emojis


πŸ‘‘ - start a function
πŸ–¨ - print
😑 - error message
πŸ•³ - _
πŸš€ - =
🍭 - |
πŸ€” - if
❗️- not
πŸ’πŸΌ - ||
⚑️ - cons
πŸ’© - comment

Example Programs


QUEEN:

πŸ‘‘ string helloWorld πŸš€ πŸ–¨ "Hello World!

JS:

console.log("Hello World!");

QUEEN:

πŸ‘‘ float fib (x: int) πŸš€
    match x with
    πŸ­ [0] -> 0
    πŸ­ [1] -> 1
    πŸ­ πŸ•³ -> (let a πŸš€ x - 1 in let b
        πŸš€ x - 2 in let z πŸš€ fib (a) in
        let y πŸš€ fib (b) in y + z)

JS:

myRecursiveFunction = (n) => {
    if (n > 0) {
        return myRecursiveFunction(n-1);
    } else {
        return n;
    }
};

QUEEN:

πŸ‘‘ int length (l : string) πŸš€
    match l with
    πŸ­ hd ⚑️ [] β†’ 1
    πŸ­ hd ⚑️ tl β†’ 1 + length(tl)

JS:

let l = [1, 2, 3];
let lengthl = l.length;

QUEEN:

πŸ€” (a πŸš€ 0 πŸ’πŸΌ b πŸš€ 0) then a
elseπŸ€” (c πŸš€ 0) then c

JS:

if (a == 0 || b == 0) {
    return a
} else if (c == 0) {
    return c
}

QUEEN:

πŸ‘‘ string reverse (l : string) πŸš€
    match l with
    πŸ­ [] β†’ []
    πŸ­ hd ⚑️ tl β†’ reverse(tl) @ [hd]

JS:

let fruits = [β€˜strawberries’, β€˜bananas’, blueberries’, β€˜raspberries’];
let reversed = fruits.reverse();

QUEEN:

πŸ‘‘ int change (n : int) πŸš€
(let quarters πŸš€ n/25 in
let dimes πŸš€ (n mod 25)/10 in
let nickels πŸš€ ((n mod 25) mod 10)/5 in
let pennies πŸš€ (((n mod 25) mod 10) mod 5) in
[quarters;dimes;nickels;pennies])

JS:

var change = function (n) {
  var changeAmt = [],
  total = 0;
  [25, 10, 5, 1].forEach(function(coin) {
    while (total + coin <= n) {
      changeAmt.push(coin);
      total += coin;
    }
  });
  return changeAmt;
};

Errors


Append😑 TYPE ERROR: Both lists must contain elements of the
          same type.


BinExp Add😑 TYPE ERROR: Only numeric types can be added and               subtracted.


BinExp Rel😑 TYPE ERROR: Incomparable types.


Conditional😑 TYPE ERROR: Condition must be a boolean.


Cons Long😑 UNDECLARED VARIABLE: ${this.e} has not been              declared.


😑 TYPE ERROR: ${this.e} must be numeric.


Cons Short😑 UNDECLARED VARIABLE: ${this.e} has not been              declared.


😑 TYPE ERROR: ${this.e} must be numeric.


Exp Id😑 UNDECLARED VARIABLE: ${this.id} has not been           declared.


Exp Print😑 UNDECLARED VARIABLE: ${this.n} has not been             declared.


😑 TYPE ERROR: ${this.string} is not a string.


Exp1 Mult😑 TYPE ERROR: Only numeric types can be multiplied             and divided.


Exp2😑 TYPE ERROR: Only numeric types can be negated.


Exp3😑 UNDECLARED VARIABLE: ${this.n} has not been declared.


😑 TYPE ERROR: ${this.n} must be numeric.


Funcall😑 ARITY ERROR: ${this.args.length} arguments provided           and ${func.parameters.length} were expected.


😑 UNDECLARED VARIABLE: ${this.args[i]} has not been           declared.


😑 TYPE ERROR: Expected ${this.args[i]} to be          ${func.paramTypes[i].toString()}.


😑 UNDECLARED VARIABLE: ${this.id} has not been           declared.


FunDecl😑 TYPE ERROR: Function was expected to evaluate to            type ${this.returnType}.


Let Let😑 VARIABLE DECLARARTION ERROR: ${this.exp} cannot be           assigned to a variable.


List😑 TYPE ERROR: List elements must all be of the same type.


Match😑 UNDECLARED VARIABLE: ${this.id} has not been           declared.


MatchExp😑 TYPE ERROR: Must match to something of the same             type.


Pattern Pattern😑 UNDECLARED VARIABLE: ${this.e} has not been                  declared.


😑 TYPE ERROR: ${this.e} must be numeric.


Syntax Diagrams


Program
FunDecl
Binding
Body
Exp
Pattern
Cons
Funcall
patternElements
List
Match
MatchExp
Let
Append
Binexp
Exp1
Exp2
Exp3
Conditional
logical
Type
boollit
id
idrest
keyword
char
escape
charlit
stringlit
numlit
addop
mulop
relop
space
comment