News for hackers. Stuff that matters.
Re:Minimalist C Libraries by vortico on Sunday June 10, 2018 @03:40AM (#17277057)
Most things here are reasonable, but I don't see a point about having only one struct. If your state is better organized in lots of hierarchical structs, within lists, within other structs, your data will be easier to move around, copy, and zero in smaller chunks, and you can write functions which processes isolated segments of data rather than a huge global state.
Re:Minimalist C Libraries by enriquto on Sunday June 10, 2018 @01:49PM (#17279229)
This is very sound advice.

The interface of the library is intended to help the user of the library, not the developer of the library.

The simplest interface is the best for the user, who does not want to know anything about the implementation details.

In the ideal case, the developer and the api designer will be different persons who are not in good terms to each other. The more the developer hates the api designer, the better.

Re:Minimalist C Libraries by matthiasv on Sunday June 10, 2018 @04:42AM (#17277192)
The point was about the user-facing side not the internal representation of state.
Re:Minimalist C Libraries by vortico on Sunday June 10, 2018 @12:45PM (#17278904)
Even then, it seems weird to prefer a big flat state rather than a state made of heirarchical sub-structures and arrays.
Re:Minimalist C Libraries by yason on Sunday June 10, 2018 @01:27PM (#17279109)
As the user of the library I probably don't care about the hierarchies. If I want X the library can provide me a function to get X by looking up its internal substructures and arrays so that I don't have to.