libCat
DOOM
libCat | DOOM | |
---|---|---|
21 | 91 | |
66 | 13,675 | |
- | 2.5% | |
9.0 | 2.1 | |
3 months ago | 4 months ago | |
C++ | C++ | |
Mozilla Public License 2.0 | GNU General Public License v3.0 only |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
libCat
-
I hate almost all software
That's awesome! I'm working on something that sounds similar. https://github.com/cons-cat/libcat
I'd love to see your work if you're willing to share it here!
-
Why Janet?
This runtime size bothers me a lot. So much that I've been working on a new runtime for C++ that breaks POSIX compatibility to keep binaries as small as they can be. The hello world with LTO is 330ish bytes right now, and I think that can get smaller. https://github.com/Cons-Cat/libCat
- Manticore 6.0.0 – a faster alternative to Elasticsearch in C++
-
std::initializer_list in C++ 1/2 - Internals and Use Cases
I'm working on a library that replaces both C++ and C/POSIX standard libraries (https://github.com/Cons-Cat/libCat), but even then I need to define a few std:: namespace symbols for some features. In the case of std::initializer_list, my answer is just don't use that feature, because you don't really need it.
-
Chromium accepting Rust in a clear move to copy what Mozilla have done, replace C++ source code
It's worse in the standard library than it has to be. When I refactored my traits to minimize template instantiations and lean on concepts as much as possible, I measured over 30% improvement to clean build compile times. It's not possible for the standard to do this, because it would subtly change the API. For instance, you can't instantiate or take the address of a concept, but you can for a type-trait class. No reason you'd want to do that, but you can, so they can't "break" the standard library by optimizing this.
-
C++'s smaller cleaner language
This doesn't have to be true. Over the past year I've made progress towards demonstrating how even non-freestanding C++ can be written without any C or C++ standard library headers or DLLs (with large benefits). There are a few names which the compilers require to be in the std:: namespace, though, but they're very special features like source_location and construct_at with semantics that can't be expressed otherwise.
-
C++ is essentially unusable without incurring undefined behavior because of it's failure to handle type punning.
This bit cast has no overhead in debug mode, and is a little bit more generally useful than std::bit_cast(), but cannot be constant evaluated. https://github.com/Cons-Cat/libCat/blob/main/src/libraries/utility/implementations/bit_cast.tpp
-
Is bloat in std::unexpected expected?
It isn't that hard to put a predicate into a type. We have lambdas in an unevaluated context, CTAD, and templated type aliases. https://github.com/Cons-Cat/libCat/blob/main/src/libraries/scaredy/cat/scaredy https://github.com/Cons-Cat/libCat/blob/main/src/global_includes.hpp#L70 https://github.com/Cons-Cat/libCat/blob/main/src/libraries/linux/cat/linux#L289 You do it like this.
-
CamelCase for C++?
But suppose that you have code with no standard library calls at all. Would it still make sense to choose this naming convention? This is actually possible, with a few special exceptions. GCC requires that an implementation of std::source_location has very particular class member names, GCC assigns special semantics to a few function names including std::construct_at and std::move (people seem to know it's inlined, but did you know std::move is required for move-related warnings?), and most intrusively of all, a promise_type must be snake_case. Other names can be worked around by using them into a different namespace with a different letter-case, but promise_type seems unavoidable.
-
Competitive programmer using c++, but absolutely ignorant of other things the language can do here. What else can c++ do?
I use C++ for a low-level Linux runtime. Other people are using it for operating systems like SerenityOS and Zircon/Fuschia. People also use C++ for making more compilers like GCC and LLVM.
DOOM
-
Doom Released Under GPLv2
commercially exploit or use for any commercial purpose."
[1] https://github.com/id-Software/DOOM/commit/4eb368a960647c8cc...
-
GTA 5 source code leaks online
The original Doom had third-party audio playback routines, so the source came with a rewritten sound server: https://github.com/id-Software/DOOM/tree/master/sndserv
The bad news: this code only compiles and runs on linux. We couldn't
- What you can do with C ?
-
Software Disenchantment
Here's a repo for you with no test coverage and no auto-generated DI. They using unsafe pointers all over the place, too!
https://github.com/id-Software/DOOM
Shall I prepare the postage for the letter in which you'll call John Carmack an MBA? Should we send another to Chris Sawyer? I heard he didn't even write a formal design doc for Roller Coaster Tycoon!
-
Ask HN: Good practices for my first C project
cURL is one of the most used C libs and is an example of good quality C code. If you follow the style used there, see e.g. https://github.com/curl/curl/blob/master/lib/dynhds.h (and associated dynhds.c) you will be good.
Looking at the source of some of the old game-engines from the era that have since been released as open-source can also be helpful, like https://github.com/id-Software/DOOM.
In both cases notice how simple and elegant a lot of the code is. There is already enough complexity inherent in the problem they are solving, and that is where the focus should be.
Any IDE with a working language server to make it easy to jump around and refactor should work fine. Limitations might be due to the C language itself?
Error handling on such a fixed platform does not need to be super-advanced. You should always be within the confines of the system so there shouldn't be much that can go wrong. If stuff goes wrong anyway just being able call a function Fatal("FooBar failed with code 34") when unexpected stuff happens and have it log somewhere to be able to dig around should be enough. You never need to be able to recover and retry.
Make sure to use https://clang.llvm.org/docs/AddressSanitizer.html or a similar tool when developing outside of the PSOne.
That said, consider statically allocating global buffers for most stuff and avoid using the heap for most stuff.
Good luck working within the confines of the PSOne! Many hackers have pulled the hair from their head on that platform ;)
- Ask HN: Where do I find good code to read?
-
Running Stable Diffusion in 260MB of RAM
Probably more easily than you'd think. DOOM is open source[1], and as GP alludes, is probably the most frequently ported game in existence, so its source code almost certainly appears multiple times in GPT-4's training set, likely alongside multiple annotated explanations.
[1] https://github.com/id-Software/DOOM
- Where can I get game files to study?
-
Some were meant for C [pdf]
I'd define an arena as the pattern where the arena itself owns N objects. So you free the arena to free all objects.
My first job was at EA working on console games (PS2, GameCube, XBox, no OS or virtual memory on any of them), and while at the time I was too junior to touch the memory allocators themselves, we were definitely not malloc-ing and freeing all the time.
It was more like you load data for the level in one stage, which creates a ton of data structures, and then you enter a loop to draw every frame quickly. There were many global variables.
---
Wikipedia calls it a region, zone, arena, area, or memory context, and that seems about right:
https://en.wikipedia.org/wiki/Region-based_memory_management
It describes history from 1967 (before C was invented!) and has some good examples from Apache ("pools") and Postgres ("memory contexts").
I also just looked at these codebases:
https://github.com/mit-pdos/xv6-public (based on code from the 70's)
https://github.com/id-Software/DOOM (1997)
I looked at allocproc() in xv6, and gives you an object from a fixed global array. A lot of C code in the 80's and 90's was essentially "kernel code" in that it didn't have an OS underneath it. Embedded systems didn't run on full-fledges OSes.
DOOM tends to use a lot of what I would call "pools" -- arrays of objects of a fixed size, and that's basically what I remember from EA.
Though in g_game.c, there is definitely an arena of size 0x20000 called "demobuffer". It's used with a bump allocator.
---
So I'd say
- malloc / free of individual objects was NEVER what C code looked like (aside from toy code in college)
- arena allocators were used, but global vars and pools are also very common.
- arenas are more or less wash for memory safety. they help you in some ways, but hurt you in others.
The reason C programmers don't malloc/free all the time is for speed, not memory safety. Arenas are still unsafe.
When you free an arena, you have no guarantee there's nothing that points to it anymore.
Also, something that shouldn't be underestimated is that arena allocators break tools like ASAN, which use the malloc() free() interface. This was underscored to me by writing a garbage collector -- the custom allocator "broke" ASAN, and that was actually a problem:
https://www.oilshell.org/blog/2023/01/garbage-collector.html
If you want memory safety in your C code, you should be using ASAN (dynamically instrumented allocators) and good test coverage. Arenas don't help -- they can actually hurt. An arena is a trivial idea -- the problem is more if that usage pattern actually matches your application, and apps evolve over time.
-
What is your gender?
Doom
What are some alternatives?
Magic Enum C++ - Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code
open-watcom-v2 - Open Watcom V2.0 - Source code repository, Wiki, Latest Binary build, Archived builds including all installers for download.
AECforWebAssembly - A port of ArithmeticExpressionCompiler from x86 to WebAssembly, so that the programs written in the language can run in a browser. The compiler has been rewritten from JavaScript into C++.
project-based-tutorials-in-c - A curated list of project-based tutorials in C
Kalman - Kalman Filter
doomgeneric - Easily portable doom
expected - C++11/14/17 std::expected with functional-style extensions
Apollo-11 - Original Apollo 11 Guidance Computer (AGC) source code for the command and lunar modules.
blender-tools - 🐵 Embark Addon for Blender
luxtorpeda - Steam Play compatibility tool to run games using native Linux engines
EA Standard Template Library - EASTL stands for Electronic Arts Standard Template Library. It is an extensive and robust implementation that has an emphasis on high performance.
angband - A free, single-player roguelike dungeon exploration game