Similar to many other objected-oriented programming languages, Julia supports a hierarchy of abstract types. Abstract types are typically used to model real-world data concepts; for example, an Animal could be an abstract type for a cat or dog, and a Vehicle can be an abstract type for a car, truck, or bus. Being able to group types together and give the group a single name allows Julia programmers to apply generic code that is common to those types.
Abstract types are often conveniently defined in a type hierarchy for a specific domain. We can describe the relationship between abstract types as parent–child, or more technically, an is-a-subtype-of relationship. The terminology for the parent type and child type is supertype and subtype respectively.
A unique feature of Julia's design, unlike the majority of other languages, is that abstract types are defined without any fields. For this reason, abstract types do not specify how data is actually stored in the memory. It may seem somewhat restrictive at first glance, but as we learn more about Julia, it will seem more natural when used in this design. As a result, abstract types are used solely to model behaviors for a set of objects rather than to specify how data is stored.
In the following sections, we will work through an example of building an abstract type hierarchy.