Codele / Advanced programming
Modules, packages and dependencies
Big programs are split into files with names, and each file imports only what it needs. You can also use code that other people published, with a version number.
- A module is one file with a name. import opens it so the file can use what is inside. Writing the module name first, as in prices.total, keeps two functions with the same name apart.
- A package is code other people wrote and published. A dependency is a package your program needs. The version number, such as 4.9.0, says exactly which release you rely on.
- A package manager fetches dependencies for you from an online registry: pip for Python, npm for JavaScript, Maven for Java, NuGet for C# and go modules for Go. C++ has no single standard one: people use tools such as vcpkg or Conan.
- Each language writes imports in its own way: Python import, JavaScript import ... from, Java import, C# using, Go import, and C++ #include. The list of dependencies lives in a file: requirements.txt, package.json, pom.xml, a .csproj file or go.mod.
Loading the playable lesson…