In his post When Static Types Mask Code Smells Jared White reflects on a discussion about TypeScript and makes the case that static typing isn't a panacea. It does not fix all your code problems. Indeed, it does not!

Jared closes with this observation:

Every programmer and every project is different, with unique needs. We should celebrate a diversity of approaches and techniques—not expect the industry at large to fall in line with a single perspective.

This is where I want to nitpick his analysis a little bit.

It is not that every programmer or every project has unique needs. From one area to another in one codebase we find different needs.

The core of that calculation module that has been driving the whole business for years. Different needs then the experimental service being tested on pilot customers. Different needs then the new web app component. Different needs than the high-performance logging engine.

TypeScript's superpower that it supports different needs within an application (even within one file or class!) with different levels of static typing - by allowing for Gradual Typing. And it is not just TypeScript. Ruby has it with RBS or Sorbet. Python has it with type hints. Folks are proposing it for Elixir, heck, even for Java.

Gradual Typing was invented by Walid Taha and Jeremy Siek. Jeremy Siek has a beautifully simple slide in his TFP 2013 keynote about the goals and benefits of gradual typing:

Gradual Typing offers both reliability and efficiency as well as productivity

Enjoy the benefits of static & dynamic typing in different parts of the same program

Apparently, the only problem with Gradual Typing (and I found this while looking for languages that support the concept) is...

Google search for "gradual typing is"

🤷🏻

gradual typing (1) typescript (1)

Social

3 Likes

Mike Gehard Jared White supports the Open Web Kevin Kim

2 Replies

Jared White supports the Open Web Jared White supports the Open Web

That might be one of the most thoughtful blog post replies I've ever seen! 👍 I really appreciate what you have to say. I think I mostly agree with what you're describing…the major caveat being that I have yet to see gradual typing promoted within an org's culture.... source

Brandon Weaver Brandon Weaver

We're always hiring... source

These are webmentions via the IndieWeb and webmention.io. Mention this post from your site:


Except where otherwise noted, content on stephanhagemann.com is licensed under CC BY 4.0 by Stephan Hagemann