In terms of Kotlin, what is the difference between a package and a module?
When it comes to visibility modifiers for top-level code, the internal
modifier only allows accessibility for code inside the same module. This makes it seem like package and module are the same thing but I'm not certain.
The question here does not answer my question as it does not bring modules and packages into the same context.
Short answer: packages collect related classes, and correspond roughly to directories; while modules are a much higher level and correspond to projects and/or compiler runs.
Longer answer:
In Java and Kotlin, classes are arranged into packages. They're set using the package
directive at the top of each file. (In Java, this corresponds exactly to the directory structure in which they're stored; that's common in Kotlin too, though not strictly required.)
They provide a way of grouping related classes: you can refer to classes (and top-level functions and fields) in the same package directly, while all other classes need to be import
ed, or their fully-qualified names (package.package…class) used. And in the most recent versions of Java, you can ‘seal’ a package, which means no-one else can add classes to it later on.
Modules, on the other hand, are new to Kotlin. They are a much higher-level concept, collecting together all the classes in a program or library. (Some IDEs and tools call this a ‘project’ or ‘source set’.) All the files in a module must be compiled together, and the results are usually collected into a .jar (or .war) file.
A big system might consist of a handful of modules, but each of those could contain many tens of packages.