The M2 programming language

Last available version: 1.5-20110205

M2 is a new language for everyday programming: a clean syntax, simple as a scripting language, severe as a strong typed language, efficient like C. Those who know Modula-2 (from whom the name), Oberon or Pascal will find in M2 many similarities. Basically, M2 is a cross compiler from the M2 language to C. Array and dynamic structures are allocated automatically and deallocated when no more needed. The run-time checking prevent array index overflow and null-pointer dereferencing, so improving the robustness of the program. All the programmer must take care of is the algorithm, all the rest is in charge of the language. Features:

M2 is still a young project, and it lacks on many areas. M2 is a procedural language, but its "postfix" functional notation open the way to the object oriented programming paradigm. Unicode isn't supported, but the iconv library lets to convert strings between any charset representation.

Currently tested on: Red Hat Linux 7.3; Slackware 10.0; MS Windows 98 + Cygwin 1.5.

Hello, world!

Suppose we have this source program in the file hello.mod:

MODULE hello
    print("Please, enter your name: ")
    name = input()
    print("Hello " + name + ", your first program is working!\n")

then, to compile and execute the program we give this command (bolded characters are those you have to type-in):

$ m2 -r hello.mod
Please, enter your name: Umberto
Hello Umberto, your first program is working!

More about M2


The M2 language and the M2 developing system are released under a BSD-style license (see the file LICENSE for details).
The M2 compiler generates C source compilable with the "gcc" compiler, released under the GNU GPL license.
Some of the C libraries used by gcc are part of the GNU operating system and are released under the GNU GPL license.
The conservative garbage collector "gc" and the developing system "Cygwin" are released with their own license, but basically they can be used freely.
Some of the libraries provided with the M2 developing system are interfaces to other software that can or can not be installed in your system: if you plan to use that software, please read the respective license.

Umberto Salsi
Site map
Still no comments to this page. Use the Comments link above to add your contribute.