3 ms·
C doesn’t have objects, which are great for encapsulating data structures, but in C++ it’s not at all hard to write a graph data structure. One wraps it behind
by blub 1y ago
C doesn’t have objects, which are great for encapsulating data structures, but in C++ it’s not at all hard to write a graph data structure.
One wraps it behind a reliable interface, writes automated test and runs them under valgrind/sanitizers and that’s pretty much it.
It’s normal for life and software development to have a certain degree of risk and to spend some effort solving problems.
Too many HN comments make it sound like it’s a jungle out there and a use-after-free will chop your head clean off.
- nemothekid 1y agoI don't mean to imply that writing a graph in C++ is impossible. It's clearly possible in modern C++. My contention is treating indicies-based management as some tedious, manual workaround. Unity's ECS is written in C#, which has both a GC and the language expressiveness for an actual graph objects, but has adopted an indicies based system. It works, and is performant, so it isn't a mistake for the compiler to herd users down that path. In a similar vein, the Linux codebase is full of completely legitimate and readable uses of goto, but we are perfectly happy with languages that force us to use structured control flow.