
Langium is an open source language engineering tool with first-class support for the Language Server Protocol, written in TypeScript and running in Node.js. This future-proof technology stack enables domain-specific languages in VS Code, Eclipse Theia, web applications, and more.
Langium generates a typed abstract syntax tree (AST) definition that perfectly fits your grammar and provides utility functions to help you navigate and process the AST.
Langium was developed on the basis of years of practical use of Xtext, which is an integral part of numerous projects and products worldwide. We apply this experience to push language engineering to a new level.
The main goal of Langium is to lower the barrier of creating a DSL or low-code platform. We achieve this by providing a special DSL that describes the syntax and structure of your language: the grammar language.
Built exclusively on web technologies, Langium is not only available for Node.js based environments but works just as well in your browser. When packaged as a language server, you can connect it to most modern IDEs.
Exploiting the power of the Language Server Protocol, Langium provides useful default implementations for most features. If you are in need of something special, you can override the defaults with your custom implementation.
You can easily package a Langium-based DSL as a command line interface (CLI) to create a rich set of interconnected tools: validator, interpreter, code generators, service adapters, etc.
.... implemented in TypeScript, runs in Node.js
.... with a grammar declaration language similar to Xtext
.... derives a parser and abstract syntax tree from a grammar declaration
... by using Chevrotain—the blazing fast parser library—under the hood
.... with high out-of-the-box functionality and high extensibility
Despite its age, Xtext is still an excellent basis for building languages and related tools with a Java technology stack. In recent years, however, the VS Code extension API has become increasingly relevant, not only for VS Code itself, but also for other tools that support this format, such as Eclipse Theia. This is why Langium has been created. It enables language engineering in TypeScript, the same technology used for VS code extensions. The differences at a glance:
Building a tool that uses an Xtext-based language server with VS Code or Theia means creating a hybrid technology stack where some parts are implemented in Java and others in TypeScript. Developing and maintaining such a mixed code base is more challenging for the engineers involved, and long-term maintenance is more difficult compared to Langium's coherent technology stack.
Xtext is heavily based on the Eclipse Modeling Framework (EMF). This can be an advantage if you want to integrate with other Eclipse modeling tools (e.g. Sirius), but it can also be a burden due to its complexity. Langium uses the simplest possible solution to describe an AST (i.e. the parsed contents of a text document): TypeScript interfaces. By relying on the built-in language constructs, we avoid the additional abstraction layers and steep learning curve of a modeling framework.