Mylange Programming Language
"Mylange; it rhymes with organge."
Welcome to the Mylange Programming Language!
This language is developed by Myriware as a simple yet powerful
language that can be used by all, especially here at Myriware.
So, what is it? Mylange is both a functional and object oriented programming language.
It takes many elements from different languages and weaves them together.
Mylange is a strict-typed language.
The Files
The most important part of Mylange is storing it in files, which are read by
the Mylange File Interpreter. Alternitivly, for developement uses, the
Mylange Linear Interpreter is used, much like Python's CLI Interface.
All mylange files are defined by the .my (or .myl) extention.
Installing the Interpreter is not standardized yet, since it is still in developement.
Currently, Mylange is built on a Python script that analyzes the code and runs it.
However, binaries for mylange can be found here, which are compiled
from the Python code. This is ineffienct right now, however it is easier for developement.
Once far enough, it will be re-programmed in C/C++ for universal use.
Mylange features a Rust-like garbage collection system. All variables or parameters are assigned
to a scope block. When the block ends, the values inside the scope are all removed, and the memory
is free.
Mylange Interpreter works on an extensive caching system, which allows for easier interpretation
of string, chars, and bracket blocks. They are, however, stored together in one Blockings Map,
and there is only one counter for the combined efforts. Each string, char, or block gets replaced
by a hex code, looking like 0x00000000. Due to the structure, please refrain from
using more than 4.294967296*10^9 strings, chars, and bracket blocks, as it will most likely break the system.
Include Statement
The first thing that you should learn is how to get access to builtin functions.
This includes any function that Mylange provides. All functions belong to a package,
with an ID that is normally short and an abreviation of something.
In order to use the package, you need to include it, denoted by:
#include <PACKAGE_ID>;
For example, the io package provides ways to input and output into the
terminal, such as the famous print function. After the package is
included, the function can be called in the default function calling way. The
function lives under the package, so a prefix of the package ID and a dot is required.
For example, to print "Hello world", the following code is used:
#include <io>
;
io.print("Hello world!");
Types
The beginnings of this language are the types that data can be stored as.
There are a few main types, which are:
nil |
an empty value, like null. |
nil |
boolean/bool |
true or false. |
true or false |
integer/int |
Any integer number. |
12, -12 |
character/char |
A single character. |
'a', 'b' |
string/str |
A combination of different characters. |
"string" |
array/arr |
A list of items. |
[1, 2, "three"] |
set |
An object made of key/value pairs. |
(key=>"value", some=>"thing") |
callback |
A function. |
int (int a, int b) as { return a + b; } or &function@{..} |
Aside from these are special types, like casting, this,
dynamic, and union.
These are not types that users will call, they are more code orientated.
Castings are objects made from user-defined classes. This is used within class castings
and are always linked to the keyword this.
Dynamic is used for loops, like when a list has mixed types inside.
Unions are not implemented.
Some types can be artitectured, meaning, you can define what the elements inside them
represent. For example, arrays and sets ordinarily can have any type inside them.
However, if you artitecture them, then they can only have certain elements inside them.
The way to do this is to follow the type name by the architype inside angle
brackets (<>). So, an array of only chars can be represented as
arr<char> letters => ['a', 'b', 'c'];
arr<arr<int>> co_ords => [ [1, 2], [3, 4], [5, 6] ];
Variables
Storing variables is a basic task, but one that is crucial to programming.
Setting variables in Mylange is simple. It takes three parts: the type, name,
and value. First goes the type, then the name, an arrow =>, then
the value.
For example, storing a name would look like this:
str code_name => "Mylange";
Conventionally, local variables are snake case (all lowercase, seperated by underscores).
Parameters are camal case (the first word lowercase, joined words are capitalized),
Classes are pascal case (like camal, but the first word is capitalized),
and global variables are upper-snake case (all uppercase, seperated by underscores).
The value of a variable must always match the decared type, or an error will be thrown.
Values can be reset in the same way as creating it, barring the type.
reset_var => "New Value";
You cannot use the resetting method to declare a varibale first.
Functions
Functions allow for code to really be useful. There are three things to any function:
the input, logic, and output. The inputs are called parameters, and the output is called
a return value.
To defined a function, the def keyword is used. Following is the return type,
name, then parameters enclosed in parenthesis. The parameters are simply a type followed
by the name. Then, the as keyword is used, before the logic.
Typically, the logic is confined in brackets ({}), but small functions
that only need a single line do not need them. Then, the return statement
is used, which ends the function.
Function do not always need parameters, not do they need returns. If you wish to
ommit a return, then the return type of the function should be nil.
Conventionally, all functions are pascal case.
Here are some examples of functions.
def int Add(int a, int b) as
return a + b;
def nil Greet() as {
str input => io.input("Name> ");
io.print("Hello " .. input .. "!");
};