←back to thread

78 points p2detar | 10 comments | | HN request time: 0.423s | source | bottom
1. 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 #
2. GhosT078 ◴[] No.46204695[source]
Look to Ada for “headers” (i.e. specs) done right.
replies(1): >>46206504 #
3. alextingle ◴[] No.46205042[source]
Separating interface from implementation of one of the core practices for making large code bases tractable.
replies(1): >>46205184 #
4. antonvs ◴[] No.46205098[source]
C's text preprocessor headers were a pragmatic design choice in the 1970s. It's just that the language stuck around longer than it deserved to.
replies(1): >>46209894 #
5. 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 #
6. runlaszlorun ◴[] No.46206504[source]
Recently became big Ada fanboy, ironic because Im far more a fan of minimal, succinct syntax like lisp, forth, etc and I actually successfully lobbied a professor in 1993 to _not_ use it in an undergrad software engineering class lol.

Still in the honeymoon phase granted, but I'm actually terrified that we have these new defense tech startups have no clue about Ada collectively.

Your startup MVP you wants to ship a SaaS product ASAP and iterate? Sure, grab Python or JS and whatever shitstorm of libraries you want to wrestle with.

Want to play God and write code that kills?

Total category error.

The fact that I'm sure there are at least a few of these defense tech startups yolo'ing our future away with vibe coded commits when writing code that... let's not mince our words... takes human life... prob says about how far we've fallen from "engineering".

7. ux266478 ◴[] No.46206695{3}[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.

8. tomcam ◴[] No.46209894[source]
So what language is ready to take its place in the thousands of new chips that emerge every year, the new operating systems, and millions of programs written in see every year?
replies(1): >>46213917 #
9. antonvs ◴[] No.46213917{3}[source]
You're alluding to the network effects that make that takeover difficult now, after decades of doubling down on a technically weak and systemically insecure solution.

Languages that are technically capable of replacing C in all those applications include Ada, (and in certain applications, SPARK Ada), D, Zig, Rust, and the Pascal/Modula-2/Oberon family. None of those language use a purely textual preprocessor like C's. They all fix many of C's other design weaknesses that were excusable in the 1970s, but really aren't today.

But Rust in the Linux kernel is no longer experimental, so perhaps things are starting to improve.

10. 1718627440 ◴[] No.46216635{3}[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?