10 ms·
Id Software Programming Principles
- a3n 10y ago> Write your code for this game only - not for a future game. You’re going to be writing new code later because you’ll be smarter. This really stood out for me. I'm always tempted, while writing something specific, to generalize it. I try to resist that, when I recognize it. Writing a ThingThatImWritingFramework risks ThingThatImWriting never seeing the light of day, or never being used.
- cryptozeus 10y agoYeh totally..simple but so true
- irfansharif 10y ago> "Write code that is easy to delete, not easy to extend."
- msangi 10y agoAbsolutely! https://vimeo.com/108441214 https://vimeo.com/108441214
- NumberCruncher 10y agoAt 3:57 he mentions erlang. Somehow I am not surpised.
- alkonaut 10y agoIt completely removes the fun though, if you only enjoy generalizing, optimizing, refactoring, designing, and take zero pleasure in delivering an actual usable product. If the product is Doom this shouldn't be a problem - but for most of us the product is form validation or calculations involving plywood. Making frameworks and generalization is the only reason I manage to keep doing what I do. (I'm exaggerating somewhat, but I think this is a clear distinction between two kinds of programmers those who love the code; and the craft, and those who like making products. Have too many of one kind and you'll ship a mess. Too many of the other and you'll never ship)
- xyzzy_plugh 10y agoI've never thought of it this way. While I don't necessarily agree, I'm thankful for this insight.
- NumberCruncher 10y ago>> Making frameworks and generalization is the only reason I manage to keep doing what I do. <sarcasm> This could be written on the tombstone of JS. </sarcasm>
- alkonaut 10y agoI hate writing boilerplate and I'd rather have pineapples shoved up my behind than write code of the kind that should be in the freaking standard library. But yeah
- brokenmachine 10y agoThis is what always bugged me about java. I'm only just above a beginner, but it seems to me that in 2017 you shouldn't have to write so much crap just to read from a file. BufferedReader, FileReader, blah blah blah http://www.mkyong.com/java/how-to-read-file-from-java-bufferedreader-example/ http://www.mkyong.com/java/how-to-read-file-from-java-buffer... Maybe there's a good reason to make it this difficult, if so I'm not aware of it.
- alkonaut 10y agoThere is - but there is no good reason to not have good naming plus also a simple wrapper to do the most common cases. That the IO framework is very general is good, but that you need tons of boilerplate for a common scenario is bad. C# var txt = File.ReadAllText("file.txt"); This is exactly the abstraction you want if you want to read a (whole) text file. The point of abstractions is to pick the right one. For IO it's likely best to have many layers of abstraction so you can choose the simple top level function or use a more complex one when needed. I'm sure there is something similar in Java these days too. Would be a huge mistake to not have simple IO helpers to the std library.
- hermitdev 10y agoThis is basically the Mythical Man Month in a few lines. You once wrote something specific, and it was great. Then you had to write a second thing, and you remember things from the first, so why not make it more general for the inevitable 3rd, 4th, 5th to come? And, then, you fail to deliver the 2nd.
- whazor 10y agoTheir tools are also a form of generalization. Furthermore, it is definitely possible to create value by generalization.
- a3n 10y agoYeah, sometimes. And other times, the whole contract gets spent on a framework that only makes sense if there's another contract, and ... well, I guess that never happens anymore. Didn't someone say premature generalization is the root of all evil?
- msangi 10y agoThat's indeed a very good advice. All abstractions have a cost and no abstraction is better than the wrong abstraction. I found this talk on the topic very interesting https://youtu.be/4anAwXYqLG8 https://youtu.be/4anAwXYqLG8
- Ace17 10y agoIn the same vein: prefer duplication over the wrong abstraction ( https://www.sandimetz.com/blog/2016/1/20/the-wrong-abstraction https://www.sandimetz.com/blog/2016/1/20/the-wrong-abstracti... )
- buzzybee 10y agoIt helps to allow yourself to be philosophical about what you're writing. Sometimes a generalization just moves around the problem. Sometimes the generalization you want competes badly against cut and paste. Increasingly I try to find a strategy that transitions towards the generalization over time by following a path of "lower friction instead of greater friction." It's easy to increase friction by adding a new configuration step, new concepts and idioms that are discordant with the rest of the environment, and then the point of doing it gets lost - you don't want to pay for that overhead most of the time, you can't ship code that way.
- nlyan 10y agoGeneralizing is part of how you'll be smarter later though. You cannot generalize something unless you understand its essence. It's easy to confuse abstraction (choosing to deal with one, possibly newly contrived, concept over another) and generalization (reducing the number of concepts required to explain something to a minimum). The former is like building a Haswell CPU from a description of 70s microcontroller architecture, whereas the latter is like trying to figure out what CPUs were like in the 70s by looking at a Haswell core under a microscope.
- a3n 10y ago> Write your code for this game only - not for a future game. The quote refers to a future product, one that is very likely unspecified at best, and more likely just something that an individual contributor dreamed up. Unless we have some sort of multi-phase contract, how do we know we'll ever build another thing like this again? Markets change, hardware changes, experience changes. Hell, building this thing may show you that you should never build another one like it. Generalize where sensible inside the project, sure. But as the quote says, build what you're building, not what you're not.
- hyperpallium 10y agoIf you know you're going to have to experiment a lot on some aspect of the game/product, it seems to make sense to isolate that part, removing the commonalities into some kind of framework (perhaps informal, jury-rigged, so you can iterate on just that aspect. A bit like the Wright brothers building a wind tunnel, so they could experiment quickly with control systems. But Id wrote some great games, so maybe I'm missing how they handled this aspect...
- pjmlp 10y agoThere is a saying in game circles, either one writes a game engine or a game, as most studios tend to die spending the publisher's money build the next great engine.
- EliRivers 10y agoFactories. I've got a codebase to work with using factories everywhere. Static arrays of them. Classes are given hardcoded enums and there's macro magic all over the palce to join classes to the factories that make them, and to generate all the factories in these static arrays of factories. Sometimes the static array of factories contains a single factory. Creating a single item. No variation, no types, just one kind of one item. The item is needed once. In one place.
- tluyben2 10y agoSome of these things, like focusing on the task at hand and trying to be as simple as possible, not thinking too much about the potential futures is important to me. If all would do that maybe there would not be 1000s of weird half baked npms and such.
- kensai 10y ago> Programming is a creative art form based in logic. Every programmer is different and will code differently. It’s the output that matters. This one is also nice, especially for mid to large software houses. As long as a common denominator is respected, I guess.
- contingencies 10y agoIt's enabled by encapsulation.
- lubujackson 10y agoIt reads like a "get shit done" manifesto, and good rules of thumb for most programmers tasked with doing just that. Worth remembering that iD had some of the most advanced 3D and networking code for years and really pushed the envelope and the industry forward in many ways (first huge shareware company, first big company to allow mods, first big company to make code open source, etc.) It is easy to slide into an OCD mindset when programming, to make things tidy and proper. It feels dirty to make stuff just work, to make stuff disposable, but evolution operates a lot like this - many little, reversible mistakes that add up to big improvements quicker than any other method.
- eps 10y agoI'd very curious to hear Carmack's take on this. After all Romero was making game levels, not the engines.
- pvitz 10y agoRomero made tools like DoomED and also wrote games before id.
- naiyt 10y agoYes, he's a skilled coder as well. He just seems to get overshadowed by Carmack.
- joakleaf 10y agoHe was developing large parts of e.g. Doom: He didn't write the BSP traversal and texture mapper (the graphics engine), but he did write monster AI, level behavior, and level editor. I think, I heard him state in an interview that he also did a lot of development on Quake in addition to the levels. Obviously the graphics engine was Abrash and Carmack's
- rckclmbr 10y agoI think Carmacks programming principle would be "be a genius"
- Hansi 10y ago> "No prototypes. Just make the game. Polish as you go. Don’t depend on polish happening later. Always maintain constantly shippable code." I disagree with this so much, prototypes and proof of concepts teach you so much but usually they are crap you will always write it better a second time. Throw away the prototype and re-write it as a much better implementation.
- viseztrance 10y agoHe addresses this during QA (@28:00).
- Negitivefrags 10y ago> If you plan to throw one away, you will end up throwing away two.
- NumberCruncher 10y agoFor every prototype / POC thrown away there are 9 other prototypes ending up in production or getting sold as business software. If you feel the urge to write a prototype to learn something new please do not show it to your manager/sales rep!
- mattkrause 10y agoProtoduction!
- pandaman 10y agoIn games industry nobody ships prototypes. If you manage to put one on Steam it's not going to sell much either. And yes, writing prototypes is normal, read on "Cerny method" if you are curious.
- douche 10y agoThe existence of so many half-baked and abandoned early-access games on Steam would seem to belie this claim. It's not uncommon to see a few hundred reviews for games where the developers have ghosted without finishing.
- deleted 10y ago[deleted]
- partycoder 10y agoHe described how literally hundreds of projects were successfully completed in C, targeting multiple platforms, while being first to market with innovative technology, with a small team in a pre-Internet world, These are achievements beyond belief.
- deleted 10y ago[deleted]
- hyperpallium 10y agoThis is first class post-hoc bullshit. They weren't making prototypes or reusing code, they sure as hell weren't composing high-sounding principles. They just got on with it because they were talented experienced and motivated. For that reason, the rest of the talk is very inspiring - so listen to the hour-long video (half talk, half questions), and not the article which only has the post-hoc bits. https://youtu.be/E2MIpi8pIvY https://youtu.be/E2MIpi8pIvY
- dualogy 10y ago> they were talented experienced and motivated Agreed and that's the whole secret sauce right there, combined with: no distractions (social media or indeed even "coding forums" with constant flame-wars on this and that language/stack/paradigm) and crucially also no distracting "stack" or APIs to speak of (bare metal coding literally "on top of the BIOS" in these days, no OS/GUI/multithread/GPU APIs). The initial core team spent their entire youths 24/7 getting insanely good at ASM and C and numerous gfx tricks and then "they just played the piano" to the best of their accumulated abilities. Observe how much longer the Dooms took compared to Wolfenstein and priors, and how much longer the Quakes took them compared to the Dooms.. as they were slowly entering the age of Windows native & Internet multiplayer even they too got slowed down a bit (were shocked how for Quake "just waiting for 'ze engine' took a year"!) compared to the earlier works --- of course still managed to ship high-quality products, but still
- hyperpallium 10y agoAnother eg of distraction-free programming: http://www.atariarchives.org/deli/cottage_computer_programming.php http://www.atariarchives.org/deli/cottage_computer_programmi...