First, read in any order those introductions

Why 42

42 is a new programming language, whose name is inspired by The Hitchhiker's Guide to the Galaxy. The language's goal is to allow the transparent cooperation and composition of millions of libraries at the same time, while providing a much higher security that any other widly used language.

In 42 you will be able to import libraries just by naming them and to compose them in your code without worrying about their dependencies. Normally libraries are big monolithic things, coming from outside and manually imported/installed. The user has little control over the library code, and the library has no influence over the importing context.

In 42 libraries are usually much smaller and are first class entities, that can be manipulated as values, loaded, stored, modified, adapted, saved or simply used. You will write code that manipulate libraries, but more importantly you will use libraries that manipulate libraries in non-trivial ways. Indeed in 42 manipulating libraries is so natural that is convenient to think of your own code as a library that you offer to yourself only.

42 enforces a high level of abstraction, thus there is no concept of null or default initialization. While is possible to write in a fully functional style in 42, usually 42 programs mix mutable datastructures with aliasing and deeply immutable data . By using reference and object capabilities, 42 supports mutability and aliasing control, helping in mixing the two styles in an easy and natural way.

Reference and object capabilities enforce the correctness of caching, representation invariants and parallelism.

Pure and fair Object Oriented language

42 is a pure object oriented language, where every value is an object. This means that:

  • Numbers are objects, so thay can have methods like «» or «».
  • All operators are just method calls, thus «» can be sugar for «», and so on. Note how «» is just an ordinary method name. Any class that offers the method supports the operator.
  • Classes are objects, so when you write «» you refer to the method «» offered by the object denoted by «». class objects are just objects, and you can also store them in local bindings if you wish, as in «»
  • The code is an object, but only at the granularity of Libraries; that is, balanced pairs of curly brackets representing classes (or interfaces) with methods and nested libraries. This is useful for meta-programming, which we will see later.
  • Differently from other pure object oriented languages, in 42 all objects have the same treatment, both syntactically and semantically. For example «» This is a declaration for a local binding «», using the string class «» and the method operator «», used as string (or in general sequence/collection) concatenation. Coming from another programming language, you may be surprised that we have to write «» before «» and «». This extra verbosity is needed to provide fair treatment to all classes. (see more in Basic classes) In 42 we do not give preferential treatment to special objects/classes. In this sense, we consider most other languages to be discriminatory. They give priority to their "preferred" version of numbers and strings, and this puts into a position of unfair disadvantage library code trying to define its own kinds of numbers/strings. Instead in 42 you may encounter strings like «» or «». The same for numeric classes: to talk about a street, 20 meters long, you would write «». Note that we write the class name after the number, while usually the class name is before. 42 is a little incoherent in this point, both for better readability and because «» would be considered an identifier by the parser. You may encounter «», «», «», «», «», «», «», «» and many other numeric classes.

A simple language

We believe 42 is a simple language, where all classes are final and interfaces are the only instrument to obtain subtyping. Moreover, 42 does not offer many controversial features usually found in other programming languages, including: (method) overloading; threading; numeric conversions and coercions; var-args; primitive types and automatic (un-)boxing; inner classes; arrays; generics; scope-hiding of local variables/bindings, methods and fields; closures/lambdas and null.

Learn through examples

If you like to learn by examples, here you can find snippets of code in 42 and their equivalent version in Java. We format the code so that, line by line, you can see the differences.

Imports and comments

String and numbers

Hello world

Methods and Classes

Control structures

b (return /*...*/)
var acc = S""  //explicit 'var': can be updated
while Bool.true() ( //booleans are not constants
  if acc.size()>50I ( //Size: type of indexes 
  acc ++= S"step"
b) {return /*...*/;}
S acc= ""; //updatable is default, but can be final
while (true) {
  if (acc.length()>50) {
  acc += "step";


 names= List.of("Fred","Mary","Mark");

List ages= List.of(20,23,22);

for(String n : names){

for(int i= 0; i friends= new ArrayList<>(Arrays.asList(
  new Person("Fred",20),
  new Person("Mary"23),
  new Person("Mark"22)

List moreFriends= new ArrayList<>();
for(int i= 0; i

Now, dig into the tutorial!

Let's board the Vogon ship