Hacker News new | past | comments | ask | show | jobs | submit login

I've had some good times in C++. But for everything that's been thrown into it, I can't believe we're still dealing with header files. That was one of the greatest things about moving to Swift: no more of that BS.

But with SwiftUI, Swift has also become "unfun." SwiftUI and Apple's half-assed, broken observation and "reactive" paradigm have made programming a joyless slog.




C++20 has modules, which replace header files completely (unless you use old libraries which aren't available as modules yet). Compiler support is there, but unfortunately IDEs are lagging. If you use modules with Visual Studio, say goodbye to IntelliSense. Maybe they'll iron out the bugs in a couple years...


C++20 that is not complete in 2025. I don’t know how C++ developers can work in this with a straight face.


You probably have to think this way: Anything added to C++ will only get to be used in for real for real in 10 years minimum.


They needed the most powerful, most flexible module system ever, so it might take decades to really become useable. Adoption has been painfully slow so far, it's insane complexity really doesn't help.


Wow, that's ridiculous.

I wonder if Xcode does any better with them. Now that would be something.


C++ has modules for small values of "modules": https://arewemodulesyet.org

It's a bit tongue in cheek but: "Are we modules yet? Nope. ... Estimated finish by: Wed Sep 20 2541"


You can use modules to structure your own codebase. No more need to write headers and think about how to structure your code in terms of compilation units. But yeah, your link shows that practically none of the popular libraries (except STL) can be imported as modules today.


I did C and C++, then moved on to Objective-C and Swift. I recently switched back to C++, after getting tired of Apple’s shit treatment of developers. I also have no interest in learning SwiftUI.

Having to define header files in C++ is pretty annoying after doing Swift for many years.


> I've had some good times in C++. But for everything that's been thrown into it, I can't believe we're still dealing with header files.

There is nothing wrong with header files. In fact, there is no such thing as a header file specified in C++. There are only forward declarations and definitions, and how those can be managed by developers.

Meaning, any talk about header files is a discussion on software engineering practices, and how developers create or avoid their own problems.


"There are only forward declarations and definitions, and how those can be managed by developers."

Why do we need to manage them?


Because nobody has figured out a way to automate the process of generating declarations from definitions.



> Why do we need to manage them?

Why do developers need to write code that makes sense and does what they want it to do?


Why do developers in other languages not have to deal with it?


> Why do developers in other languages not have to deal with it?

They do, except they don't have the bandwagon effect motivating them to complain about other solved problems.


Enjoy your echo chamber.


> Enjoy your echo chamber.

Is that supposed to mean anything at all?




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

Search: