James's Ramblings

Programming languages

Created: January 11, 2025

Static vs. dynamic typing

In a statically typed language, the type of a variable is known at compile time.

In a dynamically typed language, the type of a variable is only known at runtime.

Strong vs. weak typing

In a strongly typed language, types are enforced and not coerced.

In a weakly typed language, types can be coerced. Coercion is the process of changing an object’s type to another type implicitly.

Polymorphism

In object-orientated programming (OOP), polymorphism is the ability of different objects to respond to the same message in different ways.

More formally, polymorphism is the provision of one interface to entities of different data types.

For example, a Toyata and a Ford are both cars. They both have a drive() method, but the implementation of drive() is different for each car.

In programming language theory, polymorphism is the use of one symbol to represent multiple different types.

Consider the + operator in Python. It can add two numbers together, or concatenate two strings. The fact that the + operator can have different meanings depending on the types of the operands is an example of polymorphism. The + operator is said to be polymorphic.

There are several different types of polymorphism.