Emojicode Documentation 0.5
Guides Language Reference Package Index

The Basics

Emojicode is a language that aims to provide the most modern and powerful features to make it easy, fast and fun to write programs. These powerful features include classes, optionals, which can handle the absence of a value, generics, closures and much more.

Emojicode is a strongly typed language, which means that the compiler will verify that all of your operations are correct. This, for instance, prevents you from treating a number as a list of texts.

Although Emojicode only uses Emojis to express the programโ€™s structure, it is similar to programming languages you might know, like C.

Emojicode was designed to allow the development of platform independent applications by running them inside a virtual machine. Your code is first compiled to bytecode by a compiler and can then be executed. The reference implementation of such a virtual machine is called Emojicode Real-Time and can, as the name suggests, execute your code rather fast.


If you need guidance on how to use the compiler and the Real-Time Engine see โ€œCompile and Run Your First Programโ€, which is a short tutorial on writing applications in Emojicode.


You can include non-executable text in your code by marking it as a comment. Comments begin with ๐Ÿ‘ด and end at the line break.


๐Ÿ‘ด This comment ends at the end of the line. Exactly here

Multiline comments starts with ๐Ÿ‘ต and ends with ๐Ÿ‘ต and can contain line breaks.


๐Ÿ‘ต This is a multiline comment. You can even make
line breaks. ๐Ÿ‘ต

The ๐Ÿ block

Emojicode needs to know what your program should do when it starts, therefore it requires you to provide a ๐Ÿ block. Hereโ€™s an example of a ๐Ÿ block.

๐Ÿ ๐Ÿ‡
  ๐Ÿ‘ด Get things up and running here...

The ๐Ÿ block can also return an integer which is then used as the exit code:

๐Ÿ โžก๏ธ ๐Ÿš‚ ๐Ÿ‡
  ๐Ÿ‘ด Get things up and running here...

  ๐ŸŽ 0 ๐Ÿ‘ด Return a code here.

It occurs at the document level of a document.

When to use Emojis?

Thereโ€™s sometimes confusion when emojis are used. Basically itโ€™s very simple:

All type, method and initializer names are emojis. On the other hand variables cannot include emojis but must be any combination of characters that cannot be confused with numbers.


Variables pair a name, the variable name, with a value. The variable name can consist of any sequence of characters but may not contain spaces or emojis and may not begin with a number.

There are two types of variables: normal variables and frozen variables. Frozen variables differ from normal ones in that they cannot be changed after they were initially set.

๐Ÿฆ Declaring a Frozen Variable

The easiest way to declare and set a frozen variable at once is to use ๐Ÿฆ.

๐Ÿฆ daysInDecember 31
๐Ÿฆ approximationOf๐œ‹ 3.14159265359

The above code sets the variable daysInDecember to 31 and approximationOf๐œ‹ to 3.14159265359. These variables were declared as frozen variables as they never change.

The compiler infers the type of the variables from the values given.

๐Ÿฎ Setting and Declaring a Variable

To declare or change a normal, changeable variable you should use ๐Ÿฎ. If the variable you want to set is already declared its value will be changed, given that it is not frozen; in that particular case an error message would be emitted. Otherwise the variable is declared in the current scope.

๐Ÿฎ moneyLeft 20
๐Ÿฎ numberOfTimesโ€œSmokeOnTheWaterโ€WasPlayed 20348292837483929

These variables were justifiably declared as changeable variables because they obviously change often. You should however always prefer frozen variables if you donโ€™t intend to modify the variable.

๐Ÿฎ can also be used directly followed by an emoji, which is a special use and called assignment by call. Assignment by call is described in Classes & Value Types.

๐Ÿฐ Declaring Variables

You can declare a variable yourself regardless if a variable with the same name was declared in the parent scope but you may not declare a variable more than one time.

๐Ÿฐ variableName variableType

variableName must be a valid variable name. variableValue may be an expression of any type.

After you declared the variable in the local scope you can use ๐Ÿฎ to set it to a value. The compiler will throw an error if you try to access an uninitialized variable. Optionals are automatically initialized to Nothingness.


Beware of that ๐Ÿฐ can shadow variables from parent scopes and can, for example, make instance variables inaccessible.


Variables are only accessible from the scope in which they were declared. Every code block (everything between a ๐Ÿ‡ and ๐Ÿ‰) defines a separate scope, which disappears once the block was executed:

๐Ÿ ๐Ÿ‡
  ๐Ÿฆ work ๐Ÿ”คWork It Harder Make It Better๐Ÿ”ค
  ๐ŸŠ ๐Ÿ‘ ๐Ÿ‡
    ๐Ÿ˜€ work  ๐Ÿ‘ด work is accessible here
    ๐Ÿฆ doIt ๐Ÿ”คDo It Faster, Makes Us stronger๐Ÿ”ค
  ๐Ÿ˜€ work  ๐Ÿ‘ด work still works, of course
  ๐Ÿ˜€ doIt  ๐Ÿ‘ด doIt is no longer accessible here

You cannot access scopes beyond the method or initializer from your code. Nevertheless, you can access the object scope in instance methods and initializers. Closures are also considered an exception from this rule. Youโ€™ll learn more about these two kinds for special scoping in Classes & Value Types and Callables.

Numeric Literals

Integer literals can be written in

You can use _ within integer literals to improve readability:


The . can be used as decimal separator to create a ๐Ÿš€.

Number Types

There are only two numeric types in Emojicode:


Emojicode has a type to represent Boolean values: ๐Ÿ‘Œ. A boolean value can either be true or false. A true value is created using ๐Ÿ‘ and a false value is created using ๐Ÿ‘Ž.

In the example below two variables are set to a boolean value.

๐Ÿฆ emojicodeIsTheFunniestLanguage ๐Ÿ‘
๐Ÿฆ phpIsAsCool ๐Ÿ‘Ž

Symbol literals

A Symbol is a single Unicode character represented by the symbol type ๐Ÿ”ฃ. The symbol type can represent any character defined in Unicode.

You can include the symbol in the source code file by prepending ๐Ÿ”Ÿ before the desired symbol. This is called a Symbol literal.


๐Ÿฆ percent ๐Ÿ”Ÿ%

Including Other Source Code Files

An Emojicode program is always compiled from a single file. Nevertheless, you can include other source code files. Basically, this just inserts the code from the file at the point where you included it.


๐Ÿ“œ string

string must be a string whose value is a path to another Emojicode source file. The path is relative to the directory which included the document with the ๐Ÿ“œ statement.


Do not use this method to share code across projects. If you have written really fancy code, create a package, which you can easily make available to other people.

Next โ†’
Want to improve this page? You can edit the source on GitHub and send us a pull request!