Timeline for Is it reasonable to write a game engine in C?
Current License: CC BY-SA 3.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 6, 2018 at 23:23 | comment | added | user77245 | Lastly there's a lot of things people trip over in C++, just by tendency (not that you have to, but many do)... as an example, even Intel tripped over this stuff repeatedly designing TBB. They had a bug that lasted for ages where if you shut down the software right after a parallel loop, e.g., TBB would crash. They got tangled up in destructors for singletons/static objects -- something you can't do in C because of the explicit requirement to destroy objects. Again you don't have to trip up on this stuff, but many do, even pros... convenience can become the ultimate inconvenience. | |
| Jan 6, 2018 at 23:16 | comment | added | user77245 | And I think it's worth asking like, would the Linux kernel really be as efficient if it was written in C++? I generally lean towards "no". That doesn't have to be the case, I've seen some very efficient C++ code, but often there's a tendency to waste a lot more memory here and there and things like that -- little tabs each tiny object being designed tends to keep that racks up the bill for convenience (optimizers can eliminate the object overhead, but I'm talking about overheads programmers tend to accept daily in desigining objects) -- a negligible bill in many cases but not for an OS kernel. | |
| Jan 6, 2018 at 23:09 | comment | added | user77245 | When you have a language where it's incredibly difficult and time-consuming to just write a growable array container like std::vector in a way that's exception-safe and conformant to people's expectations, imagine how long it takes to write a cutting-edge BVH for raytracing. The time/productivity difference is enormous. So I often find C preferable and a massive time saver for writing core data structures tailored for a particular software in a way that works well and conforms to everyone's expectations of what it should do... not to mention it typically builds way, way faster. | |
| Jan 6, 2018 at 23:02 | comment | added | user77245 | ... exception-safe and efficient for PODs and disambiguate fill ctors from range ctors with type traits and provide both a const and mutable iterator along with reverse const and non-const iterators. In C that takes 15 minutes to write an efficient one using realloc that recovers properly in the face of an allocation failure. There's a whole lot going for a language that has less. That said, I also love C++, but I love C++ because it has a richer type system, and I love C because it doesn't. | |
| Jan 6, 2018 at 23:00 | comment | added | user77245 | Less stuff is actually the reason I like C. For example, in C I can just copy bits and bytes around with a memcpy for anything because the type system doesn't allow things like copy ctors and dtors. I can write code knowing I won't have to roll back side effects at almost any given line of code since I can't implicitly exit a function unless I explicitly return out of it; there are no exceptions being thrown. All of this makes writing data structures so much easier -- in C++ just writing a standard-compliant vector is very time-consuming, especially if you want to make it ... | |
| S May 6, 2015 at 18:09 | history | suggested | CommunityBot | CC BY-SA 3.0 | corrected spelling error |
| May 6, 2015 at 16:59 | review | Suggested edits | |||
| S May 6, 2015 at 18:09 | |||||
| Aug 24, 2010 at 16:39 | comment | added | user744 | @Dan: Simply by having more stuff, C++ is harder to debug. You can of course restrict yourself from using any of that stuff, in which case it becomes as easy to debug as C - because it becomes C. | |
| Aug 24, 2010 at 9:51 | comment | added | Kylotan | Even clean code can be harder to understand in C++ - with overloading, templates, virtual functions, and exceptions, it's much harder to see at a glance exactly what the actual control flow will be. | |
| Aug 24, 2010 at 7:02 | comment | added | Dan Olson | Going to disagree with point 3. It's just as easy to write messy, hard-to-debug code in C as it is in C++. Better debugging isn't something inherent in the C language. | |
| Aug 9, 2010 at 1:05 | comment | added | jsimmons | There's really nothing stopping you implementing inheritance in C. And if you use C99 you can declare variables in for loops. | |
| Jul 15, 2010 at 8:20 | history | answered | Ben Zeigler | CC BY-SA 2.5 |