News for hackers. Stuff that matters.
Re:When to use generics by eru on Wednesday April 13, 2022 @12:24AM (#31011184)
I suspect the difference depends on what your types can provide?

So in something like Haskell the types are strong enough that going with a types first approach makes a lot of sense. Often once you have the types laid out, many functions will only have a handful of sensible implementations that are even possible at all.

In something as primitive as C or Go (before generics) types don't tell you much at all. So laying them out first doesn't give you much at all. You might make a mental (or physical) note of what you are trying to achieve on what data, and then start coding.

In Haskell you could express a lot of the content of that note in the types; but in C and Go many or even most things are done via side-effects, and their type system doesn't track these at all.

Re:When to use generics by shpongled on Wednesday April 13, 2022 @12:51AM (#31011303)
Indeed, I do a lot of Rust/ML-style programming, so the type-directed approach comes naturally.