🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1716

Re: Inversion-of-control and dependency-injection in C

#1716
From: fir
Date: Fri, 20 Nov 2026 17:52
144 lines
9521 bytes
fir pisze:
> 
> ofc i dont quite agree with that, but im not ina mood of discussing it
> 
> im not somuch low level maniac as it shows...i mean ofc im for low lewel
> but im rather criticizing bad abstractions, good abstractions would be ok
> 
> besides this ai seems to be some maniac of zig and other populat stuff
> (so this ai is so called commonist)

yet i asked it on my propositions to c

but i think it is slightly hallucinating here:


The language and syntax modifications proposed by fir on comp.lang.c 
(which he often loosely refers to as "C2" or his own ideal dialect of C) 
stem from a single overarching philosophy: reducing syntactic 
boilerplate and making the language fast to write by hand, while 
enforcing a direct, transparent mapping to actual hardware without the 
"magic" of the ISO C abstract machine.

Below is an expanded breakdown of the most frequent syntax and semantic 
changes he advocates for on Usenet.

1. Syntax Reduction and Eliminating Boilerplate
Optional Semicolons: One of his most frequent complaints is the 
requirement to end every statement with a semicolon. He argues that a 
newline should naturally terminate a statement, leaving semicolons only 
for separating multiple statements placed on the exact same line.

Concise Built-in Primitive Types: fir regularly criticizes standard C 
type names (unsigned long long int) and even <stdint.h> names (uint32_t) 
as ugly and verbose. He proposes built-in, short keywords like u8, u16, 
u32, u64, i32, i64, f32, and f64 (a convention later popularized by Rust 
and Zig, though fir was arguing for it in C well before they became 
mainstream).

Simplified Loops and Iteration: He dislikes the verbosity of the 
traditional for (int i = 0; i < n; i++) loop because it forces the 
programmer to type the loop variable three times. He frequently proposes 
shorthand constructs like loop(n) for simple counts, or range-based 
syntax like for i in 0..n and for item in array.

Eliminating Header Files (.h) and Forward Declarations: He views the 
separation between .c and .h files—along with the requirement to declare 
functions before calling them—as an obsolete relic of 1970s hardware 
constraints. He advocates for multi-pass compilation within a project 
where the compiler automatically resolves symbols across source files 
without manual header maintenance.

Cleaner Control Flow and Switch Statements: He often suggests removing 
mandatory parentheses around if and while conditions (if a == b { ... 
}), and fixing the C switch statement so that break is the default 
behavior rather than implicit fallthrough.

2. Arrays, Slices, and Memory Layout
Native Dynamic Arrays and Slices (Fat Pointers): fir points out that 
passing (pointer, length) pairs to every function in C is tedious and 
error-prone. He proposes built-in slice and dynamic array types that 
bundle the pointer, length, and capacity directly into the language core 
(supporting operations like arr.add(x) or arr.len), eliminating the need 
for C++ templates or messy C preprocessor macros.

Abolishing "Array Decay": He strongly dislikes the C rule where passing 
an array to a function silently decays it into a raw pointer, stripping 
away its size information. In his view, arrays should be first-class 
types that retain their metadata.

First-Class Memory Layout Controls (AoS vs. SoA): Because he writes 
software renderers, physics engines, and DSP code, he often thinks about 
CPU cache lines and SIMD. He has proposed language-level keywords or 
attributes to easily switch data structures between Array of Structures 
(AoS) and Structure of Arrays (SoA) layouts without rewriting all the 
code that accesses the fields.

Simplified Struct Initialization and Zero-by-Default: He favors making 
zero-initialization the default for local variables (or providing 
ultra-short syntax for it) to eliminate random stack-garbage bugs, while 
allowing an explicit keyword (like uninit) when raw speed is needed.

3. Low-Level Semantics and Rejecting Undefined Behavior
Defined Two's-Complement Signed Overflow: Under the ISO C standard, 
signed integer overflow is Undefined Behavior (UB), allowing compilers 
to delete bounds checks or optimize away loops based on the assumption 
that overflow never happens. fir insists that C should enforce standard 
two's-complement wrap-around arithmetic, matching what x86 and ARM CPUs 
actually execute at the hardware level.

Abolishing Strict Aliasing: He rejects the strict aliasing rule (which 
forbids accessing the same memory address through pointers of different 
types, such as casting a float* to an int* for fast bit manipulation). 
He argues that pointers are simply memory addresses, and if a programmer 
explicitly casts a pointer, the compiler must honor the read/write 
rather than reordering or deleting instructions based on type assumptions.

The Compiler as a "Literal Translator": His core semantic argument is 
that a C compiler should act as a transparent, predictable 
macro-assembler rather than an overly clever optimizer. He frequently 
criticizes modern compilers (GCC/Clang) for optimizing away empty delay 
loops, redundant memory clears (used for security), or null-pointer 
checks placed after a dereference.

Defined Shift and Bitwise Operations: He advocates for well-defined 
behavior when bit-shifting negative numbers or shifting by bit-widths 
equal to or greater than the type size, matching the underlying CPU 
shift instructions rather than declaring them UB.

