Jonas Helming, Maximilian Koegel and Philip Langer co-lead EclipseSource. They work as consultants and software engineers for building web-based and desktop-based tools. …
Eclipse Theia extensions vs. plugins vs. Che-Theia pluginsOctober 10, 2019 | 6 min Read
In this article, we compare Eclipse Theia plugins with Theia extensions and highlight the differences. In case you are wondering what Eclipse Theia is, please head over to our introduction to Theia and have a look at the frequently asked questions about Eclipse Theia. Eclipse Theia is an extensible framework for building tools and IDEs. It can be extended by custom features. This can be done by adding existing or custom Theia extensions, Theia plugins or even VS Code extensions. That obviously leads us to the first interesting question, which we will cover in this article:
What is the difference between an Eclipse Theia plugin and an extension?
Let us start with Eclipse Theia extensions, as they have been there first. Theia has been designed in a very modular and extensible way, this has always been a core design principle. The first mechanism available for that was the “extension”. As a matter of fact, everything in Theia, including the base parts such as the Monaco editor, the basic frame or the “Explorer View” are extensions. Therefore, extensions are first-class citizens in Eclipse Theia. If you create a custom Theia extension, you can do and access everything that the existing core extensions can do. Therefore, the extension mechanism of Theia is both very powerful and flexible. For the communication and “glue” between extensions, Eclipse Theia uses dependency injection (see here for details on dependency injection with inversify in Theia).
So, if your use case is to build a custom product based on Theia, reusing some of the existing extensions and adding some custom extensions are a pretty perfect way to do so. Please see this article on how to add extensions and plugins to Eclipse Theia and here for more details about Theia extensions.
Eclipse Theia plugins have been introduced at a later time as an alternative to Theia extensions. See also the official documentation on extensions and plugins. That leads us to the next question:
What is the advantage of an Eclipse Theia plugin compared to an extension?
The Theia extension mechanism is very powerful, but it has two shortcomings:
- Extensions are not suited to be installed/added at runtime, they are meant to be added at build time.
- Extensions are not “isolated,” neither from an API point of view nor are they running in a separate process. While this makes Theia extensions very powerful, you can easily “harm” or slow down the full product from within an extension.
If you are a tool provider and you develop a full custom solution based on Theia to your clients, you might not be affected by those two issues, especially if you do not want to allow anybody else to extend your solution. Please note that even the “extend at runtime” issue is a different story in the web compared to the desktop. Adding a new feature via extensions to your own custom product can be done in a centrally managed way and transparent to users as you control the deployment.
This all changes in a scenario, where you provide a more generic product based on Theia, and want to allow a community of developers to add features to it based on their individual needs. In this scenario, you also want to allow individual users of the tool to install those new features as plugins into their instance of your tool. If there is a marketplace of plugins available that you do not have full control over, the two issues described above become important. In such a scenario, you indeed want to allow users to install plugins at runtime and you need to ensure that those plugins do not affect the stability of your base tool. In a nutshell, the second scenario is much like the VS Code ecosystem or like the Eclipse desktop IDE. This is exactly what plugins achieve compared to extensions. Please see this article on how to install/add Eclipse Theia plugins.
Plugins are enabled in Eclipse Theia by a specific extension (remember, everything in Theia in an extension). This “Plugin Extension” provides an API to be used by plugins. This API is “restricted”, meaning it only provides selected features. Furthermore, it is “decoupled”, so plugins can run in there own process or even container.
Please note that extensions were originally also designed to allow for extensibility at runtime, and there used to be an “extension manager” in Eclipse Theia, a UI to manage extensions at runtime. However, this approach has been deprecated in favor of plugins.
So now that we have described the difference between an Eclipse Theia extension and a plugin, that leads to us to another follow-up question.
What is the relationship between an Eclipse Theia plugin and VS Code?
This one is pretty simple. When it was decided to design another mechanism to extend Eclipse Theia (the plugin mechanism), the definition of a corresponding API was part of this task. By that time, VS Code had already defined such an API, which (1) fulfilled the two original goals and (2) covered the expected functionality. Following the “do not reinvent the wheel” paradigm, which is justifiably one of the core values in Theia, the VS Code plugin API was adopted for Eclipse Theia. This provides two additional advantages: (1) If you know the VS Code plugin API, you can easily transfer this knowledge to Eclipse Theia plugins and (2) VS Code plugins can also be used in Eclipse Theia.
Conclusion and more
In this article, we have compared Eclipse Theia extensions to Eclipse Theia plugins and VS Code extensions. In a nutshell, extensions are more powerful and targeted at “build time extensibility”, while plugins are isolated, targeted at “runtime extensibility” and they are compatible with the VS Code extension API. Thereby, you can even reuse VS Code extensions without any adaptations in Theia.
Both mechanisms to extend Theia have their use cases, they even combine well. In this scenario, you would define your base product as a set of extensions and then potentially allow users to add more features at runtime via plugins. In both cases, you should always try to design your code as independant and modular as possible. The extension or plugin mechanism only wires your features into Theia, so ideally most of the effort is spent on code which is independent of both the extension and the plugin mechanism.
If you are looking for support in designing an Eclipse Theia extension or plugin, or need help to figure out, which mechanism is better suited to your project or if you need general support and advice on implementing a tool, extension or plugin based on Eclipse Theia, have a look at our service and support offering for Eclipse Theia, for web-based tools or tools in general and please get in contact with us!
Finally, if you are interested in future parts of this series, e.g. how to extend Eclipse Theia and how to customize it, please follow us on Twitter, we will publish the next parts of this article series soon.