TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24365 17
Anyone else decided to ditch the baby with the bathwater and redesign C++ to fit their needs?

Really long story short, Ive had this idea in my head forever for a UEFI application, but I keep running into roadblocks actually trying to debug it whenever I try to implement it.

C is a little too old and really missing proper QOL features like templates, constructors, name scoping, etc.

Rust is great but I want to beat my face in with a rake dealing with memory allocations and the lifetime system

Zig is nearly perfect. not quite convinced on the build system yet but with better documentation, im sure ill be convinced. However, its impossible to output DWARF debug info for PE/COFF targets as is UEFI. Plus alot of the debugging features are broken in UEFI targets so actually finding bugs is near impossible.

So I got left with C++, after tasting the real freedom that is modern languages. Since UEFI is essentially a freestanding target anyway so I dont get stdlib support. So I figured fuck it, lets design a stdlib to fit my own needs.

#include <efi/typedef.h>
#include <efi/status.h>


#include <allocate.h>
#include <exit.h>


#include <QEMU/debugCon.h>


extern "C" Status efi_main(EFI_HANDLE ImageHandle, SystemTable* st, void* imageBase) {
Allocator iface = poolAllocator(st);


if (Option<Slice<char>> result = iface.alloc<char>(14); result.isSome()) {
Slice<char> str = result.unwrap();
const char* lit = "Hello World!\n";
for (uintmax_t i = 0; i < str.len; i++) {
str[i] = lit[i];
}


DebugCon::putChars(0, lit);
DebugCon::putChars(0, str.ptr);


iface.free(str);
}


return Status::Success;
}

After fighting with the compiler/linker for 2 weeks to get a bootable & debuggable image where UEFI, GDB, and the compiler wouldnt complain. I was finally able to write a CRT0 runtime, and modify the linker script for constructors/deconstructors. Then implement all the UEFI base types/definitions for a bare minimal environment and to properly handle debugging. Then I could start to implement core types like slice<t> and option<t> to handle things like memory allocations via a consumable interface.

Its been a rough several weeks, but im finally at the point where the "standard" library I will be using is starting to take enough shape. Just to make the above code run properly without bugs is \~2500 lines of code lol.

https://redd.it/1p7zlou
@r_cpp
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
More from @r_cpp
  1. Oct 11, 2026wxWidgets 3.2.12 and 3.3.4 Released https://wxwidgets.org/news/2026/10/wxwidgets-3.2.12-an…
  2. Oct 11, 2026VKRT NES Remaster — an open-source C++20 NES emulator with an observation-driven remasteri…
  3. Oct 11, 2026Right way to test async code https://redd.it/1x2wqgz @r_cpp
  4. Oct 10, 2026Yantra: an LALR(1) parser generator for C++23 Yantra: an LALR(1) parser generator for C++2…
  5. Oct 10, 2026Opting in, and back out again https://dryperspective.github.io/posts/opting-in/ https://re…
  6. Oct 10, 2026I’m Building Bursztyn OS a Polish Operating System From Scratch I’m building Bursztyn OS,…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →