Safer Casting in C — With Zero Runtime Cost
https://www.reddit.com/r/programming/comments/1sfomcl/safer_casting_in_c_with_zero_runtime_cost/
submitted by /u/Yairlenga (https://www.reddit.com/user/Yairlenga)
[link] (https://medium.com/@yair.lenga/safer-casting-in-c-with-zero-runtime-cost-making-casts-visible-auditable-and-harder-to-misuse-331b3a3a8090) [comments] (https://www.reddit.com/r/programming/comments/1sfomcl/safer_casting_in_c_with_zero_runtime_cost/)
https://www.reddit.com/r/programming/comments/1sfomcl/safer_casting_in_c_with_zero_runtime_cost/
submitted by /u/Yairlenga (https://www.reddit.com/user/Yairlenga)
[link] (https://medium.com/@yair.lenga/safer-casting-in-c-with-zero-runtime-cost-making-casts-visible-auditable-and-harder-to-misuse-331b3a3a8090) [comments] (https://www.reddit.com/r/programming/comments/1sfomcl/safer_casting_in_c_with_zero_runtime_cost/)
I Am Very Fond of the Pipeline Operator
https://www.reddit.com/r/programming/comments/1sfoqwq/i_am_very_fond_of_the_pipeline_operator/
submitted by /u/techne98 (https://www.reddit.com/user/techne98)
[link] (https://functiondispatch.substack.com/p/i-am-very-fond-of-the-pipeline-operator) [comments] (https://www.reddit.com/r/programming/comments/1sfoqwq/i_am_very_fond_of_the_pipeline_operator/)
https://www.reddit.com/r/programming/comments/1sfoqwq/i_am_very_fond_of_the_pipeline_operator/
submitted by /u/techne98 (https://www.reddit.com/user/techne98)
[link] (https://functiondispatch.substack.com/p/i-am-very-fond-of-the-pipeline-operator) [comments] (https://www.reddit.com/r/programming/comments/1sfoqwq/i_am_very_fond_of_the_pipeline_operator/)
Implementing C++ STL containers in pure C — what I learned
https://www.reddit.com/r/programming/comments/1sg1apu/implementing_c_stl_containers_in_pure_c_what_i/
<!-- SC_OFF -->I've been experimenting with implementing C++ STL-style containers (vector, list, deque, set, map, stack, queue, priority_queue, unordered_set, unordered_map) as a single-header C library using C99 macros and variadic dispatch. The goal was to see how close you can get to the C++ STL interface in pure C — same function names like push_back, insert, erase, find, begin/end — without requiring a C++ compiler. A few interesting design challenges came up: 1. Bracket access (v[i]) For VECTOR and DEQUE, the handle is just a * pointing into the data region, so v[i] works naturally as pointer arithmetic. Metadata (size, capacity) is stored before the pointer address. This also means you can pass a vector directly to qsort or bsearch with no wrapper. ```c VECTOR(int) v = new_vector(int); for (int i = 0; i < 10; i++) push_back(v, i); qsort(v, size(v), sizeof(int), my_cmp); // just works printf("%d", v[3]); // bracket access destroy(v); ``` 2. Variadic overloading in C Using macro argument counting, different parameter counts dispatch to different behaviors: c insert(v, v + 3, 777); // insert single value at position insert(v, v + 5, 3, 999); // insert N copies at position This mimics C++ overloading without _Generic per se — it's purely preprocessor-driven dispatch based on argument count. 3. Uniform API across container types The same insert, erase, find names work across all container types. A single macro routes to the correct implementation based on the container's internal tag. Node-based containers (list, set, map) use next(it) / prev(it) for iteration instead of it++. ```c // Dijkstra with VECTOR + PRIORITY_QUEUE typedef struct { int cost, to; } Edge; int compare_edge(const void a, const void *b) { return ((Edge)a)->cost > ((Edge)b)->cost ? -1 : ((Edge)a)->cost < ((Edge*)b)->cost; } int dijkstra(Edge *graph, int src) { VECTOR(int) dist = new_vector(int); QUEUE(Edge) pq = new_priority_queue(Edge, compare_edge); assign(dist, size(graph), 99999); dist[src] = 0; push(pq, (Edge){0, src}); while (!empty(pq)) { Edge e = top(pq); pop(pq); for (int i = 0; i < size(graph[e.to]); i++) { int next_to = graph[e.to][i].to; int new_cost = dist[e.to] + graph[e.to][i].cost; if (dist[next_to] > new_cost) { dist[next_to] = new_cost; push(pq, (Edge){new_cost, next_to}); } } } destroy(pq); return dist; } ``` Compiler compatibility was another rabbit hole — getting this to work across MSVC, GCC, Clang, MinGW64, icx-cc, and TCC required quite a bit of conditional preprocessing, especially around __VA_ARGS__ handling differences. Source is here if anyone wants to look at the macro internals: https://github.com/springkim/OpenCSTL Curious what people think about this approach. Has anyone else tried building STL-like abstractions in C? What tradeoffs did you hit? I'm especially interested in opinions on the metadata-before-pointer trick for bracket access — it works well but feels a bit cursed. <!-- SC_ON --> submitted by /u/springnode (https://www.reddit.com/user/springnode)
[link] (https://github.com/springkim/OpenCSTL) [comments] (https://www.reddit.com/r/programming/comments/1sg1apu/implementing_c_stl_containers_in_pure_c_what_i/)
https://www.reddit.com/r/programming/comments/1sg1apu/implementing_c_stl_containers_in_pure_c_what_i/
<!-- SC_OFF -->I've been experimenting with implementing C++ STL-style containers (vector, list, deque, set, map, stack, queue, priority_queue, unordered_set, unordered_map) as a single-header C library using C99 macros and variadic dispatch. The goal was to see how close you can get to the C++ STL interface in pure C — same function names like push_back, insert, erase, find, begin/end — without requiring a C++ compiler. A few interesting design challenges came up: 1. Bracket access (v[i]) For VECTOR and DEQUE, the handle is just a * pointing into the data region, so v[i] works naturally as pointer arithmetic. Metadata (size, capacity) is stored before the pointer address. This also means you can pass a vector directly to qsort or bsearch with no wrapper. ```c VECTOR(int) v = new_vector(int); for (int i = 0; i < 10; i++) push_back(v, i); qsort(v, size(v), sizeof(int), my_cmp); // just works printf("%d", v[3]); // bracket access destroy(v); ``` 2. Variadic overloading in C Using macro argument counting, different parameter counts dispatch to different behaviors: c insert(v, v + 3, 777); // insert single value at position insert(v, v + 5, 3, 999); // insert N copies at position This mimics C++ overloading without _Generic per se — it's purely preprocessor-driven dispatch based on argument count. 3. Uniform API across container types The same insert, erase, find names work across all container types. A single macro routes to the correct implementation based on the container's internal tag. Node-based containers (list, set, map) use next(it) / prev(it) for iteration instead of it++. ```c // Dijkstra with VECTOR + PRIORITY_QUEUE typedef struct { int cost, to; } Edge; int compare_edge(const void a, const void *b) { return ((Edge)a)->cost > ((Edge)b)->cost ? -1 : ((Edge)a)->cost < ((Edge*)b)->cost; } int dijkstra(Edge *graph, int src) { VECTOR(int) dist = new_vector(int); QUEUE(Edge) pq = new_priority_queue(Edge, compare_edge); assign(dist, size(graph), 99999); dist[src] = 0; push(pq, (Edge){0, src}); while (!empty(pq)) { Edge e = top(pq); pop(pq); for (int i = 0; i < size(graph[e.to]); i++) { int next_to = graph[e.to][i].to; int new_cost = dist[e.to] + graph[e.to][i].cost; if (dist[next_to] > new_cost) { dist[next_to] = new_cost; push(pq, (Edge){new_cost, next_to}); } } } destroy(pq); return dist; } ``` Compiler compatibility was another rabbit hole — getting this to work across MSVC, GCC, Clang, MinGW64, icx-cc, and TCC required quite a bit of conditional preprocessing, especially around __VA_ARGS__ handling differences. Source is here if anyone wants to look at the macro internals: https://github.com/springkim/OpenCSTL Curious what people think about this approach. Has anyone else tried building STL-like abstractions in C? What tradeoffs did you hit? I'm especially interested in opinions on the metadata-before-pointer trick for bracket access — it works well but feels a bit cursed. <!-- SC_ON --> submitted by /u/springnode (https://www.reddit.com/user/springnode)
[link] (https://github.com/springkim/OpenCSTL) [comments] (https://www.reddit.com/r/programming/comments/1sg1apu/implementing_c_stl_containers_in_pure_c_what_i/)
I learned something about GPUs today
https://www.reddit.com/r/programming/comments/1sk9bhg/i_learned_something_about_gpus_today/
submitted by /u/rogual (https://www.reddit.com/user/rogual)
[link] (https://foon.uk/blackshift-sand-bug/) [comments] (https://www.reddit.com/r/programming/comments/1sk9bhg/i_learned_something_about_gpus_today/)
https://www.reddit.com/r/programming/comments/1sk9bhg/i_learned_something_about_gpus_today/
submitted by /u/rogual (https://www.reddit.com/user/rogual)
[link] (https://foon.uk/blackshift-sand-bug/) [comments] (https://www.reddit.com/r/programming/comments/1sk9bhg/i_learned_something_about_gpus_today/)
All elementary functions from a single binary operator
https://www.reddit.com/r/programming/comments/1skfad3/all_elementary_functions_from_a_single_binary/
submitted by /u/Dear-Economics-315 (https://www.reddit.com/user/Dear-Economics-315)
[link] (https://arxiv.org/abs/2603.21852) [comments] (https://www.reddit.com/r/programming/comments/1skfad3/all_elementary_functions_from_a_single_binary/)
https://www.reddit.com/r/programming/comments/1skfad3/all_elementary_functions_from_a_single_binary/
submitted by /u/Dear-Economics-315 (https://www.reddit.com/user/Dear-Economics-315)
[link] (https://arxiv.org/abs/2603.21852) [comments] (https://www.reddit.com/r/programming/comments/1skfad3/all_elementary_functions_from_a_single_binary/)
Everything Should Be Typed: Scalar Types Are Not Enough
https://www.reddit.com/r/programming/comments/1skg8vj/everything_should_be_typed_scalar_types_are_not/
submitted by /u/Specialist-Owl2603 (https://www.reddit.com/user/Specialist-Owl2603)
[link] (https://sot.dev/everything-should-be-typed.html) [comments] (https://www.reddit.com/r/programming/comments/1skg8vj/everything_should_be_typed_scalar_types_are_not/)
https://www.reddit.com/r/programming/comments/1skg8vj/everything_should_be_typed_scalar_types_are_not/
submitted by /u/Specialist-Owl2603 (https://www.reddit.com/user/Specialist-Owl2603)
[link] (https://sot.dev/everything-should-be-typed.html) [comments] (https://www.reddit.com/r/programming/comments/1skg8vj/everything_should_be_typed_scalar_types_are_not/)
The Origins of GPU Computing
https://www.reddit.com/r/programming/comments/1skv31d/the_origins_of_gpu_computing/
submitted by /u/Successful_Bowl2564 (https://www.reddit.com/user/Successful_Bowl2564)
[link] (https://cacm.acm.org/federal-funding-of-academic-research/the-origins-of-gpu-computing/) [comments] (https://www.reddit.com/r/programming/comments/1skv31d/the_origins_of_gpu_computing/)
https://www.reddit.com/r/programming/comments/1skv31d/the_origins_of_gpu_computing/
submitted by /u/Successful_Bowl2564 (https://www.reddit.com/user/Successful_Bowl2564)
[link] (https://cacm.acm.org/federal-funding-of-academic-research/the-origins-of-gpu-computing/) [comments] (https://www.reddit.com/r/programming/comments/1skv31d/the_origins_of_gpu_computing/)
No one can force me to have a secure website!!!
https://www.reddit.com/r/programming/comments/1sl0kfp/no_one_can_force_me_to_have_a_secure_website/
submitted by /u/MintPaw (https://www.reddit.com/user/MintPaw)
[link] (https://www.youtube.com/watch?v=M1si1y5lvkk) [comments] (https://www.reddit.com/r/programming/comments/1sl0kfp/no_one_can_force_me_to_have_a_secure_website/)
https://www.reddit.com/r/programming/comments/1sl0kfp/no_one_can_force_me_to_have_a_secure_website/
submitted by /u/MintPaw (https://www.reddit.com/user/MintPaw)
[link] (https://www.youtube.com/watch?v=M1si1y5lvkk) [comments] (https://www.reddit.com/r/programming/comments/1sl0kfp/no_one_can_force_me_to_have_a_secure_website/)
Effect Without Effect-TS: Algebraic Thinking in Plain TypeScript · cekrem.github.io
https://www.reddit.com/r/programming/comments/1sl2pwy/effect_without_effectts_algebraic_thinking_in/
submitted by /u/cekrem (https://www.reddit.com/user/cekrem)
[link] (https://cekrem.github.io/posts/effect-without-effect-ts/) [comments] (https://www.reddit.com/r/programming/comments/1sl2pwy/effect_without_effectts_algebraic_thinking_in/)
https://www.reddit.com/r/programming/comments/1sl2pwy/effect_without_effectts_algebraic_thinking_in/
submitted by /u/cekrem (https://www.reddit.com/user/cekrem)
[link] (https://cekrem.github.io/posts/effect-without-effect-ts/) [comments] (https://www.reddit.com/r/programming/comments/1sl2pwy/effect_without_effectts_algebraic_thinking_in/)
GitHub Stacked PRs
https://www.reddit.com/r/programming/comments/1sl4erj/github_stacked_prs/
submitted by /u/adam-dabrowski (https://www.reddit.com/user/adam-dabrowski)
[link] (https://github.github.com/gh-stack/) [comments] (https://www.reddit.com/r/programming/comments/1sl4erj/github_stacked_prs/)
https://www.reddit.com/r/programming/comments/1sl4erj/github_stacked_prs/
submitted by /u/adam-dabrowski (https://www.reddit.com/user/adam-dabrowski)
[link] (https://github.github.com/gh-stack/) [comments] (https://www.reddit.com/r/programming/comments/1sl4erj/github_stacked_prs/)
Finding a duplicated item in an array of N integers in the range 1 to N − 1
https://www.reddit.com/r/programming/comments/1sl5h3v/finding_a_duplicated_item_in_an_array_of_n/
submitted by /u/sweetno (https://www.reddit.com/user/sweetno)
[link] (https://devblogs.microsoft.com/oldnewthing/20260413-00/?p=112227) [comments] (https://www.reddit.com/r/programming/comments/1sl5h3v/finding_a_duplicated_item_in_an_array_of_n/)
https://www.reddit.com/r/programming/comments/1sl5h3v/finding_a_duplicated_item_in_an_array_of_n/
submitted by /u/sweetno (https://www.reddit.com/user/sweetno)
[link] (https://devblogs.microsoft.com/oldnewthing/20260413-00/?p=112227) [comments] (https://www.reddit.com/r/programming/comments/1sl5h3v/finding_a_duplicated_item_in_an_array_of_n/)
Completion is a Substrate, not a UI
https://www.reddit.com/r/programming/comments/1sl77ob/completion_is_a_substrate_not_a_ui/
submitted by /u/misterchiply (https://www.reddit.com/user/misterchiply)
[link] (https://www.chiply.dev/post-icr-primer) [comments] (https://www.reddit.com/r/programming/comments/1sl77ob/completion_is_a_substrate_not_a_ui/)
https://www.reddit.com/r/programming/comments/1sl77ob/completion_is_a_substrate_not_a_ui/
submitted by /u/misterchiply (https://www.reddit.com/user/misterchiply)
[link] (https://www.chiply.dev/post-icr-primer) [comments] (https://www.reddit.com/r/programming/comments/1sl77ob/completion_is_a_substrate_not_a_ui/)
This Talk Has It All: Array Programming, GPU Shortcuts, A Live Demo & Much More • Conor Hoekstra
https://www.reddit.com/r/programming/comments/1sl7828/this_talk_has_it_all_array_programming_gpu/
submitted by /u/goto-con (https://www.reddit.com/user/goto-con)
[link] (https://youtu.be/OJ6keePxWPg?list=PLEx5khR4g7PLjpaSO0XI-6euF483ORLyJ) [comments] (https://www.reddit.com/r/programming/comments/1sl7828/this_talk_has_it_all_array_programming_gpu/)
https://www.reddit.com/r/programming/comments/1sl7828/this_talk_has_it_all_array_programming_gpu/
submitted by /u/goto-con (https://www.reddit.com/user/goto-con)
[link] (https://youtu.be/OJ6keePxWPg?list=PLEx5khR4g7PLjpaSO0XI-6euF483ORLyJ) [comments] (https://www.reddit.com/r/programming/comments/1sl7828/this_talk_has_it_all_array_programming_gpu/)
Serialization Filtering
https://www.reddit.com/r/programming/comments/1sl9d1m/serialization_filtering/
submitted by /u/SlightOpinion2873 (https://www.reddit.com/user/SlightOpinion2873)
[link] (https://docs.oracle.com/en/java/javase/17/core/serialization-filtering1.html#GUID-55BABE96-3048-4A9F-A7E6-781790FF3480) [comments] (https://www.reddit.com/r/programming/comments/1sl9d1m/serialization_filtering/)
https://www.reddit.com/r/programming/comments/1sl9d1m/serialization_filtering/
submitted by /u/SlightOpinion2873 (https://www.reddit.com/user/SlightOpinion2873)
[link] (https://docs.oracle.com/en/java/javase/17/core/serialization-filtering1.html#GUID-55BABE96-3048-4A9F-A7E6-781790FF3480) [comments] (https://www.reddit.com/r/programming/comments/1sl9d1m/serialization_filtering/)
Interview with the author of Just
https://www.reddit.com/r/programming/comments/1sla7ww/interview_with_the_author_of_just/
submitted by /u/bee-gee-dee (https://www.reddit.com/user/bee-gee-dee)
[link] (https://youtube.com/shorts/24A87E-a6_4?feature=share) [comments] (https://www.reddit.com/r/programming/comments/1sla7ww/interview_with_the_author_of_just/)
https://www.reddit.com/r/programming/comments/1sla7ww/interview_with_the_author_of_just/
submitted by /u/bee-gee-dee (https://www.reddit.com/user/bee-gee-dee)
[link] (https://youtube.com/shorts/24A87E-a6_4?feature=share) [comments] (https://www.reddit.com/r/programming/comments/1sla7ww/interview_with_the_author_of_just/)
The real work of maintenance happens before you touch the code
https://www.reddit.com/r/programming/comments/1slab5m/the_real_work_of_maintenance_happens_before_you/
<!-- SC_OFF -->Most teams treat maintenance as a code problem. But in this episode of the Maintainable podcast, Rein Henrichs argues the real work happens before you touch anything. Engineers never interact with their systems directly. They work through representations like logs, dashboards, and code, and when those drift from reality, shared understanding quietly erodes. Have you felt this on your team? Curious what others have run into. <!-- SC_ON --> submitted by /u/robbyrussell (https://www.reddit.com/user/robbyrussell)
[link] (https://maintainable.fm/episodes/rein-henrichs-the-real-work-of-maintenance-happens-before-you-touch-the-code) [comments] (https://www.reddit.com/r/programming/comments/1slab5m/the_real_work_of_maintenance_happens_before_you/)
https://www.reddit.com/r/programming/comments/1slab5m/the_real_work_of_maintenance_happens_before_you/
<!-- SC_OFF -->Most teams treat maintenance as a code problem. But in this episode of the Maintainable podcast, Rein Henrichs argues the real work happens before you touch anything. Engineers never interact with their systems directly. They work through representations like logs, dashboards, and code, and when those drift from reality, shared understanding quietly erodes. Have you felt this on your team? Curious what others have run into. <!-- SC_ON --> submitted by /u/robbyrussell (https://www.reddit.com/user/robbyrussell)
[link] (https://maintainable.fm/episodes/rein-henrichs-the-real-work-of-maintenance-happens-before-you-touch-the-code) [comments] (https://www.reddit.com/r/programming/comments/1slab5m/the_real_work_of_maintenance_happens_before_you/)
SDL3 port to DOS
https://www.reddit.com/r/programming/comments/1slas1j/sdl3_port_to_dos/
submitted by /u/r_retrohacking_mod2 (https://www.reddit.com/user/r_retrohacking_mod2)
[link] (https://bsky.app/profile/dosnostalgic.bsky.social/post/3mjfdos7iok2o) [comments] (https://www.reddit.com/r/programming/comments/1slas1j/sdl3_port_to_dos/)
https://www.reddit.com/r/programming/comments/1slas1j/sdl3_port_to_dos/
submitted by /u/r_retrohacking_mod2 (https://www.reddit.com/user/r_retrohacking_mod2)
[link] (https://bsky.app/profile/dosnostalgic.bsky.social/post/3mjfdos7iok2o) [comments] (https://www.reddit.com/r/programming/comments/1slas1j/sdl3_port_to_dos/)
Understanding gRPC architecture in simple terms
https://www.reddit.com/r/programming/comments/1slxyum/understanding_grpc_architecture_in_simple_terms/
submitted by /u/Sushant098123 (https://www.reddit.com/user/Sushant098123)
[link] (https://sushantdhiman.dev/understanding-grpc-architecture-in-simple-terms/) [comments] (https://www.reddit.com/r/programming/comments/1slxyum/understanding_grpc_architecture_in_simple_terms/)
https://www.reddit.com/r/programming/comments/1slxyum/understanding_grpc_architecture_in_simple_terms/
submitted by /u/Sushant098123 (https://www.reddit.com/user/Sushant098123)
[link] (https://sushantdhiman.dev/understanding-grpc-architecture-in-simple-terms/) [comments] (https://www.reddit.com/r/programming/comments/1slxyum/understanding_grpc_architecture_in_simple_terms/)
Direct Win32 API, Weird-Shaped Windows, and Why They Mostly Disappeared
https://www.reddit.com/r/programming/comments/1sm01ev/direct_win32_api_weirdshaped_windows_and_why_they/
submitted by /u/nccwarp9 (https://www.reddit.com/user/nccwarp9)
[link] (https://warped3.substack.com/p/direct-win32-api-weird-shaped-windows) [comments] (https://www.reddit.com/r/programming/comments/1sm01ev/direct_win32_api_weirdshaped_windows_and_why_they/)
https://www.reddit.com/r/programming/comments/1sm01ev/direct_win32_api_weirdshaped_windows_and_why_they/
submitted by /u/nccwarp9 (https://www.reddit.com/user/nccwarp9)
[link] (https://warped3.substack.com/p/direct-win32-api-weird-shaped-windows) [comments] (https://www.reddit.com/r/programming/comments/1sm01ev/direct_win32_api_weirdshaped_windows_and_why_they/)
Things you didn't know about (Postgres) indexes
https://www.reddit.com/r/programming/comments/1sm5d83/things_you_didnt_know_about_postgres_indexes/
submitted by /u/NotTreeFiddy (https://www.reddit.com/user/NotTreeFiddy)
[link] (https://jon.chrt.dev/2026/04/15/things-you-didnt-know-about-indexes.html) [comments] (https://www.reddit.com/r/programming/comments/1sm5d83/things_you_didnt_know_about_postgres_indexes/)
https://www.reddit.com/r/programming/comments/1sm5d83/things_you_didnt_know_about_postgres_indexes/
submitted by /u/NotTreeFiddy (https://www.reddit.com/user/NotTreeFiddy)
[link] (https://jon.chrt.dev/2026/04/15/things-you-didnt-know-about-indexes.html) [comments] (https://www.reddit.com/r/programming/comments/1sm5d83/things_you_didnt_know_about_postgres_indexes/)