Some C habits I employ for the modern day
2 months ago
- #type-systems
- #C-programming
- #coding-practices
- The author uses C23 for new projects, preferring it for its features, but adapts to other standards for compatibility.
- They define custom type aliases (e.g., u8, i32) inspired by Rust for clarity and brevity in their code.
- Advocates for 'parse, don't validate' approach in C, leveraging structs and opaque types for safer APIs.
- Introduces tuples in C23 for returning multiple values from functions, though with some limitations.
- Uses sum types (via structs and unions) to handle errors and results, making error handling more robust.
- Prefers avoiding dynamic memory management in C, suggesting other languages like Rust or C# for such needs.
- Avoids string.h functions, reimplementing needed functionalities for better control and safety.
- Encourages thinking about personal coding style in C, balancing its limitations with creative solutions.