ECMAScript, popularly known as JavaScript, has become an important programming language, not only as a scripting language for web pages, but also for larger projects, including rich web applications and even back-end software. In order to develop large projects successfully, static validation and sophisticated tooling are crucial. N4JS enriches ECMAScript with a static type system and provides extensive support for static validation hosted within a feature-rich IDE.
N4JS is an extension of ECMAScript providing a sound type system. It provides a transpiler to translate N4JS files to plain ECMAScript. The N4JS IDE enables the authoring of JS and N4JS files, providing tool support analogous to that of best-of-breed Java IDEs, e.g., Eclipse JDT.
N4JS adds a static type system similar to that of Java to ECMAScript 2015. This type system support nominal and structural typing, in both cases supporting generics similar to that of Java 8. In order to capture details specific to ECMAScript,additional constructs are introduced such as union types, 'this' type, and special forms of structural types. Additional concepts required for larger projects are built in, e.g., dependency injection, test support, and various component types.
N4JS provides an extensible framework for representing and manipulating JS and N4JS files.Based on this framework, it provides integrated, extensible tooling that supports instantaneous validation, content assist, and quick fixes, as well as launch support for running the code and associated tests.
The N4JS IDE is based on the Eclipse platform and uses many associated Eclipse technologies, in particular Xtext. Not only does it provide a Java-based ECMAScript 2015 parser, it also produces EMF-based models for both the abstract syntax tree (AST) of JS and N4JS as well as the type model of N4JS. This makes it an ideal basis for implementing a host of interesting tools to analyze, maniuplulate, and transform JS and N4JS.
N4JS aims to build a community of contributors who will help build a powerful, feature-rich IDE.
The project is already using a build process similar to the one used by Eclipse projects, so it should be possible to quickly set up the Eclipse project with a nightly build once the project gets approved and the initial contribution as gone through the due diligence process.
The current version is already stable and has been in production mode internally for over a year. Fixing bugs and adding minor improvements are on going work, of course. Additionally, the following topics are expected to be addressed:
- Improved UI experience, in particular customized content assist as well as more quick fixes.
- Improved ECMAScript 2015 support.
- Improved type inference.
- Improved refactoring capabilities.
- Improved node.js developer experience, e.g., support for browser-based projects.
Although tooling only supports N4JS and plain ECMAScript at the moment, it should be possible to also provide support for other ECMAScript typing approaches such as TypeScript in the future. Whether this is added or not depends on the community feedback and involvement.