5 ms·
This is the most clean, grokkable, readable C++ code I think I've ever read. I feel like most open source C++ projects I read in non-game spaces are just a com
by Solvency 3y ago
This is the most clean, grokkable, readable C++ code I think I've ever read.
I feel like most open source C++ projects I read in non-game spaces are just a complete mess of indecipherable syntax.
Is this game code uniquely well written or am I often looking at the wrong codebases?
- almost_usual 3y agoMy first impression was that it was fairly readable and had decent comments.
- lmm 3y agoHave a look at KDE, I've always found most of their projects to be well written.
- Mydayyy 3y agoI can attest to that, atleast for spectacle. I once wrote a sharing plugin for purpose and spectacle had an issue where it was not propagating possible errors correctly. Setting up a dev environment for kde/spectacle was extremely easy and the code was easy to follow. Took me maybe 3 hours from zero to fixing it and making a PR.
- nailer 3y agoI mean KDE did take over the desktop, with most of our apps living in the browser and most of the browsers being based on their code.
- The_Colonel 3y agoI understand that you're being facetious, but the reality is much darker than this historical trivia might suggest - the web platform is today largely controlled by one mega corp.
- WastingMyTime89 3y ago> the web platform is today largely controlled by one mega corp. With a product using code from KDE it must be said.
- The_Colonel 3y agoDoes it matter apart from warm fuzzy feelings? KDE doesn't have any influence on web platform anymore.
- johannes1234321 3y agoWhen talking about KDE's code quality it matters. Two of three remaining relevant browser engine vendors (Apple and Google) base their browsers in that code base. They could have gone from scratch or used a different base, but they took KDE's. They wouldn't have if it was of bad quality and unmaintainable.
- nailer 3y agoThe context is how good their C++ code base was.
- ccrush 3y agoKHTML->Konqueror->WebKit->WebCore->Blink
- johannes1234321 3y agoAlso WebKit -> Safari
- nailer 3y agoI’m being genuine.
- Jyaif 3y agoWas pleasantly surprised by the comments. But while the codebase is grokkable (every line is simple), it's brittle [1]. Not saying it's a big deal: brittle codebases are fine when the codebase is only going to be touched by a small amount of people. Less so when the code is going to be used and modified for decades by thousands of people (in OS, compilers, browsers...). [1] Unchecked assumptions everywhere, #ifdef with platform specific code everywhere, singletons everywhere. Only spent 5 minutes browsing the code, I'm sure there's more examples.
- Keyframe 3y agosingeltons are rather common in game code, it's not that bad. What's wrong with ifdefs for platform specific code though? Alternative is to have different compile-time paths.
- golergka 3y agoIn my experience (with gamedev) it often leads to your game silently breaking on platform you're not building it for. Proper CI will catch this, but it still makes the feedback loop longer.
- Jare 3y agoI joined Radical Entertainment a few years after Hit & Run, and I can confirm that it was filled with very good engineers (and artists!), with really solid hiring and leadership. It wasn't without its flaws, but it was an excellent place for new and experienced developers alike. Ultimately the transition to 360/PS3 and the massive increase in production value and challenges cracked the company - or, depending who you ask, it was just the Activision merger with Vivendi (owner of Radical).
- cwales95 3y agoI was sad when Radical Entertainment went away (no longer doing their own games). Loved the prototype game series. Hoping it somehow comes back.
- devjab 3y ago> am I often looking at the wrong codebases? I don’t think you are. I have a couple of decades in the industry, in which I’ve had the honour to see quite a lot of code from many different organisations through one of my roles in Enterprise Architecture in the Danish public sector. In my completely anecdotal experience it takes quite a lot of dedication to the CI part of the development process to achieve clean code bases, and it’s often not something that’s going to be very beneficial in the short term. Over time, I think that most good programmers eventually ends up in a “readable code is good code” mantra, but it’s not an easy path and a lot of the “meta” philosophies that we teach programmers from their first day in programming are sort or counter-productive to writing clean code. Having gotten into programming around the millennium I’m obviously mostly familiar with the OOP side of things, but many of the things I was taught in regards to OOP is still things I see CS students being taught when I do my side gig as an external examiner. Where I’m from we tend to start learning OOP with a classic “bird -> duck, something that flies, some bird that walks” sort of thing so students can put in “fly”, “swim”, “walk” and “say something” methods. Which is great, in theory, because in the real world (again very anecdotal) people tend to build polymorphism and inheritance in ways that eventually almost always seem to end up with code basis having been better off just writing a duck, a chicken and a ostrich instead of nesting them under a bird class. Don’t get me wrong, I love having basic classes to inherit from in any sort of data-modelling so it’s not like I’m aboard the “I hate all OOP” bus, my point is rather that we still teach students something that often turns out not to produce clean code. Often it’ll take a long time for some of those students to get to a point where they become critical of “academic” programming and many frankly never learn how to write clean code. In non-OSS you can dictate a lot of things that you can’t with open source without breaking a lot of the concepts. I don’t necessarily think it’s wrong to demand that open source organisations make it a requirement that the only way you can build things for them is if you use their template projects in a technology they want to govern. But that goes against the principle of technology agnostics, so many will rightly not do that. If you don’t, however, take control on how code is supposed to be written, then it’s going to be written in a multitude of ways and I think it’s very hard to avoid it becoming messy over time. Now, if you have a single project and not an organisation, and maybe you even have changing custodians, then you’re likely going to end up with not only different ways of contributing but also different governing philosophies over time. Which is very democratic, and probably unavoidable, but it’s also very prone to leave you with a code base that isn’t easy to read because it’s not actually written by a single set of “clean code” principles but multiple. Or in short, no, writing clean readable code is hard.
- thom 3y agoSerenityOS's codebase is extremely clean: https://github.com/SerenityOS/serenity https://github.com/SerenityOS/serenity
- albertzeyer 3y agoThere are also games with lots of very hacky and ugly code. :) But I can recommend you to read the code from Quake, Doom, etc. Start with the early versions, because it's even much simpler. I also find this very easy to read and very simple, and easy to hack around with. See my list here of code bases I recommend to read: https://github.com/albertz/wiki/blob/master/coding.md#recommended-projects https://github.com/albertz/wiki/blob/master/coding.md#recomm...
- deaddodo 3y ago> I feel like most open source C++ projects I read in non-game spaces are just a complete mess of indecipherable syntax. This is because a lot of C++'s idioms are a) very old (stemming back from C++98, and slowly morphing with each version) and b) extremely conservative. Ideas that are important to more "modern" languages like KISS and "nothing magic" apply much less, as efficiency is generally more focused on. Especially in systems and embedded development. > Is this game code uniquely well written or am I often looking at the wrong codebases? I would say it's multi-faceted. Firstly, the codebases you're referring to probably aren't nearly as messy or archaic to primarily C++ developers. They just seem that way to outsiders; though there are plenty of messy codebases. Secondly, gamedev has it's own paradigms and idioms that are generally structured more agnostically and modular. That all being said, I would say modern codebases built in C++11 and newer are much "cleaner" for non-C++ developers with more modern idioms.
- ec109685 3y agoThis file has more comments / boilerplate than logic and it’s hard to follow: https://github.com/Svxy/The-Simpsons-Hit-and-Run/blob/eb4b3404aa00220d659e532151dab13d642c17a3/game/code/ai/actionbuttonhandler.cpp https://github.com/Svxy/The-Simpsons-Hit-and-Run/blob/eb4b34...