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.

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 access to primitive
structures like arrays (just use collections), and 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 .
42 offers powerful support for aliasing control and immutability, helping in mixing the two styles in an easy and natural way.

42 offers (well, will offer) automatic parallelism: thanks to immutability and aliasing control, many patterns of normal sequential code will be safely executed in parallel.

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 '' is sugar for '',
and so on. Note how '' is a 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.
First class meta-programming is the most important feature of 42.

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;
casts; 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

< { //define a class Person
S name //fields
Year age
//in 42 fields are seen as getters and setters,
//thus there is no need to define those.
//Also, no need to write down a constructor:
//Data defines a 'name, age' factory for us.
//Data generates implementations for methods like
//equality, hashCode and conversion to string.
method //instance method definition
S sayHi(S to){ //here we use {..return..}
if to==this.name() ( //no parenthesis on if/while
return S"Oh, you are called "[this.name()]" too?"
) //string interpolation
return S"Hi, my name is "[this.name()]
" and I'm "[this.age()]" years old"
}
class method//This == Person here,
This bob() //simple method instantiating a Person
This(name:S"Bob", age: 23Year)
}
]]>