5 Tony’s famous FFI cookbook
This chapter covers
- The goals of library design
- Understanding Zig’s relationship to the C ABI
- Writing friendly code for crossing language boundaries
- Thinking about lifetimes with arena and buffer allocators
- Data-oriented ideas for keeping state management simple
As programmers, we spend a lot of time compromising. We compromise due to time, choosing to deliver a result we’re less proud of simply because we won’t have time to do it right. We compromise for our teams, accepting design decisions we protested for good reasons. We compromise on technical debt when we’re pushed to produce new features despite a mountain of backlog.
Your boss, Tony, calls you into a private meeting out of the blue on a Friday afternoon. It’s your colleague David’s birthday on Monday. David is well-liked among the team for his generous gifts of homemade pastry. Tony thinks he’s struck gold with his gift idea for David, a custom recipe book app. The problem? Tony is a top-tier UI designer with absolutely zero grasp of anything related to the backend or operating system. If you can build the state management for the recipe book as well as a way to save and load recipes, he’ll build the rest and you’ll earn a massive IOU. Tony is a goofy boss but keeps his word, and you begrudgingly agree to the deal.
Seems like compromise is the name of the game here. The less work you can do to make Tony happy, the more weekend you will keep to yourself.