Spaced repetition learning
CommonJS modules are primarily used in Node.js for server-side JavaScript development.
In CommonJS, you export modules using `module.exports` or `exports`, e.g., `module.exports = { functionName: function() { … } }`.
ES6 modules use `import` and `export` statements, while CommonJS uses `require()` and `module.exports`.
You can use named imports in ES6, e.g., `import { specificFunction } from './module.js'`.
The `_init_.py` file marks a directory as a Python package and can be used to execute package initialization code.
You can use the `from` keyword, e.g., `from modulename import specificfunction`.
The module system was introduced in Java 9.
The `module-info.java` file defines a module's dependencies, exported packages, and services.
C++20 introduced modules to the C++ language.
C++ modules offer faster compilation times, better encapsulation, and reduced header dependencies.
Ruby modules are used for namespacing and mixins, allowing code to be shared across multiple classes.
You use the `include` keyword followed by the module name, e.g., `include ModuleName`.
The command `go mod init` initializes a new module in Go.
The `go.mod` file is created to manage dependencies in Go modules.
You declare a module in Rust using the `mod` keyword, e.g., `mod modulename;`.
The `use` keyword in Rust is used to bring items from modules into scope, similar to `import` in other languages.
The default access level for entities in Swift modules is `internal`.
You add the `public` keyword before the class or function declaration, e.g., `public class ClassName { … }`.
Autoloading in PHP automatically includes class files when they are used, eliminating the need for multiple `include` or `require` statements.
PSR-4 defines the autoloading specifications in PHP.
TypeScript modules are very similar to ES6 modules but add support for type information and additional features like `namespace`.
The `export` keyword in TypeScript is used to make a declaration available for use in other modules.
You import a Haskell module using the `import` keyword, e.g., `import ModuleName`.
The `qualified` keyword is used to import a module with a namespace, preventing name clashes, e.g., `import qualified Data.Map as Map`.
In Scala, packages serve a similar purpose to Java packages, organizing code into namespaces.
You create a singleton object in Scala using the `object` keyword instead of `class`, e.g., `object SingletonName { … }`.