DEV Community


Static vs Dynamic Typing for ADHD

kspeakman profile image Kasey Speakman ・4 min read

Static typing has boring overhead but it augments my brain's limited working memory.

The PHP years

My first professional software product was a sign-out board for consultants and company cars. At the time I was employed quite cheaply as IT support not a programmer. I wrote it in PHP, which is dynamic in case you don't know, circa 2000. Later I added an expense reporting feature to replace their existing process of emailing spreadsheets to accounting.

I went on to write many small things in PHP on the side. A service to receive automated responses from an SSN validation provider. (Similar to what web hooks do today.) A limited blog-type website for a charity. (WordPress didn't exist back then.) And a few other things.

After a couple of years the company I worked for closed, and I was without a job. My dad hired me to write an internal ordering system for his small business, which produces lighted outdoor signs. There is a tiny chance that some of those golden arches you see from the interstate in the USA were made to order at his shop.

My equipment betrays me

Pricing a sign and speccing it out for manufacturing is complicated. The wizard-style app I ended up writing had a dozen or 2 possible pages of data collection. It had branching paths depending on selected options and multiple pricing rules. This is where PHP broke me.

Later after I tried other languages, I came to have a strong distaste for PHP. But I realize now that the negative experience I had with PHP was not its fault. It was my brain's tiny working memory -- a trait of ADHD. To keep the small details of a wizard process in mind across a dozen pages was too much for it. Especially when ADHD prevents me from choosing what to focus on. So every day became a frustrating process of continually losing focus and forgetting the information I needed to carry from one page to the next. And having to repeatedly remind myself of the same information. Eventually breaking through and having enough information to make a little hard-fought progress. Some days I was too burned out and simply let the hours pass in defeat. I realized none of this at the time and I just assumed programming for a living was not for me.

The (mostly) typed years

I did eventually finish that app. And as much as I wanted to do hardware work, people kept wanting to pay me for software. I took on some work writing in VB, then C#, Javascript, some others, and finally F#. After C# I realized that I could maybe see my way to coding for a living and did so from then on. Fast forward a decade to the last few months, I starting learning Clojure.

Rediscovering dynamism

I created MVU and validation libraries in Clojure. I absolutely loved how tiny yet understandable they were. I started rewriting my front-end-only budget simulator in it. While doing that, a feeling struck me that I had not felt for a long time. It was frustration with myself for not being able to remember basic information from one page to the next and the fear that I had remembered it wrong. It was notable because it happened repeatedly.

Then I discovered I had ADHD, and these experiences started to make sense.

Dynamism in context

Part of the reason I was interested in Clojure was precisely because it was dynamic. After many years of writing in typed languages and creating larger and larger apps, maintaining types can become tedious. And it definitely adds coding overhead that I was interested in reclaiming. What I did not realize until recently is that my neurological traits make types highly beneficial for me. Types essentially provide a library for me to look up the shape of the data. And editors instrument this with the ability to hover and see the type definition in an instant. So types augment my limited working memory very effectively.

Programming already requires an expanded working memory as you progress toward an overall solution. But with ADHD a lot of the important minutia (like what did I name that field, or what kind of data was in it?) is impossible to keep in working memory because it is uninteresting and therefore evades focus.

For other people, this may be less of an issue and dynamic languages are a net savings. But for me the overhead of maintaining types is well worth the benefit. It is especially detrimental to the self-esteem to get so repeatedly frustrated with one's own limitations.

Same for FP
This is also the reason that the functional programming paradigm works so well for me. FP focuses on using deterministic (aka pure) functions. By definition, this mean I do not have to remember any state from outside the function. I only have to deal with what is right in front of my face. This plays to my strengths.

I have not given up on Clojure. Spec allows me to have types, in effect. The main issue is that Spec is still in alpha and extensive use of specs seems to be considered abnormal in Clojure code. For now I am keeping my eye on it. I have enjoyed writing code in Clojure so I am interested in figuring out a system that works for me there at some point.

Path ahead

Overall, this realization about my neurological traits means I will be preferring types in some form or another for the foreseeable future. And F# is my go-to language.

Discussion (0)

Editor guide