-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the mafiascript wiki! Mafiascript is a dynamically-typed, interpreted programming language. It takes a more functional approach to things - there aren't any classes or complex data types in mafiascript, everything is practically an object
!
- Structure of the language - list of expressions and statements
- Memory management in mafiascript - does it have a garbage collector?
- More examples of mafiascript in action
If you've looked at the examples page then you will notice that mafiascript and javascript are pretty damn similar. The main reason for this is that I adore javascript, and I wanted to see how difficult it would be to create a similar programming language. That being said, the languages may look similar, but a lot of the main concepts are different. Here's a list of all the differences (other than the missing garbage collector)
The most obvious difference. Mafiascript combines JSs' for
and while
keywords. The loop
keyword can be used as a for
loop and as a while
loop - depends on how many arguments you give it. And also, arguments are separated by a comma (,
) while in javascript they are separated by a semicolon (;
).
loop (before, during, after) {}; // Regular for loop in javascript
loop (during) {}; // A while loop in javascript
Another obvious difference. I like my code consistent.
Just like in javascript, every value in mafiascript is an object
. All values in javascript can have custom properties - numbers, strings, arrays, etc. The difference is in prototypes
. In javascript you have prototypal inheritance, which means an object can inherit another. In mafiascript, all objects are different from each other. This means that there are no constructors. We can pretend like a function is a constructor, though.
const objectCreator = (a, b) => {
const obj = {
"a": a,
"b": b
};
obj.doSomething = |obj| => obj.a + obj.b;
return obj;
};
const obj = objectCreator(1, 5);
print(obj.doSomething());