Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am starting to wonder if the preference static vs dynamic is some kind of character trait like introvert vs extrovert. I personally prefer static typing and use it to my advantage during development but I know very smart people who hate static typing and think it impedes them. Both sides have valid arguments but seem to prioritize things differently.

However I think it’s important to have used both for a while so you can make a good decision what you prefer.



I think it depends a lot on previous experience, what type of thing you are developing, and your tooling. I'm very comfortable and happy bouncing between C# in Unity, React and JS, and Haskell for more CS / intellectual curiosities. For me it's more about fit and choosing the right tool for the job.

All things being equal I prefer something like Haskell because it is very clean and expressive. But I hate excessive types when you are dealing with generics 3 level deep or when you have these funky type signatures dealing with monad transformers. It's just too many layers of abstraction that takes you away from the actual data / parameters.

When I'm writing something small I find typing slows me down. But when writing something bigger, working in a team, or working on a codebase for a longer period of time the typing acts as documentation. Typing something and having Intellisense tell you what is in a class is extremely helpful. Otherwise you have to jump to the file or look through documentation.

For me it's less about the errors it catches and more about the time saving of not having to read through code that I am calling in order to understand what I need to pass to it.

In general. strong typing is great when you are working with other people's code and 3rd party libraries, but excessive overhead when you just want to experiment and crank out something small.


Fwiw we have a relatively large Scala codebase that's exceptionally bug-free, performant.and easy to modify and haven't had to reach for a lot of the extremely abstract FP patterns that warrant the most blog posts. Simple immutability, garden variety monads (IO, Either, Option) get you a long way and are simple to understand.


"static vs dynamic is down to personal preferences" was the running thesis of some of Steve Yegge's essays. His "Portrait of a N00b" is more/less one aspect of this.

For static-lovers, the idea of "just fix it if it breaks in production" is horrible. For dynamic-lovers, the idea of "spend time on work which doesn't get you closer to solving the problem" is essentially wasted effort. (Static-types are 'meta' code; the equivalent program works just as well without the types declared).

I've heard a good strategy is that the first-iteration should be dynamic (this gets the problem solved quickly), and static typing is good for further iterations (static-typing is better at conserving what's there).


I don't know. My favourite languages to work in are Clojure (very dynamic) and the ML family (powerful types). I'll admit I've indulged in some C++ type orgies in the past. What I don't like is dynamic types in an imperative setting (python, js). I think dynamically typed oop is a bad combo.


> However I think it’s important to have used both for a while so you can make a good decision what you prefer.

Exactly, I always found static typing to be annoying clutter and Python seemed to work even at scale. I removed the few type hints the codebase had.

Then I had to spend a year in C# professionally. At the end, I was fine with both, no preference. Then I jumped back into our Python and only then realized the utility of typing - it felt chaotic, my (IntelliJ) IDE was no longer helping me and every time I had Prod type related bug, it feeling dumb.

Ended up type hinting the critical parts of the Python.


I am also starting to embrace a mix. “Any” in TS or “dynamic” in C# can save a lot of code when parsing JSON but then I usually quickly try to move over into the typed world.


`unknown` is also a really convenient type too: https://www.typescriptlang.org/docs/handbook/release-notes/t...

I think of it as "I don't care what the type is, but I also shouldn't be able to do anything with it"


At first I thought I was going to read "I am starting to wonder if the preference static vs dynamic is some kind of character trait like intelligent vs ignorant", which would have been much closer to the truth. I think you're very incorrect. Maintaining a codebase of any sufficient size and complexity without static typing is a poor investment of development time. It can be done, obviously, but it's a nightmare. Typescript is a bandaid for web-development's biggest open wound. Taken on its own merits ( ignoring the garbage ecosystem, terrible tooling, etc ) Typescript is a decent enough language, but it's not a clever one. Is Typescript better than vanilla Node.js? Absolutely. Is it worth introducing to an area without Node.js? Absolutely not. If your project is any more complex than a four page CRUD app, in my opinion you're better off going with a bigger player like Java/.Net. These languages are more robust, more mature, there's better tooling, better community... The list goes on.


I am not sure if I want to work with you if you think it’s about “intelligent vs ignorant"...

Even though I seem to be in the “intelligent” camp by your definition.


That's fine.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: