Hacker News new | past | comments | ask | show | jobs | submit
I started learning Clojure when I was 17, but then later moved away from programming. It's done the opposite with me, I struggle to really get the benefit of static types and I still think of everything as maps and functions.
The biggest benefit of static typing is that you automatically know every single operation you can perform on every single result of every single function ever made.
I think an appreciation for static typing comes once you have to start working with code others wrote. I used to write a lot of clojure in my free time, but I think I liked it more because I was the only developer on those projects.

Working professionally in dynamic languages, especially those that use maps in place of objects/records, I would spend a lot of time trying to figure out which keys were present in various input maps. Were they always available or only sometimes? I could either add verify checks at function callsites or trace the map all the way through my code and hope it didn't originate from an undocumented API response.

A few years ago, we started migrating our code from Elixir to Scala. That involved a lot of work creating case class "schemas" for many records that used to be represented by maps. But now it's clear at dev time what data each function receives as input. What fields are required and which are optional. I can write a quick bugfix in a large module that someone else wrote without spending a full day tracing data paths and looking at runtime traces.

Haha same! All you need are primitives and maps and lists and first class functions! (Though good decomposition syntax is up there as well; it can be really helpful for telling what a given thing needs the map to include!)
Awesome, how do you ensure clients of your code always do the correct operations on your data?

With static types it's obvious and you generally have to work hard (and in non intuitive ways) to mess up.

This becomes more important as team sizes grow.

> Awesome, how do you ensure clients of your code always do the correct operations on your data?

Either the data type is opaque (as in you shouldn’t mess with it and you should use the provided api) or it’s just normal primitives and thus no restrictions.

You don’t usually reach into data structures to modify their properties, especially if it’s for foreign modules.