Mass Programming Language (1) Inception

Next Post

Three weeks ago, I was working on the implementation of an interpreted language, written in C#. The new language is called Mass (dedicated to  @MArtinSaliaS):

The current solution has three projects: a class library, its tests, and a console program, mass.exe, that launches Mass programs

You can run a


The classic Hello world source code:

println("Hello, world")

An example with classes and objects

class Person
	define initialize(firstname, lastname)
		self.firstname = firstname
		self.lastname = lastname
	define getName()
		return self.lastname + ", " + self.firstname

adam = new Person("Adam", "TheFirst")


An example with access to .NET types and objects:

dirinfo = new System.IO.DirectoryInfo(".")

for fileinfo in dirinfo.GetFiles()

The idea is  to have a dynamic language that leverages an underlying language provided with a rich class library and ecosystem, like in AjSharp and other of my projects. Before Mass, I was working on:

– Implementing Python in C# (see PythonSharp)

– Implementing Ruby in C# (see RubySharp)

– AjSharp (see repo and post)

But this time I wanted to implement something with simple sintax and semantic. Indeed, I was playing with “simple” ideas for a compiler over Javascript, see SimpleScript (1) First Ideas.

Then, with Mass, I deliberately wanted to avoid:

– Multiple commands in the same line (I discarded ‘;’ like in Ruby)

– Syntax based in spaces and indentation (Python discarded)

– Function invocation using only the name; Mass impose the explicit use of parenthesis (Ruby discarded; Mass is like JavaScript)

– Base values and classes (integers, strings, lists, etc…) having a crowd of methods (like Ruby and Python). No, Mass prefers to expose and use the underlying language/class library.

Then, I wanted:

– Functional values, as first-class citizens, like in JavaScript. So, having to put explicit parenthesis to invoke a function allows me to use the name of the function as a functional value

– Dynamic objects: each object can be extended at any moment, with new instance variables, object functions, a la JavaScript

– Syntax based in lines: each command has its own line. No command separation

– Syntax based in keywords: the end of a command list is marked with ‘end’, no braces

– As far as possible, only one way to do something, instead of the many ways motto a la Perl

– Complete keywords, then ‘define’ instead of ‘def’

– Simple inheritance at classes. But Mass could be expressive without written classes, using native classes from .NET framework and other libraries. It could be used as an scripting language.

– Explicit setting of variables that are out of the local scope (a topic for next posts)

– Variable scope by file, like in the require of JavaScript/NodeJs/CommonJS

– Module by file, with a require that automatically searches in directories, a la NodeJs/CommonJs. Notably, Mass can consume node_modules folder, so Mass module can be published and installed using NPM!

– Package manager, using NPM. You can use package.json to declare the dependencies, and publish new modules at NPM (using ‘mass-‘ as the suggested namespace).

In upcoming posts, I will write more details about implementation, guiding design ideas, examples. But now, you can see the code and the test examples at public repo. And yes, all was written by baby steps, using TDD.

Keep tuned!

Angel “Java” Lopez

2 thoughts on “Mass Programming Language (1) Inception

  1. Pingback: Mass Programming Language (2) First Expressions | Angel "Java" Lopez on Blog

  2. Pingback: Mass Programming Language (1) Inception | MVPs de LATAM

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s