Back to Blog
incongruent-types.ts

On Strong Typing

Apr 08, 2024

My first meaningful code was in Modula-2 and then C and C++ in grad school.  

All these were strongly typed languages.  

I remember naming member variables m_iPrice m for member, i for integer, etc. 

That’s when IDEs gave you no support in remembering what was what.

After that, I think I may have written some Java. Or I lucked out and skipped over it.  šŸ˜±

Somewhere in the late 2000s, I discovered Python. 

Python was truly awesome. I didn’t have to bother with squiggly brackets or a bunch of other things, including types.

It would all figure it out by itself.  

It was marvelous and I did not give much thought to the lack of strong typing.

15 years later, now having built some projects in Python that have spanned almost that whole duration I have learned a few things:

  • When I was writing code on a large project alone, the lack of typing did not appear to be a big deal. 
    The types were pretty clear to me, and because I was experienced and careful, I barely made any typing mistakes on an ongoing basis.  

    (Bravo to me, I’m so great - but not quite - keep reading).
  • When I started adding engineers to these projects, I saw runtime-type mistakes.
    I told myself it was because they were less careful and less experienced.  

    Probably partly true, but that was not the whole story.
  • The lack of types was an absolute disaster when we needed to do bigger refactorings. 
    Even with some static analysis, it was nearly impossible to refactor code in any sensible way.

    There was just no way to have certainty that something you change over here will not break something way over there.

    Now that was suddenly a big freakin' problem. šŸ’£

During the last 7 years at Uber and Included Health I mostly wrote Go code.

Returning to this issue, with some added experience, I have now gained an appreciation for the utility of strongly typed languages.

My takeaways:

  • I will no longer consider code with no types (or type hints) fit for production.  
  • If I’m working on an existing project in either Python or Javascript, I will make sure mypy or Typescript are used.  (I refuse to use Ruby, but that’s a story for another time).
  • When starting a new project, I would strongly consider a typed language. While the add-on systems work, they are rough around the edges, especially when integrating with “other people’s code,” which may or may not provide good typing support.

Don't miss a post!

New postsĀ to your inbox.Ā 

We hate SPAM. We will never sell your information, for any reason. Unsubscribe anytime.