r/cprogramming

I built a DSA library in C and it got selected for an open-source program, looking for contributors
▲ 3 r/cprogramming+2 crossposts

I built a DSA library in C and it got selected for an open-source program, looking for contributors

I built C_DSA_interactive_suite, a fully modular, console-based DSA library written entirely in pure C11. No frameworks, no abstractions. Just raw C, manual memory management and real implementations built from scratch. The codebase has a clean modular architecture with one .h/.c pair per module, reusable APIs across modules. A single interactive executable as the entry point, Valgrind-clean memory, CI/CD on every push, and .clang-format enforced style throughout. The project just got selected in SSOC, an open-source program similar to GSoC and I am the project admin, which means this summer, project is open for contributiors! If you've been wanting to:

  • Start your Open Source journey
  • Contribute to a real C codebase with proper architecture and planning
  • Implement something like AVL trees, heaps, priority queues, tries, Dijkstra, or DP
  • Get your hands dirty with actual C, not school level C
  • Have your contribution acknowledged by a reputable community

This is your shot. Everybody else is doing MERN. Come touch some real memory. I'm available to walk anyone through the codebase, clear doubts, explain concepts, or help you get your first PR merged. No gatekeeping. Register as contributor for SSOC. Only 5 days left - https://www.socialsummerofcode.com/ GitHub: https://github.com/darshan2456/C_DSA_interactive_suite Drop a comment or open an issue if you're interested. Let's build something worth putting on a resume.

hows this?

u/Straight_Coffee2028 — 1 day ago

My first program was a text editor

As the title says, My first program is a text editor. Well other that hello world.

------------BACK GROUND----------------

Im 19 now but a year ago I got really into old computers and laptops. And I like really love them they are all really cool. but i realized I don't really use them and they just sit there. So I decided to get myself used to MSDOS and everthing to know about using them for daily things.

oneday I was thinking about how id like to learn how to program. I tried before by making gamed with c# and unity when I was 10 but I didnt really get into it.

I decided I really wanted to learn but I was afraid that i would give up again so I tried to think about the best way to learn. Who could I learn from that was also really great at programming you know? I realized that it were the programmers from the 80's and 90's. They could do amazing things by just learning from books and had the discipline to write efficient code while being limited with memory.

I realized I could follow in their foot steps with the same computers that they would have used. which mine is running MS-DOS 5.0 and an 80386 CPU.

So I went on a hunt to find the physical copies of compilers of languages I want to learn from. I found Borland Turbo C/C++, MASM, Microsoft Fortran and cobol. As well as a couple books for C.

These last two months of March and april Ive read seven books on C. My favorite was "Pointers on C" by Kenneth A. Reek. after learning the basics from the first book I read I wrote hello world as Is mandatory. But before I started learning C I had a goal which was to write a text editor so I kept reading until I felt like I could start.

------------The Grit Text Editor-----------------

I have named It Grit.

currently It is at a bare Minimum. The arrow keys are used to traverse the file and is saved/closed with ESC.

one Issue that desperatly needs attention is how the text is displayed. Because It is meant for to be ran from the command line it was not made using and specialized graphics functions and the text is just written character by character.

One

This Issue is the fault of my current gap in C knowledge. The functions I used from conio.h that control where the cursor is, and clearing the screen are work but cause on screen blips. this is because these functions are wraps for system interupts that do things like moving the cursor and such. this works HOWEVER back then programmers would display things on screen by directly accessing the graphics in memory with pointers.

--------------HOW I PLAN TO FIX/IMPROVE-------------

This is what I plan on learning next. first Im going to reread a lot of my books and then Im going to learn Graphics and at the same time Assembler with MASM.

-------------------GIT HUB--------------------------------

https://github.com/thatoneproton/Grit.git

if you guys could, read over and give feedback

reddit.com
u/strilkrill — 3 days ago
▲ 134 r/cprogramming+3 crossposts

AI sucks at low level programming.

I'm gonna take a hot take, I think that AI is absolutely terrible at coding in low level (C/C++/ASM) the code it generates is absolute SLOP, and functions terribly. (AI SLOP)

reddit.com
u/Clear_Safe_5408 — 4 days ago
▲ 141 r/cprogramming+1 crossposts

I love C but I dont like libc that much

I love C, but I don't like its standard library having tons of hidden states (like errno) and error values baked into their returns. A lot of times I have to stop and check the function's documentation just to know which value is actually the error value. It makes me tired.

So, I have spent some of my time making a custom C runtime and libc from scratch in C89. I know it might be bad or wrong in some places, but at least I understand how it all works under the hood now.

Thing i have done so far are: Explicit Allocator - No Hidden State - Builtin Some Basic types

There are still a lot of things that need to be implemented, and currently, it only supports x86_64 Linux.

I would love to hear feedback!

Repo: https://codeberg.org/fanes/flibc

