Hacker News new | past | comments | ask | show | jobs | submit login

Aside from grouping functions together that work together, for example working with data types/structures also defined in or by the module, modules also serve the purpose to hide implementation-detail code (“private” functions) shared between those functions. Modules provide a form of information hiding.

Furthermore, modules are the unit of versioning. While one could version each individual function separately, that would make managing the dependency graph with version compatibility considerably more complex.

There is the adage “version together what changes together”. That carries over to modules: “group together in a module what changes together”. And typically things change together that are designed together.

Namespaces are an orthogonal issue. You can have modules without namespaces, and namespaces without modules.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: