The type system

This chapter is pretty big, because it contains a lot of basics you may encounter further along the article. Rust may have a few interesting types not found in languages you know, and those may have some interesting properties. As such, it pays to learn about them before diving into the more advanced topics.

Rust is a statically typed language. That means that any element, be it variable, struct, field or other, has a single type which can't change during its lifetime. Now that is nothing special by itself, but programming languages are mostly divided into either group of statically or dynamically typed. Typically, statically typed languages map much closer to what is happening inside the hardware, since there's much less abstraction involved. This comes with advantages such as speed, runtime size and correctness, but forces you to think about your implementation more and results in more code for the same task. In my opinion, that is a trade-off one should always make, except maybe for prototyping.

But Rust goes one step further than most other languages and uses types as the general core feature most other features are built upon. You will see what I mean over the course of this article, but for now, let us take a look into the type system itself.