Edit: Added a GitHub mirror for convenience (and in case Codeberg is having downtime!):
https://github.com/byfanes/flibc

u/ByMeno — 4 days ago

Getting Formatting Errors Loading .C Files in Turbo C for DOS

I am having a problem with loading .c files in ye olde Borland Turbo C for DOS 2.01. .C files will display properly if I load them in any other editor on earth, under any other operating system, but Turbo C seems to ignore line feeds(?) when loading that same file into it's IDE editor. It will throw out an error about the line being too long, etc.

Sincerely,

Getting a Bit Annoyed in Bermuda

reddit.com
u/DogWallop — 4 days ago
▲ 8 r/cprogramming+1 crossposts

I built a Redis-compatible in-memory database in C that shows competitive performance against Dragonfly

Hi everyone,

I’ve been working on Freakv, a Redis-compatible in-memory key-value store written in C.

The project originally started as a university learning project because I wanted to deeply understand how high-performance systems are built internally: sharding, memory layout, lock avoidance, networking, persistence, and cross-thread coordination.

At the same time, I also wanted to build something serious enough to put on my CV while preparing for backend/systems engineering roles.

FreakV is built around:

  • shared-nothing sharding architecture
  • custom slab-style memory allocation
  • asynchronous shard communication using SPSC queues
  • zero-lock hot paths for normal single-shard operations
  • zero-copy reply path
  • TTL expiration + LRU eviction
  • snapshot persistence without relying on fork()
  • async two-phase MSET transaction protocol with cross-shard coordination

The server speaks Redis RESP2, so standard Redis clients work directly (redis-cli, redis-py, ioredis, Jedis, etc.).

I benchmarked Freakv against Dragonfly v1.25.2 on identical AWS hardware (c6in.16xlarge, 32 worker threads).

Some results:

SET — pipeline 10

memtier_benchmark -s $SERVER --ratio 1:0 -t 60 -c 20 -n 2000000 \

--distinct-client-seed --hide-histogram --pipeline=10 \

--print-percentiles=50,99,99.9,100

  • Freakv: 13.6M ops/sec
  • Dragonfly: 10.1M ops/sec

GET — pipeline 10

  • Freakv: 12.3M ops/sec
  • Dragonfly: 9.7M ops/sec

Additional SET stress run

memtier_benchmark -s $SERVER --ratio 1:0 -t 32 -c 60 -n 200000 \

--distinct-client-seed --hide-histogram \

--print-percentiles=50,99,99.9,100

  • Freakv: 6.08M ops/sec @ 0.390 ms avg latency
  • Dragonfly: 5.33M ops/sec @ 0.428 ms avg latency

Pipeline 10:

  • Freakv: 13.7M ops/sec @ 1.637 ms avg latency
  • Dragonfly: 9.4M ops/sec @ 2.261 ms avg latency

Even with snapshots enabled every 10 seconds, FreakV still sustained: 10.7M SET ops/sec

To be clear: Dragonfly is a far more mature production system with replication, richer data structures, cluster support, and many years of engineering behind it. Freakv currently only supports a Redis-compatible string subset.

So this isn’t meant as “Freakv beats Dragonfly overall”. The comparison is intentionally narrow: raw GET/SET throughput and latency on string workloads.

Still, as a learning-focused project written from scratch in C, I’m honestly pretty happy with how far it got.

As for AI usage: I used AI extensively during development, mainly as a learning/reference and acceleration tool.

I used it to speed up implementation of more straightforward components, for example RESP handling/parsing, boilerplate generation, code tracing, and iteration during debugging sessions.

The important part is that the architecture, systems design, profiling workflow, benchmarking methodology, bottleneck isolation, and debugging direction came from me, and a lot of the sensitive parts still required manual coding and iteration from my side.

Would love feedback from people working in databases, distributed systems, or low-level performance engineering.

Here is the repo: hphucp/freakv

u/ExchangeFew9733 — 4 days ago

Review of My C Library

Hi fellow C programmers,

I’ve been building my own C library as a way to go deeper into systems programming, API design, memory ownership, and testing.

The library has grown quite a bit, and currently includes:

* Dynamic string (`d_dyn_string`)
* String views (`d_string_view`)
* Dynamic arrays (`d_dyn_array`)
* Stack (`d_stack`)
* Queue (`d_queue`)
* Deque (`d_de_queue`)
* Unordered map (`d_unordered_map`)
* Hash set (`d_hash_set`)

I’d really love feedback from experienced C programmers:

* API design: anything that feels awkward or unsafe?
* File/project structure: does it scale well?
* Ownership semantics: anything unclear or non-idiomatic?
* What mature C libraries would you recommend studying?

Repository:

c_library

Any brutally honest feedback is welcome :)

u/Dieriba — 5 days ago
▲ 58 r/cprogramming+3 crossposts

