DEV Community

Caroline Mwasigala
Caroline Mwasigala

Posted on

Statically Typed Vs Dynamically Typed Programming languages

The juiciness of any concept lies in its roots.Everything Evolves and types are not exempt. Simply put types are classification or characterization of things.

In this article we are going to briefly expound the concept of types and the categorization of languages based on types. I will use C# in the code block examples.

Variable and Type checking are crucial concepts when it comes to understanding the difference between statically typed and dynamically typed programming languages.

What is a variable?

A variable is a name used to represent a memory location for information storage. The best analogy for this is a cup. A cup is a rounded container that holds substance. substance represent data, container represents memory location and the word cup represents a variable name.

What is type checking?

Type checking is a system of checking if the assigned data contains the expected data type. The system is called Type System.

The difference between the two concepts boils down to variable declaration. For statically typed languages, the enforcement is on explicit declaration of variables with their types. Type checking happens during the compilation time, in turn this ensures code optimization.

int score=5;
string name="Myspexg";
double amount = 12.3;
Enter fullscreen mode Exit fullscreen mode

While dynamically typed languages allows implicit variable declaration.It gives programmer flexibility but it’s error prone.Type checking usually happens at the runtime

var score=5;
var name="Myspexg";
var amount=12.3;
Enter fullscreen mode Exit fullscreen mode

Examples of Dynamically typed language is JavaScript, PHP etc. Examples of statically typed language is C,Java etc

Lot of programming languages are hybrid meaning they are both statically and dynamically typed. i.e C#, Python etc

Top comments (0)