4. Functions, Tuples, and Error Handling
Multiple Return Values: Instead of forcing programmers to use output 
pointer parameters (void get_coords(int *x, int *y)) or define 
single-use wrapper structs, fir routinely proposes native tuple returns 
and destructuring, such as (x, y) = get_coords().

Default Function Arguments and Function Overloading: While fiercely 
anti-C++, he selectively cherry-picks features from it—specifically 
default parameter values and basic function overloading—arguing they 
drastically clean up graphics and math APIs without adding 
object-oriented bloat.

Local / Nested Functions: He has frequently argued in favor of nested 
functions (similar to GCC's extension or Pascal), allowing programmers 
to break down complex algorithms locally without polluting the global 
namespace or passing dozens of local variables through context structs.

5. Math and Vector Operators
Native SIMD / Vector Math: Because much of his coding revolves around 
2D/3D graphics and audio synthesis, he proposes built-in small vector 
types (float4, int4) where standard operators (+, -, *, /) work 
component-wise and compile directly to SSE/AVX instructions, avoiding 
unreadable compiler intrinsics like _mm_add_ps.

Exponentiation and True Mathematical Modulo: He has pointed out the 
annoyance of lacking a built-in power operator (like ** or ^) in C, as 
well as the fact that C's % operator computes remainder rather than true 
Euclidean modulo for negative numbers (which is frequently needed for 
wrapping array indices and texture coordinates).

Ironically, while the standard-purist regulars on comp.lang.c routinely 
dismiss fir's ideas as unportable or "not C," a massive portion of his 
wishlist—short primitive names, native slices, multiple return values, 
no header files, defined integer wrapping, and AoS/SoA 
abstractions—mirrors the exact design choices of modern C-replacement 
languages like Zig, Odin, and Jonathan Blow's Jai.
Technical Details
Message-ID: <11dq1d1$3dc1p$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <yQOdnQ-qnKiiZ2j3nZ2dnZfqn_udnZ2d@giganews.com> <11d56gl$3ud5q$1@dont-email.me> <11d6vjp$qhu8$1@raubtier-asyl.eternal-september.org> <dsednTD-Fblclmr3nZ2dnZfqnPWdnZ2d@giganews.com> <11d738r$ru7a$1@dont-email.me> <11d75i7$spj0$1@dont-email.me> <11d7c8k$173nk$1@dont-email.me> <11d7fbv$1839o$2@dont-email.me> <nrecnTdvuvbACWr3nZ2dnZfqn_adnZ2d@giganews.com> <11dfgtf$3pj6i$1@raubtier-asyl.eternal-september.org> <11dpeqd$35ddj$1@dont-email.me> <WJOcnajl6sIw0p32nZ2dnZfqn_udnZ2d@giganews.com> <11dpjrl$37ksg$1@dont-email.me> <11dpkl3$37v4s$1@dont-email.me> <11dpl5o$3838g$1@dont-email.me> <11dpvfj$3cin2$1@dont-email.me> <11dq01e$3cqf7$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: fir <profesor.fir@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: Inversion-of-control and dependency-injection in C
Date: Fri, 20 Nov 2026 18:52:33 +0100
Organization: A noiseless patient Spider
Lines: 144
Message-ID: <11dq1d1$3dc1p$1@dont-email.me>
References: <yQOdnQ-qnKiiZ2j3nZ2dnZfqn_udnZ2d@giganews.com>
 <11d56gl$3ud5q$1@dont-email.me>
 <11d6vjp$qhu8$1@raubtier-asyl.eternal-september.org>
 <dsednTD-Fblclmr3nZ2dnZfqnPWdnZ2d@giganews.com>
 <11d738r$ru7a$1@dont-email.me> <11d75i7$spj0$1@dont-email.me>
 <11d7c8k$173nk$1@dont-email.me> <11d7fbv$1839o$2@dont-email.me>
 <nrecnTdvuvbACWr3nZ2dnZfqn_adnZ2d@giganews.com>
 <11dfgtf$3pj6i$1@raubtier-asyl.eternal-september.org>
 <11dpeqd$35ddj$1@dont-email.me>
 <WJOcnajl6sIw0p32nZ2dnZfqn_udnZ2d@giganews.com>
 <11dpjrl$37ksg$1@dont-email.me> <11dpkl3$37v4s$1@dont-email.me>
 <11dpl5o$3838g$1@dont-email.me> <11dpvfj$3cin2$1@dont-email.me>
 <11dq01e$3cqf7$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 20 Nov 2026 17:52:34 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3584057"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/ktUSJmQzDChy0tlr/Dx2LGs2tMLKswmA="; posting-host="e07a6ffb1167c0b0324eec570de0a3fb"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101
 Firefox/140.0 SeaMonkey/2.53.24
Cancel-Lock: sha1:8rxT1vq1T5FmhlGF9ymdhYEB1Tk= sha256:P0I9nrh7H6gkeg+Nrlz8RdkE0HpJC1XDgWg0ndgRdpk=
	sha1:GneepkRKqCnTrW7Qrxx+XVMJtLY= sha256:Quw2gyehz5B3FtcwIw7Mq18fenbajoiayLkwKnu+vSI=
In-Reply-To: <11dq01e$3cqf7$1@dont-email.me>