What are components?
Components are the main building blocks of Magento 2. Whether the core codebase, third party extensions or your own custom development, components provide almost all the code you'll interact with when working with Magento 2.
- Language Pack
Modules are the predominant component type in Magento 2 and where most developers, especially those focused on backend development, will write the majority of their code. Their purpose is to provide functionality, whether by adding new features or modifying existing ones. All the key features you associate with an eCommerce platform are provided by a module in Magento, e.g. products, categories, the cart and checkout.
As well as implementing the business logic of the features they provide, modules can also include the view (presentation) layer, such as base layout, markup, scripts and styles.
Language packs facilitate one of the key selling points of Magento 2: internationalisation. They can override all the phrases (text) output across storefronts and the admin panel (via modules and themes), making translation and localisation simple to achieve, while not impacting the existing functionality.
Libraries provide abstract and re-usable code that other components (in most cases modules) can implement and extend. The main library component that ships with Magento 2 is known as 'Magento Framework'. Magento Framework contains all the low-level classes and interfaces that all modules utilise and build on top of, including managing HTTP requests, interacting with the database and filesystem, the caching mechanism and the layout and templating system that renders output on the frontend.
While you can also create your own custom library components, there is little difference from creating a standalone PHP library, other than it being Magento 2 specific.
The setup component type is relatively new, only being introduced formally in Magento 2.3.0. Setup components are concerned with the preparation of the Magento application itself, both from an install and upgrade perspective. It isn't something you'll often encounter, nor will need to create, and there is only one component of this type in the core codebase.