Skip to content
GoogleFeud edited this page Jan 11, 2021 · 4 revisions

Welcome

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!

Mafiascript vs Javascript

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 loop keyword

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

Required semicolon

Another obvious difference. I like my code consistent.

No object prototypes

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());
Clone this wiki locally