DEV Community

Cover image for How working with AWS open-source tools made me a better developer
Ivica Kolenkaš for AWS Community Builders

Posted on • Edited on

How working with AWS open-source tools made me a better developer

In the beginning

In the beginning God created the heaven and the earth. The earth began to cool, the autotrophs began to drool, Neanderthals developed tools and to-make-a-long-story-short I started learning Python. Much like our early ancestors benefited from using fire to prepare food, I benefited from using (and sporadically contributing to) AWS open-source tools.

This is a story of how I went from a self taught Python developer with profound dislike of type hints to tolerating and even using them. All it took to convince me is a multi-billion dollar company with tens of thousands of developers.

I am not stubborn and I'm not a duck

Contrary to what the intro paragraph led you to believe, I am not a stubborn person. I'd say I'm opinionated, and my opinion about using data types was formed in my teen years. I was a rebel without a pause. It was the time of Python 2.6, which of course has multiple data types, but they are dynamic. This means that you don't have to declare a type for a variable -- the type is inferred by the interpreter at runtime.

You could just re-declare a variable with a different type (int to a float) and that was fine.

salary = 12000
salary = 12000.0
Enter fullscreen mode Exit fullscreen mode

I was amazed. It was so easy. No static final void warranty<List> that college professors tried to teach me. You just sit down (sitting is optional), type Python and watch magic happen in front of you. An ocassional TypeError wasn't gonna stop me. Trying to iterate over an integer? Been there, done that. Neither of those convinced me to spend some time and learn about type hints in Python.

I won't blame you if by reading this you assume I'm a bad developer. I never said I was good :)

Don't believe the hype

Python and me grew older together and with Python version 3.5 came type hints. As their name suggests, they are just hints; Python is still a dynamically typed language. They are not evaluated and they don't affect your application at runtime.

Those hints do help though; modern IDEs understand them and suggest better auto-complete results. They also warn when incorrect types are used:

def add(a, b) -> int:
    return str(a+b)
Enter fullscreen mode Exit fullscreen mode

I was aware of these Python advancements but I wasn't aboard the hype train. Who is this Guido person and why is he bringing the noise? Python's syntax was so clean before type hints. My colleagues, who were wiser than me, did get on the hype train and soon I was looking at code that resembled this:

def calculate_avg(salaries: List[int]) -> AverageSalary:
    # perform calculations

salaries: List[int] = [12000, 13000, ...]
avg_salary: AverageSalary = calculate_avg(salaries)
Enter fullscreen mode Exit fullscreen mode

It was awful. It was noisy, it was unreadable, it was sacrilegious.

The big melt

Some time ago I was introduced to AWS CDK for Python and it was a breath of fresh air after years of Terraform (I still <3 Terraform, don't get me wrong). Then I started noticing that CDK code is strongly typed in all its language variants, and for very good reasons. I liked CDK but did I like it enough?

I gulped, bit the bullet and added types where I had to. I also had a brief adventure with CDK for Typescript and...and... I started liking strict typing. It made the code strict, and well defined, and you knew what to expect as a return value. It all made sense! Not to mention how it improves collaboration, makes large code-bases more maintainable and prevents silly bugs.

Peasants put down their pitchforks because the giant's heart has melted.

From "I hate this" to...

I truly disliked type hints. Working with CDK started to change that for the better and then I discovered AWS Lambda Powertools. It combines multiple things I am passionate about so I became passionate about using the library and improving it. Lambda Powertools utilizes static typing for several of its main features (Parser, Event Sources and Typing).

I was keen to contribute to this open-source project which meant I had to jump into static typing and contribute code that will blend in and be accepted. Using static types was so natural, it made so much sense, especially in a codebase that is unknown to me. Instead of being noise, those type hints were real hints that helped me understand a codebase I was unfamiliar with.

My stomach now stays perfectly calm while I'm reading or writing code like this:

log_level: Optional[Union[int, str]] = None
Enter fullscreen mode Exit fullscreen mode

Using CDK and contributing to Lambda Powertools made me turn a 180 degrees. I went from "I hate this..." to "type hints are great!". Using them made me understand why type hints and static typing are necessary and helpful. I even use them sporadically in my pet projects while trying to become a better developer.


Our ancestors cooked food which allowed for their digestive tracts to become smaller, leaving more energy for brain growth. Something similar happened to me; using type hints allowed me to understand unfamiliar codebases and improve my coding skills. My humble contributions are a way of paying back to the open-source community and thanking contributors of Lambda Powertools for Python

A good way to end this article is with another Public Enemy reference: It took a multi-billion dollar company with tens of thousands of developers just a few months to convert this non-stubborn dynamic-typer into a typing hints aficionado.

No statically typed languages were hurt during the writing of this article.

Top comments (0)