Quake III Arena GPL Source Release (2012)
github.com
github.com
More info: https://en.wikipedia.org/wiki/Fast_inverse_square_root
https://github.com/id-Software/wolf3d/blob/master/WOLFSRC/WL...
- The client/server network protocol and syncing state
- The VM architecture (e.g. most of the game can be compiled by LCC into a custom byte code and interpreted. This was for safely (although I wouldn't be as sure these days) distributing mods iirc. I think the main game was shipped compiled to x86 though. The interface between the VM and the core stuff is via "syscalls" and its fun to see how that's wired up.)
- The player physics/controls (i.e. walk/jump/collisions/etc.) (it's neat how fake first-person player physics always is. This isn't unique to quake 3 but quake 3 had notably good controls.)
It's a bit fun to trace what happens on 'w' keydown/keyup (when bound to walk forward.) When I first saw how that actually worked I was surprised (hint: it types commands invisibly into the command console ;) lots of string copies to do that.)
https://github.com/id-Software/Quake-III-Arena/blob/dbe4ddb1...
They implemented adaptive huffman coding but ironically only use it during static initialization, feeding it with static data (see the defn of msg_hData a few lines up.) Note that the only calls to Huff_addRef are in the init, and notice how it gets called - the loop over msg_hData[i]. I found that pretty funny. I'm guessing there was some plans to use it adaptively but it's not easy/obvious how to keep it in sync reliably...
[0] http://kristianduske.com/trenchbroom/
[1] https://www.quaddicted.com/ & http://www.celephais.net/board/
Nevertheless, I appreciated the open source release very much back in 2005, as it allowed you to learn C programming in a friendly way. Not just that testing is like playing a game, but they have build a lot of platform independent functions to provide cross platform support.
https://github.com/id-Software/Quake-III-Arena/blob/master/c...
Anyway this is game engine code and very old. I doubt you would find perfect formatting if it were spaces either.
You wouldn't need to customize anything, it would look good at all tab widths and people who prefer 2 space sized indents would be able to use that in their editors.
Actually, it could be even better, we could use tabs for aligning to tables too if editors supported elastic tabstops [0]. Unfortunately, the only ones that do don't support other essential features like saving when they lose focus.
Please note that i disagree with how the example aligns function params. The space/tab there looks bad and params should be aligned with spaces using a formatting tool (which every sane language should have).
Or, y'know, scratch that, why don't we commit the AST (enhanced to include comments and other hints like blank lines) to git and let everyone use their formatting.
</rant>
Furthermore if your coding style imposes some kind of width restriction you also have to commit to a certain tab width anyway.
Beyond that if you really value configurability it's a bit odd to limit yourself to "I want to configure tab width". How about bracket positions, spacing between operators, variable names etc... ? All these seems are arguably more important for readability and code understanding than indentation. Ideally programming languages would be stored as abstract syntax trees that you can display however you like but we're still using dumb all ASCII text files.
In theory tabs are mildly superior to spaces, pragmatically it's spaces all day every day as far as I'm concerned.
It shouldn't be left to the devs.
All languages should have something like Go's gofmt -- or even better, mandatory whitespacing/tabs rules. If you don't respect them (which the auto format tool could help you automatically do), the program shouldn't compile.
It exists `clang-format`
But they're not widely accepted by most languages devs (like gofmt is by Go programmers), nor is their use enforced by the compiler (even in Go).
I have no issue whatsoever with using tabs in an editor, as long as it saves them as spaces on disk.
The only valid argument is that mixing spaces and tabs for indentation messes things up, but that argument works both ways so doesn't support either side in this never ending argument.
That means that if you want to avoid a mixed codebase it is far easier to get to and stay at spaces only than tabs-for-indent, spaces-for-alignment.
Of course you can also configure all the alphanumeric characters by changing your terminal font. I'm only half joking - it's not supposed to be important what the letters look like, only what they mean. ASCII art is not guaranteed to look good, whether or not it uses tabs.
Cool example on BEL.
And this is why you use spaces for everything.
I can't imagine anyone would manually press the spacebar N times to get the desired indentation level.
Except with tabs everyone gets whatever width they want. Tab width is configurable system wide (and even in GitHub’s terrible web view).
Spaces are objectively worse in every possible way and require workarounds and editor hacks to make them behave like tabs. Skip a step & just use tabs: much better.
Go here in a browser: https://github.com/id-Software/Quake-III-Arena/blob/master/c...
Note that the use of tabs has caused un-alignment. You've claimed that tab width is configurable in git's web view, but I can't figure out how to do it.
And further, if it requires me to configure in a certain way, then it's not really true that "everyone can configure tabs how they want".
Spaces. Set it and forget it. Works everywhere, every time. Objectively better.
You can't really say that definitively without ignoring the laundry list of negatives that come with spaces. Spaces are not configurable at all. That, in itself, is reason enough that Tabs are "objectively better".
You literally provided me with more proof spaces are bad. Good example.
This, too, can be fixed in most editors.
[0] https://www.sublimetext.com/
someType someFunctionName(
param1, param2, ...)
{
statement1;
statement2;
...
}
I find that following a style like this will work equally well with tabs or spaces and that I have to spend less time formatting code I write (either manually or changing a setting in the editor I'm using).No matter how you do it[0], alignment is bad for maintainability. It happens that someType or someFunctionName changes, and if you use alignment, you'll have to re-align all those parameters. This is annoying to do even with editor help, and it generates noisy diffs which make patch review needlessly more difficult. Aligning the names of member variables is even worse.
Just Say No to alignment, perhaps? ;)
[0] Well, except if you use "elastic tabs", which don't have widespread support in the first place.
I edit code in an editor way, way more often than look at it on GitHub. Every day when I edit code indented with spaces and my various editors don't correctly handle every edge-case for backspacing, de-denting, etc. I am reminded why I prefer tabs over spaces. It's such a common event for me that I probably wouldn't remark on it without some prompting.
My guess is that some people use them as bookmarks... but isn't that what stars are for?