<story><title>Modern C++ gamedev: thoughts and misconceptions</title><url>https://vittorioromeo.info/index/blog/gamedev_modern_cpp_thoughts.html</url></story><parent_chain><item><author>gordaco</author><text>I would say Java, which I suspect is bound to be a bit of an unpopular opinion here (I expect more startup people than enterprise denizens in HN); but the more I think about it, the more sure I&amp;#x27;m that it fits the bill:&lt;p&gt;- Dumb: you bet. The inclusion of lambdas has shaken things a little, but usually Java code is straightforward with little space for &amp;quot;cleverness&amp;quot;. The counterpoint to this, of course, would be the memes about AbstractFactoryFactoryImplementationSubclassDispatcher class names and all that, which IMHO does not represent much actual Java code out there. There are good reasons why big corps prefer Java, and readability is one of them. As a programmer, I&amp;#x27;ve found it easier to jump into a Java codebase I didn&amp;#x27;t know much about than in any other language. And this has happened even when I had little experience in Java.&lt;p&gt;- Safe: yes. You have to go out of your way to be unsafe in Java. Memory allocation is done for you and the try-with-resources idiom is almost as good as C++ RAII.&lt;p&gt;- Fast: also yes. Usually about 2x or 3x the run time of C&amp;#x2F;C++ code, some times even less.</text></item><item><author>deepaksurti</author><text>&amp;gt; Not always, though. See every bug and exploit with C arrays ...&lt;p&gt;That can also be perceived as a a flaw of the language design in that it does not allow one to write dumb, safe and fast code. Which are such languages in existence today?&lt;p&gt;edit: fixed typos</text></item><item><author>krapp</author><text>&amp;gt;I find that the dumbest code is the best code&lt;p&gt;Not always, though.&lt;p&gt;See every bug and exploit with C arrays or pointers that exists because C devs think even minimal attempts at safety are too complicated or slow, or old-style PHP code that builds SQL queries out of printf strings directly from POST values, or probably countless other examples in other languages. C++ code that uses raw pointers instead of references or that uses std::vector but never actually bothers to bounds-check anything.&lt;p&gt;It&amp;#x27;s entirely possible for code to be too dumb for its own good.</text></item><item><author>PezzaDev</author><text>After years of experience writing code for games, I find that the dumbest code is the best code. It doesn&amp;#x27;t matter if it&amp;#x27;s C# or C++, whenever I&amp;#x27;ve used something like reactive extensions or template metaprogramming, it has been a terrible mistake every single time. Make your code simple, dumb and verbose all the time. Avoid using any complex abstractions or any overcomplicated syntactic sugar and you&amp;#x27;ll have a codebase that anyone can jump into and quickly be able to add features without introducing bugs (at least less likely). This matters more than anything else.</text></item></parent_chain><comment><author>jcelerier</author><text>&amp;gt; Fast: also yes. Usually about 2x or 3x the run time of C&amp;#x2F;C++ code, some times even less.&lt;p&gt;not commenting on the Java part as I believe it&amp;#x27;s usually faster than that (though not so sure when you see the years of hoops that Minecraft java had to go through to stop being so damn slow all the time...) , but it&amp;#x27;s kinda frustrating to be fighting for microseconds almost daily and then hear people saying that 2x slower is fast... 2x slower means going from 100fps to 50fps which ... well, gets you fired ?</text></comment>
<story><title>Modern C++ gamedev: thoughts and misconceptions</title><url>https://vittorioromeo.info/index/blog/gamedev_modern_cpp_thoughts.html</url></story><parent_chain><item><author>gordaco</author><text>I would say Java, which I suspect is bound to be a bit of an unpopular opinion here (I expect more startup people than enterprise denizens in HN); but the more I think about it, the more sure I&amp;#x27;m that it fits the bill:&lt;p&gt;- Dumb: you bet. The inclusion of lambdas has shaken things a little, but usually Java code is straightforward with little space for &amp;quot;cleverness&amp;quot;. The counterpoint to this, of course, would be the memes about AbstractFactoryFactoryImplementationSubclassDispatcher class names and all that, which IMHO does not represent much actual Java code out there. There are good reasons why big corps prefer Java, and readability is one of them. As a programmer, I&amp;#x27;ve found it easier to jump into a Java codebase I didn&amp;#x27;t know much about than in any other language. And this has happened even when I had little experience in Java.&lt;p&gt;- Safe: yes. You have to go out of your way to be unsafe in Java. Memory allocation is done for you and the try-with-resources idiom is almost as good as C++ RAII.&lt;p&gt;- Fast: also yes. Usually about 2x or 3x the run time of C&amp;#x2F;C++ code, some times even less.</text></item><item><author>deepaksurti</author><text>&amp;gt; Not always, though. See every bug and exploit with C arrays ...&lt;p&gt;That can also be perceived as a a flaw of the language design in that it does not allow one to write dumb, safe and fast code. Which are such languages in existence today?&lt;p&gt;edit: fixed typos</text></item><item><author>krapp</author><text>&amp;gt;I find that the dumbest code is the best code&lt;p&gt;Not always, though.&lt;p&gt;See every bug and exploit with C arrays or pointers that exists because C devs think even minimal attempts at safety are too complicated or slow, or old-style PHP code that builds SQL queries out of printf strings directly from POST values, or probably countless other examples in other languages. C++ code that uses raw pointers instead of references or that uses std::vector but never actually bothers to bounds-check anything.&lt;p&gt;It&amp;#x27;s entirely possible for code to be too dumb for its own good.</text></item><item><author>PezzaDev</author><text>After years of experience writing code for games, I find that the dumbest code is the best code. It doesn&amp;#x27;t matter if it&amp;#x27;s C# or C++, whenever I&amp;#x27;ve used something like reactive extensions or template metaprogramming, it has been a terrible mistake every single time. Make your code simple, dumb and verbose all the time. Avoid using any complex abstractions or any overcomplicated syntactic sugar and you&amp;#x27;ll have a codebase that anyone can jump into and quickly be able to add features without introducing bugs (at least less likely). This matters more than anything else.</text></item></parent_chain><comment><author>HelloNurse</author><text>Cleverness is more a function of a programmer&amp;#x27;s habits and attitude than of the language: one tries to be clever in any language.&lt;p&gt;C++ offers &amp;quot;efficient&amp;quot; ways to be clever, with varied and difficult challenges that can be addressed in relatively little difficult code; some are good or harmless (e.g. aligning struct fields to cache lines or concise towers of useful templates) and some are bad (e.g. flaky homemade not-too-smart pointers and almost-STL-compatible containers).&lt;p&gt;Java, on the contrary, facilitates the creation of large, boring and easy to read generic object-oriented tumors, that become satisfactorily clever only when they go very far (e.g. one more layer of indirection than everyone else) or reach theoretical limits (e.g. nothing left to invert control of).</text></comment>