Guidelines for Writing Fully Encapsulated C Programs: Pure vs Performance Approaches
By
p2detar
Sesame, salt, and substance. A flagship bake.
Summary
This article presents a comprehensive set of rules and guidelines for writing fully encapsulated C programs, developed by the author over years of experience. It covers two main approaches: pure encapsulation (focusing on complete data hiding and abstraction) and performance encapsulation (balancing encapsulation with optimization needs). The article provides detailed programming rules, best practices, and philosophical insights about C programming, emphasizing the language's closeness to assembly and the freedom it offers developers.
Key quotes
· 5 pulledC is my favorite language and I love the freedom and exploration it allows me. I also love that it is so close to Assembly and I love writing assembly for much of the same reasons!
I offer both a 'performance' and a 'pure encapsulation' approach to C here (first two headers). So feel free to interpret the rest of the rules based on the approach.
One of the great things about C is that it allows you to write code that is both high-level and low-level at the same time.
Perfect encapsulation means that the internal representation of data is completely hidden from the outside world.
The performance approach sacrifices some encapsulation purity for better runtime efficiency when needed.
You might also wanna read
Cscript Style Guide: A Python-Inspired Approach to C Programming
Cscript is presented as a style guide for writing C code that aims to make C development faster and more Python-like while maintaining C's p
Pigeon's Device: An Independent Loop Optimization Technique in C Programming
The article introduces Pigeon's device, a loop optimization technique in C programming that was independently developed from Duff's device.
Implementing Closures in C Using JIT-Compiled Wrappers for Win32 Window Procedures
The article discusses an advanced programming technique for creating closures in C using JIT-compiled wrappers, specifically applied to Win3
Checked-size Array Parameters in C: Addressing Safety Issues with Array Size Validation
The article discusses a recent attempt to add safety checks for array parameters in the C programming language, specifically within the cryp
Creating a Leak-Free, Thread-Safe Grep Utility in C23 with Safe Programming Practices
The article details the author's experience creating a leak-free, thread-safe grep utility in C23 using a custom header file called safe_c.h
Implementing Generic Programming in C: Techniques and Trade-offs
The article explains how to implement generic programming in C despite the language not having built-in generics support. It covers various
