Part of the TechLab_Report19

Back to overview

Statically typed languages

Static type checking is the process of verifying the safety and reliability of a program based on analysis of the program’s source code. While we’ve had statically typed languages for a long time, in recent years more advanced statically typed languages have become a common choice for web and mobile front-end development. The dynamic, runtime type checking of traditional JavaScript is being replaced with static type checking at compile time in languages like ReasonML, Flow, Typescript, or Elm.

So, why the change? Statically typed languages can bring a number of benefits. Types take what used to be implicit in a dynamic language and make it explicit in a statically typed one. They help document intent, and in many cases can replace entire classes of manually written tests that may have previously been needed to ensure the same level of quality in a dynamic language.

Certain statically typed languages are able to analyse the program and make sure it’s ‘correct’ and cannot fail at runtime in an unexpected way. Some statically typed languages also enable tools to fill in gaps and suggest how to complete the jigsaw of a program, increasing programmer efficiency while maintaining correctness of code. Some tools can even optimise code performance based on the types, resulting in a better performing program.

With these benefits, why would you ever use dynamic languages? Depending on the use case, you might be willing to trade off correctness for being able to rapidly prototype an idea without thinking of every single eventuality. In these instances, a dynamic language may actually be a better fit to avoid jumping through unnecessary hoops to solve a problem. Switching to statically typed languages will also likely demand a different approach to the code itself. Patterns that the programmer may not be familiar with are used to ensure the code will pass static analysis and subsequently compile.

For code that you want to deploy to production, which needs to be reliable, the explicit statement of intent that’s verified at build time is super-beneficial. This, paired with the guarantee that what is written won’t fail at runtime, makes statically typed languages a great choice for production applications.

Back to overview
Enjoyed our report? Sign up now to our upcoming event on May 16th - “Moving at light speed with continuous delivery”