Save money in your next project by opting for strict language early?

29 October 2024

Antti Luukka

Antti Luukka

Senior Developer

"use strict"

Preface

Did you know that choosing a language (or its type system) might have a significant impact on project finances in the long run? Even though it may seem like a little technical detail, or just a single developer preference, choosing a language with a too loose type system for your project might reduce development efficiency and maintainability as the code base grows. In this article we will focus on the benefits of more strict type systems and why you could prefer them in your team’s upcoming project.

Dynamically typed languages have been dominating the web development space, at times due to lack of real options, but most importantly due to their accessibility, flexibility and ability to execute them without an extra build step. This flexibility however has its pros and cons, and for some dynamically typed languages there has been a push to implement stricter typing systems to help with complexity that today's applications face.

Picking a language for a new project

Discussion about language options and preferences comes up when it’s time to boot up a new project, or add a new significant part to an existing one. All languages have their strengths and weaknesses, and can often be used to achieve similar results to an extent within their environments. One aspect when choosing a language for a project, is to choose between a language with a more strict type system over a flexible one.

Benefits of more strict type systems

Flexibility is a good thing, as it means speed, right? Well, speed is good for a quick sprint, but when it comes to a marathon, it’s a different story. If the aim is to build anything bigger than a small app or a quick prototype, we should likely sacrifice some speed at the beginning to be able to keep pace later in the race.

For larger projects, it’s important to have some safety nets by design to reduce bugs and fix them quickly. Strictly typed language will be part of this safety net by reducing human error as developer tools are able to point out obvious errors during development. The trade off is that you spend time “fighting with types” as strict types force you to be more verbose and explicit with your code.

Strict types slow you down, but this is only true in smaller projects or in isloation. When there are a lot of moving parts communicating with each other, you want these parts to speak a strict common language to avoid miscommunication, or your project as it grows, may start to lean more and more towards bug hunting that takes away from feature development.

Using strict typing for AI and automation

Talking about human error, a new benefit when choosing more strictly typed language is that AI tools will greatly benefit if you put the time into your types, and will be a better copilot helping you to get things done a bit faster. The types will provide more concrete context for Large Language Model (LLM) based tools to deduce what you want. Just like types helps your co-worker (and your future self) to understand your code, so it does with LLM’s as well.

Long-term savings with strict types

Strict types save money in the long run as your project grows. Your developers will more likely enjoy working on a larger code base, as there will be more confidence in making changes and less risk of introducing bugs. It’s easier to onboard developers, as the types give more context and built in documentation. Some tools will also work drastically better, which in turn speeds up development. As you spend less time debugging, something that can’t really be measured is, you might have lost a lot more users due to things not working as expected. You can count the audibly frustrated or happy users as they are your invested users, but you never know about the ones that bounced early due to things going wrong.

The industry trend toward stricter type systems

For a while now, there has been an accelerating trend to opt-in for more strict type systems, as some languages have implemented ways to enforce types. JavaScript, Python and PHP, just to name a few popular, are natively dynamic languages and were not necessarily designed for large feats. All of these have still gained traction due to being accessible for new developers, and arguably fun and quick to use in small projects due to their flexibility. Naturally, due to the accessibility, these languages have taken their space and have grown vibrant communities around them, which in turn keeps fueling the fire, but even after all the success, there has been a call for stability in evergrowing complexity in applications.

To simplify and sum up some pros and cons for mid to large-size projects:

Pros:

  • Empowers AI and other tools
  • Helps automating documentation and works as in-code documentation
  • Better team collaboration and multi developer experience
  • More robust when moving things around
  • Less debugging and maintenance costs due to reduced human error

Cons:

  • Slows development initially
  • Less agile when experimenting or prototyping (strict types can be bypassed in some languages for these purposes)
  • Steeper leaning curve, especially for junior developers
  • Can at times complicate simple tasks

In the long run, this boils down to: happier developers, happier users and saved money.

Conclusion

When choosing a language for your project, it’s important to acknowledge the scale of the project without ignoring the future needs. In many cases, there is absolutely no reason to use dynamically typed languages, as you miss so many of the benefits mentioned above. Some languages, such as JavaScript, support migrating to types later on (TypeScript). In some cases this can even be done incrementally, but if the project has already grown and there are multiple contributors, it will be a miserable journey, and you will most likely end up with unhappy developers, wasted work hours and a code base mixed with loosely and strictly typed mess for the foreseeable future.

Strict type system benefitsProgramming language choiceCode maintainability

Get in touch with us!

We’re here to help and answer any questions you might have. Reach out to us and we’ll respond as soon as we can.

+
Call us!