Packages and Modules

Read Packages and Modules as a Java habit shift, with links to the Musi Book definition.

A Java reader brings habits from packages, classes, records, interfaces, exceptions, annotations, streams, and long-lived APIs. That helps with contracts, visibility, and maintainable names, but the Musi page asks a narrower question: what contract should this module and package boundaries example make visible?

java
import store.Option;

var defaultGate = Option.some(1);

Reading Packages and Modules from Java

On the Musi side, Musi imports bring named module values into scope, so package boundaries stay visible where code uses them. Read the shared example through Java eyes: keep the useful instinct, then let Musi name shape, behavior, absence, and outside work in separate places.

False friend

Do not rebuild a source-language global namespace, header include pile, or barrel file when one import names the owner. For a Java reader, the trap is reading Musi class as a nominal object type with constructors and fields; Musi class is a behavior contract supplied by instances; records and data model object shape.

When this pays off

Use modules when billing, routing, text, option, runtime, or encoding code has an owner worth naming. The Java instinct still helps here: Keep the Java habit of naming APIs for future readers.

Keep close