←back to thread

78 points p2detar | 3 comments | | HN request time: 0s | source
Show context
Jean-Papoulos ◴[] No.46204131[source]
>What this means is that you can explain all the intent of your code through the header file and the developer who uses your lib/code never has to look at the actual implementations of the code.

I hate this. If my intellisense isn't providing sufficient info (generated from doc comments), then I need to go look at the implementation. This just adds burden.

Headers are unequivocally a bad design choice, and this is why most of every language past the nineties got rid of them.

replies(3): >>46204695 #>>46205042 #>>46205098 #
alextingle ◴[] No.46205042[source]
Separating interface from implementation of one of the core practices for making large code bases tractable.
replies(1): >>46205184 #
1. valleyer ◴[] No.46205184[source]
Of course, but that's doable without making programmers maintain headers, and some modern languages do that.
replies(2): >>46206695 #>>46216635 #
2. ux266478 ◴[] No.46206695[source]
I've found usually to poor effect. Both Rust and Haskell did away with .mli files and ended up worse for it. Haskell simplified the boundary between modules and offloaded the abstractions it was used for into its more robust type system, but it ended up lobotomizing the modularity paradigm that ML did so well.

Rust did the exact opposite and spread the interface language across keywords in source files, making it simultaneously more complicated and ultimately less powerful since it ends up lacking a cognate to higher order modules. Now the interfaces are machine generated, but the modularity paradigm ends up lobotomized all the same, and my code is littered with pub impls (pimples, as I like to call it) as though it's Java or C# or some other ugly mudball.

For Haskell, the type system at least copes for the bad module system outside of compile times. For Rust, it's hard for me to say anything positive about its approach to interfaces and modules. I'd rather just have .mlis instead of either.

3. 1718627440 ◴[] No.46216635[source]
I don't understand that hate against header files. It is just a separate file with the interface. Of course you also need to change it, when you change the API, which you might find annoying, but maybe you should use that to consider that you are just changing an API?