Cross-compiling MINIX 1.1 on a modern host (pre-ANSI, K&R C)

I've recently purchased a physical copy of Tanenbaum's original "Operating Systems: Design and Implementation" (first edition), downloaded the companion MINIX 1.1 source code and spent a few weeks setting up a cross-platform toolchain so that I can build the pre-ANSI C codebase, targeting the 8086/8088, from my modern machine. The toolchain is based on Bruce's C Compiler (bcc) and the dev86 project, which is vendored into the project to keep things stable.

So far I've learned a ton and had to deal with a few interesting problems trying to get such an old C codebase compiling:

  • Porting the original PC/IX assembly code to dev86's as86.
  • Adding some numeric compiler routines from bcc libc to the MINIX libc library.
  • Tweaking the MINIX C runtime (crtso) to work with bcc and the MINIX exec syscall.
  • Fixed a couple of bcc compiler bugs to allow passing structs by value: a bug in the optimiser was trashing the stack and a bug in the codegen logic was clobbering a register. I've since learned that passing structs by value wasn't supported in the original K&R book or Ritchie's original reference manual, but the code for the MINIX shell requires it and it was a common compiler extension.

Further details in the project changelog.

Anyway, thought I'd share this here because it's been a lot of fun bringing this historical codebase and OS back to life and I want others to know that there's still a lot of fun/learning to be had exploring the original MINIX OS.

codeberg.org
u/Kq9gE8MNWZ7m — 6 days ago

TIL that the standard library provides support for complex numbers

Accessible via the `complex.h` header

What other useless things have you encountered in C?

reddit.com
u/Qiwas — 5 days ago

Help with learning?

i want to learn C in a interesting way other than reading doc. As I'm more of a visual learner then reading text.

I have watched yt videos but most good onces are old.
Any suggestions on how?
websites / Games or anything?

reddit.com
u/Peace-HoHo — 7 days ago
▲ 61 r/cprogramming+2 crossposts

Made a small 2D graphics library for C

been learning C for a bit and wanted to make something visual. but SDL2 felt too involved for doing sth simple....so i made my own library..its called Cinder. sits on top of SDL2, collapses all the setup into basically nothing:

CinderInit(CINDER_SUBSYSTEM_ALL);
CinderCreateWindow(CinderDefaultWindowDesc());

while (CinderIsRunning()) {
    CinderBeginFrame();
    CinderClearBackground(CINDER_BLACK);
    CinderEndFrame();
}

covers drawing, input, audio, fonts, textures, timers, rng.. the usual stuff. there are examples in the repo (pong, snake, pendulum) if you want to see how it actually feels to use.

feedback welcome

github.com
u/Afraid_Lie_9340 — 8 days ago
▲ 7 r/cprogramming+1 crossposts

Agentic Prover for Rocq

AutoRocq: an open-source LLM agent built for verifying C code in Rocq/Coq. Linked with CoqPyt to autonomously search for existing lemmas and get real-time feedback.

github.com
u/Riiiiime — 6 days ago
▲ 0 r/cprogramming+2 crossposts

who else uses AI to write CMakeLists.txt

im a lazy programmer, I absolutely hate cmake files, they take away from the C experience. Just wondering who else uses AI to write cmake files. (I love cmake, its real easy to use. Just not the cmakelists.txt files)

reddit.com
u/Clear_Safe_5408 — 10 days ago
▲ 11 r/cprogramming+1 crossposts

Working on a new Nostr relay implementation in C

Hello everyone

I’ve been working on a new Nostr relay called Nostrum — focused on being simple, lightweight and fast.

Some features/goals:

Simple and clean architecture

Good performance and low memory usage

Easy self-hosting

Open source (BSD 3-Clause)

Project link: https://github.com/henriquetft/nostrum

I’m actively developing it and would really appreciate feedback, bug reports, ideas, or contributors interested in relay development.

If you test it, let me know what you think!

u/henrique_tft — 9 days ago

FREE MISRA C TOOL

Hey,
I wrote a code base in C and want to check its MISRA C complaince. Searched and found cppcheck which supports MISRA 2012 could not get hand on any latest tools. Is there any tool that support the latest MISRA edition compliance check and is free ?

reddit.com
u/Sad_Passenger_9918 — 10 days ago

Diagrams for C

Hi, I had to do a project where I used an FPGA and i wrote half in C and half in Verilog, now I need to present my project in a few weeks but I don't know exactly what type of diagram I should use for my C part. I thought about using a block diagram similar to the one used for Verilog designs, but that feels a bit too simple but using UML diagrams also feels somewhat unnatural? maybe because I do not know how can i replicate it from OOP to C. Is there a specific type of diagram that is commonly used for C projects to represent functionalities and communication between modules? My project has around 9 files in C, each responsible for a specific task, and some of them communicate with each other.

reddit.com
u/paxl_lxap — 13 days ago