Cross Platform Component Object Model (XPCOM) is a
cross-platform
Within computing, cross-platform software (also called multi-platform software, platform-agnostic software, or platform-independent software) is computer software that is designed to work in several Computing platform, computing platforms. Some ...
component model from
Mozilla
Mozilla is a free software community founded in 1998 by members of Netscape. The Mozilla community uses, develops, publishes and supports Mozilla products, thereby promoting free software and open standards. The community is supported institution ...
. It is similar to
Component Object Model
Component Object Model (COM) is a binary-interface technology for software components from Microsoft that enables using objects in a language-neutral way between different programming languages, programming contexts, processes and machines ...
(COM),
Common Object Request Broker Architecture (CORBA) and
system object model (SOM). It features multiple
language binding
In programming and software design, a binding is an application programming interface (API) that provides glue code specifically made to allow a programming language to use a foreign library or operating system service (one that is not native to ...
s and
interface description language (IDL) descriptions, which allow programmers to plug their custom functions into the framework and connect them with other components.
The most notable use of XPCOM is within the
Firefox
Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements curr ...
web browser, where many internal components interact through XPCOM interfaces. Furthermore, Firefox used to allow
add-ons extensive XPCOM access, but this was removed in 2017 and replaced with the less-permissive
WebExtensions API. Two
forks
In cutlery or kitchenware, a fork (from 'pitchfork') is a Eating utensil, utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tine (structural), tines with whic ...
of Firefox still support XPCOM add-on capability:
Pale Moon and
Basilisk
In European bestiary, bestiaries and legends, a basilisk ( or ) is a legendary reptile reputed to be a Serpent symbolism, serpent king, who causes death to those who look into its eyes. According to the ''Natural History (Pliny), Naturalis Histo ...
.
Model
XPCOM is one of the main things making the
Mozilla
Mozilla is a free software community founded in 1998 by members of Netscape. The Mozilla community uses, develops, publishes and supports Mozilla products, thereby promoting free software and open standards. The community is supported institution ...
application environment an actual framework. It is a development environment that provides the following features for the cross-platform software developer:
* Component management
* File abstraction
*
Object message passing
*
Memory management
Memory management (also dynamic memory management, dynamic storage allocation, or dynamic memory allocation) is a form of Resource management (computing), resource management applied to computer memory. The essential requirement of memory manag ...
This component object model makes virtually all of the functionality of
Gecko
Geckos are small, mostly carnivorous lizards that have a wide distribution, found on every continent except Antarctica. Belonging to the infraorder Gekkota, geckos are found in warm climates. They range from .
Geckos are unique among lizards ...
available as a series of components, or reusable cross-platform
libraries
A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
, that can be accessed from the
web browser
A web browser, often shortened to browser, is an application for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's scr ...
or scripted from any Mozilla application. Applications that must access the various Mozilla XPCOM libraries (
networking,
security,
DOM, etc.) use a special layer of XPCOM called
XPConnect, which
reflects the library interfaces into
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
, or other languages. XPConnect glues the front end to the
C++,
C, or
Rust
Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH) ...
programming language based components in XPCOM, and it can be extended to include scripting support for other languages: PyXPCOM already offers support for
Python. wxWidgets provide support for
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language".
Perl was developed ...
, and there are efforts underway to add
Common Language Infrastructure
The Common Language Infrastructure (CLI) is an open specification and technical standard originally developed by Microsoft and standardized by International Organization for Standardization, ISO/International Electrotechnical Commission, IEC (ISO/ ...
(CLI) and
Ruby
Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...
language support for XPConnect.
For developers, XPCOM allows writing components in
C++,
C,
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
,
Python, or other languages for which special bindings have been created, and compile and run those components on dozens of different platforms, including these and others where Mozilla is supported.
The flexibility to reuse the XPCOM components from the Gecko library and develop new components that run on different platforms facilitates
rapid application development
Rapid application development (RAD), also called rapid application building (RAB), is both a general term for adaptive software development approaches, and the name for James Martin's method of rapid development. In general, RAD approaches to ...
and results in an application that is more productive and easier to maintain. The networking library, for example, is a set of XPCOM components that can be accessed and used by any Mozilla application. File I/O, security, password management, and profiles are also separate XPCOM components that programmers can use in their own application development.
Past overuse
XPCOM adds a lot of code for
marshalling objects, and in the
Netscape era XPCOM was overused for internal interfaces where it wasn't truly necessary, resulting in
software bloat. This was a key reason why in 2001
Apple
An apple is a round, edible fruit produced by an apple tree (''Malus'' spp.). Fruit trees of the orchard or domestic apple (''Malus domestica''), the most widely grown in the genus, are agriculture, cultivated worldwide. The tree originated ...
forked
KHTML
KHTML is a discontinued browser engine that was developed by the KDE project. It originated as the engine of the Konqueror browser in the late 1990s, but active development ceased in 2016. It was officially discontinued in 2023.
Built on the ...
, not Gecko, to create the
WebKit
WebKit is a browser engine primarily used in Apple's Safari web browser, as well as all web browsers on iOS and iPadOS. WebKit is also used by the PlayStation consoles starting with the PS3, the Tizen mobile operating systems, the Amazon K ...
engine
An engine or motor is a machine designed to convert one or more forms of energy into mechanical energy.
Available energy sources include potential energy (e.g. energy of the Earth's gravitational field as exploited in hydroelectric power ge ...
for its
Safari
A safari (; originally ) is an overland journey to observe wildlife, wild animals, especially in East Africa. The so-called big five game, "Big Five" game animals of Africa – lion, African leopard, leopard, rhinoceros, African elephant, elep ...
browser.
Mozilla has since cleaned up some of the XPCOM bloat. By 2008, this combined with other efforts resulted in big performance improvements for
Gecko
Geckos are small, mostly carnivorous lizards that have a wide distribution, found on every continent except Antarctica. Belonging to the infraorder Gekkota, geckos are found in warm climates. They range from .
Geckos are unique among lizards ...
.
References
External links
XPCOM API ReferenceA Simple XPCOM Tutorial
{{DEFAULTSORT:Xpcom
Application programming interfaces
Mozilla