Read an introductory tutorial. Browse the complete Mars language reference, or the library reference.
Get started with Mars (Linux only). Download the compiler, in source or binary form, and begin building your own Mars programs.
See a handful of small Mars programs.
Mars is a very simple imperative programming language with a catch: all of the functions and expressions are pure.
That means when you call a function, it is guaranteed to have no side-effects: it can't mutate its arguments, modify global variables, or perform input/output. But unlike other pure languages, Mars gives you all the nice features of imperative programming, like local variable assignments and loops. The compiler also automatically converts inefficient copy-and-update operations into in-place destructive operations.
Mars also has some other nice features borrowed from functional programming: a strong static type system, algebraic data types, pattern-matching switch statements, and higher-order functions.
Mars is an experiment, not a full-featured programming language. You can use it for playing with the boundaries between imperative and declarative programming, but we don't recommend you write real software with it.
sudo dpkg -i mars_1.0.0-1_amd64.deb.
sudo apt-get remove mars.
bzr branch lp:mars.
Simple Mars programs look a lot like Python:
import prelude def main() :: io Num: print_string("Hello, world!\n") return 0
But Mars is statically typed, and forbids side-effects (other than input/output effects, in functions specially annotated with
io, as seen here).
For example, when you call
array_concat, you concatenate two strings, without modifying either of them (just like
+ in Python):
hello = "Hello" return array_concat(hello, " world")
However, Mars is smart enough to realise that you won't be using
hello again, so automatically reuses the memory for that string, instead of copying it.
Learn how to write Mars with the tutorial, or learn about the automatic memory reuse system.
Here are several complete Mars programs. These are all included in the source distribution, under
All samples on this site are in the public domain.