Jonas Helming, Maximilian Koegel and Philip Langer co-lead EclipseSource. They work as consultants and software engineers for building …
Eclipse GLSP 1.0: TypeScript support for GLSP server implementationsJuly 20, 2022 | 4 min Read
In this article, we highlight a new feature of the Eclipse GLSP 1.0 release: Support for TypeScript based diagram server implementation. For a general overview of the GLSP 1.0 release and other notable features, please see the GLSP 1.0 release announcement.
Eclipse GLSP is a framework for efficiently building web-based diagram editors and makes it easy to embed them into Eclipse Theia, VS Code, Eclipse desktop or even an arbitrary web page. Please visit the Eclipse GLSP website to learn more.
With GLSP 1.0, there is an entirely new member in the GLSP component family: a node-based framework for writing GLSP diagram servers entirely with Typescript. Of course it was already possible before to write GLSP servers in any programming language or runtime, due to the flexible protocol-based client server architecture. However, with a dedicated framework, writing GLSP diagram servers with Typescript now got a whole lot easier. Thanks to STMicroelectronics for this great contribution!
Why is this such a great deal, you might ask? There are a few reasons, since choosing to write a node-based GLSP server instead of a JVM-based server is advantageous for certain use cases:
- Homogeneity Using one language (Typescript) for your GLSP server and GLSP client enables a more homogeneous developer experience than having to work with two languages (Java and Typescript) and potentially two IDEs and setups.
- Reduction of system requirements If you aim at providing a VS Code extension or Theia plugin, shipping a node-based GLSP server may be easier, since you don’t need to worry whether or not your users have a JVM installed. They’ll have a node runtime already.
- JSON source models If you plan to work with plain JSON files for your source models, i.e. the files you store your actual model information behind the diagrams in, Typescript may make it even easier to work with your JSON models.
Clearly, it depends on the use case and other factors if building your GLSP diagram server with Java or node.js is preferable. For instance, if you are working with EMF source models, or already have an existing diagram implementation that you migrate and you plan to reuse certain business logic, or if you also want to include your GLSP diagram editor as part of an Eclipse desktop tool, Java may be the better choice.
In any case, the node-based server framework for GLSP demonstrates the beauty of the architecture of GLSP in particular and LSP in general. The clear separation of responsibility and decoupling of client and server opens up a lot of flexibility, not only in the choice of language, but also for future evolution of your diagram editor. If for some reason, you need to switch to a different server platform in the future, you won´t need to change one line of your client implementation; and vice versa.
To see examples of GLSP server features implemented in Typescript and Java, please refer to the GLSP documentation, which shows both the code for a Java-based server and a Typescript-based server, where ever applicable.
The flexible architecture of Eclipse GLSP does not restrict the used language. By providing additional server frames for the most used languages (TypeScript and Java), it becomes even more efficient at implementing diagram editors with GLSP 1.0. Therefore, GLSP is a perfect choice for greenfield diagram editor projects, but also for projects that want to integrate existing business logic from a legacy tool.
We hope you enjoy the new TypeScript support in Eclipse GLSP 1.0. If you want to use a language other than Java or TypeScript, you can absolutely do so using the defined protocol. If you want support via a server frame, we are happy for contributions and also provide sponsored development for Eclipse GLSP.
If you have any questions about Eclipse GLSP, please get in touch with us! EclipseSource provides support for building custom diagram editors using Eclipse GLSP and for building custom IDEs or tools based on VS Code or Eclipse Theia.