John (@MrJayLC) header
John (@MrJayLC) profile picture

CEO #htmx Foundation Putting C back in CDeezNutz Inc. Master of CompSci Hobby 3D Animator Competitive shooter Occasional DnDer Wool is king, thanks Grandma

Norway
Joined March 2011
Photo by John (@MrJayLC)Photo by John (@MrJayLC)Photo by John (@MrJayLC)Photo by John (@MrJayLC)Photo by John (@MrJayLC)Photo by John (@MrJayLC)Photo by John (@MrJayLC)Photo by John (@MrJayLC)Photo by John (@MrJayLC)Photo by John (@MrJayLC)
Replying to @IroncladDev
Unless the preference is unaligned indentation, anyone who prefers aligned indentation either prefers 1 space indentation or tabs. The rest are posers.
1
1
5
2,986
Is LTO just linker unity builds passed back to the optimizer???
6
The C++ implicit lifetime rules are like the antethesis to Effective Types in C. C probably had that one right. Again...
6
I didn't know, but I think I need this.
Replying to @MrJayLC
That is the goal, yes.
11
On this note, a stdlib c++ implementation could probably provide pure interface structures for the underlying system, where the data is internal by type erasure to the public interface struct. Inside you reintepret_cast the this pointer to it's original data type. UB? probably.
Replying to @schteppe
methods are not real.
11
So you could use safe<int>... OR static_cast<unsigned>(x) + 1 < static_cast<unsigned>(x) Just fucking learn the language oh my lord.
bool will_overflow(int x) { return x + 1 < x; } GCC and Clang compile that to return false at -O2 Signed overflow is undefined, so the optimizer assumes it never happens and deletes the check you wrote to catch it 🧵👇
14
And this is completely void for string literals, if they are not zero-terminated, the compiler is wrong (or you used raw literal strings in C++).
If you have no guarantee that you've correctly 0-terminated your 0-terminated strings, then you have no guarantee that you've correctly sized your sized string.
1
1
65
I guess dogfooding is a symbiosis with Conway's Law, in that since the needs of a system or product is reflective on the organization and it's communication boundaries, by using the system or product you are effectively restructuring to align with communications of the customer.
10
C++: "Leave no room for a lower level language." Odin: gingerbill.org/article/2026/… These are the language type tools I have been looking to see for C as well, example: specifying internal calling conventions and other goodies for specific 2% problems that are load-bearing.
11
Here I am reading the mans article, and he rabbit holes me. >:(
Replying to @MrJayLC
Why don't you check for yourself with the emitted assembly itself?
11
C++: "You can't take the sizeof your type within the {} and use it with static_assert, because the static_assert is evaluated in incomplete-type context." y tho. It's the definition of the class. This is so dumb, why!?
11
So, C(23)?
When I look at C code, every bone in my body wants to rewrite it in an actually maintainable language can't really explain why
16
Built-in types should be built-in, no std:: necessary. CFI is the baseline, no headers required.
Rant time: the fact that std::initializer_list in C++ is a partial language construct with special syntax, a compiler-generated array with special lifetime, yet needs a header and an std::initializer_list to provide a type is BONKERS. Looks like any other std type, yet it's not.
21
If I see a vector of pointers in any code, there better be an insanely good reason for it. Or it's fired.
I’d approve this raw pointer in a C++ review. the parent owns its children. the parent link is borrowed, with the parent required to outlive the child. the ownership model matters more than making every pointer smart.
1
35
Just one line of deduction guide, and no more need to wrap up functions in silly "deleter" structs. C++, the language of mistakes and missed opportunities. If you wanna keep sizes down, use lambdas instead of function objects (allows sprinkling of keywords too). CTAD ftw.
You can keep a C library and still use C++ to manage its resources. A small wrapper around FILE* removes manual closing from the normal return paths and exception paths. This is the kind of C++ abstraction I find easy to justify.
34
John retweeted
Replying to @pikuma
1
7
159
Like @ThePrimeagen says: "Choose your hard". Hard now or hard later. Echoes sentiments of Marcus Aurelius and other great stoics.
Sylvester Stallone makes an excelent point.
30
tfw the __builtin_source_location() on gnu uses a type defined in the <source_location> header... So you can't use the builtin without including a header. The fuck is the point of *BUILTIN* stuff if you need to include headers??? Absolutely hate forcing in Standard Libraries.
30
Someone did not read their C++ object model section or the casting rules section. cppreference's biggest page is probably on casting. C is pretty cool tho.
Types can be nothing in C/C++ where casting is allowed freely. You can disassemble and assemble bytes from the types such as "uint_64" or classes. You can cast pointer types and play with the wild "void *". Types: syntax sugar.
1
29
Ginger Bill put into words pretty much my feelings every time I write "template <typename T>", look into type_traits or concepts, or the C++ print templates... Many such cases where the types I want to use have the same interface, and I want some static virtual dispatching.
1
19