2 comments
I agree, that sometimes doing things OOP-style with methods isn't the right choice and using plain structs and free functions is a better way of doing things. But there are cases where using methods is inevitable - when internals must be hidden in order to prevent incorrect usage. Also it's needed if one needs runtime polymorphism, in such cases (in C++) inheritance and virtual methods come to rescue. Doing so in C way (with void pointers and structs containing function pointers) is less ergonomic and bug-prone.
For many applications, modules are much more flexible and convenient for hiding internals than class hierarchies that may force an irrelevant structure on the internals and which may make difficult to selectively choose what is visible and what is hidden.
Read the full thread on Hacker News →
Related stories
- Lobsters · 48 points · over 5 years ago
- Hacker News · 21 points · about 10 hours ago
- Mythical Thought and Scientific Thoughtmedium.comHacker News · 2 points · 6 days ago
- Show HN: XHTML – Expert HTMLxhtml.esHacker News · 3 points · 7 days ago
- Belay – See what keeps going wrong in your Claude Code and Codex sessionsgetbelay.vercel.appHacker News · 1 points · 9 days ago
- Hacker News · 2 points · 8 days ago