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

> smart people are naturally attracted to complexity like moth to a flame

I think the general inclination here towards static typing is due to this, rather than any evidence that statically typed languages lead to higher quality software. Engineers just love puzzles. I'm also looking at you, Rustaceans...

runs for his life



I’ve seen some variation of this accusation being thrown around for years- and frequently by people who I regard as smart, capable developers. On the other hand, having worked with languages all over the spectrum of static typing- I’ve also seen first how how high the bar really is for benefiting from static types before you hit diminishing returns.

The best answer I can come up with is that people just seem to have differently wired brains. For me, static typing- even fairly sophisticated static typing, is simple. It makes the code simpler, easier to reason about, easier to refactor, and with a sufficiently expressive type system it lets you build things in a much more intuitive way than you could otherwise. It’s not about solving puzzles for the sake of them- types remove a big part of the puzzle by letting me explicitly write things down- and letting the compiler keep track of the details.

Certainly plenty of people don’t see it that way, and I’ve heard a lot of people make similar arguments about dynamic typing being simpler and more expressive. I don’t think they are lying but I see a big pile of inscrutable pain when I work in large dynamically types codebases.

I know I’m right about my experience, and I trust other people are right about theirs, so there must be some significant divide in how we conceptualize code that makes one persons elegant simplicity another’s intolerable complexity.


Nothing to add, except for a sincere appreciation for how you eloquently and impartially summed up the divide.


I don't agree with this - types do not imply abstractions, and simple types make simple code.

Every tool has the potential to be misused in accidental complexity.


I don't know, man — I see a lot of TypeScript developers who lean hard into generics (I am occasionally one of them).


When I've seen this (and found myself doing it) it's been because we're trying to do something with TS which we would have done easily in JS.

But the JS function we would have written would have required someone using it to read and understand it, and the TS function (without using 'any') needs to fully express what its inputs and outputs can look like.

Because of this TS actually tends to guide me towards writing more "Grug brained" code, because I refuse to use 'any' (and throw away TS benefits) and using generics usually requires a trip downstairs for a fresh cup of tea.


Because generics are actually a powerful tool for simplifying the data flow. They make it possible to promise not to do anything specific to and based on the data involved.


This is a very simplistic approach to simplicity. Simplicity is not just counting the number of characters you see. A function in a statically typed language may have a signature that says 'it takes an integer and returns an integer'. That is very simple. A function in a dynamically type language says 'this can take something, anything really, and returns something, anything, really. That is very complicated and unspecified even if it takes a few characters less to type.


I agree, but for complex type systems versus Java-style type systems.




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

Search: