BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News A New Crop of Self Hosting IDEs: RedCar and JRuby, Cloud9 IDE and Javascript

A New Crop of Self Hosting IDEs: RedCar and JRuby, Cloud9 IDE and Javascript

This item in japanese

Except for Smalltalkers, dynamic language programmers are used to their tools and IDEs being written in lower level languages. Writing developer tools for a language in the language has big advantages, particularly for users (ie. developers). In the case of editors and IDEs, it means developers can extend their tools without having to deal with another language and platform. Java developers today can choose from a list of Java-based IDEs, all extenѕible by writing a bit of Java code. That's not quite the case for Javascript or Ruby.

Two new IDEs try to change that: Cloud9 IDE written for/in Javascript and RedCar written for/in JRuby.

Cloud9 - Javascript

Serious editors and IDEs written using Javascript and HTML were hard to imagine half a decade ago. Then Javascript VMs became much faster and HTML components gained functionality that made sophisticated editors possible. Skywriter (formerly known as Bespin), Mozilla's programmer's editor, uses the Canvas element and API to draw it's editor component.

At startup (in the browser), Cloud9 visually resembles Eclipse visually a bit, and it also uses the idea of building the whole IDE out of plugins. All functionality is contributed via plugins, including the editors, views, behaviors, etc. One advantage Javascript can be seen in the plugin metadata descriptors, which are written in JSON, which is easily handled (and manipulated) in Javascript - less hassle for plugin developers.

When it comes to functionality, it's early days for Cloud9 at the moment - at least compared to mature IDEs. There are some convenient features in the IDE already, though. The Javascript debugging support has a GUI and connectors for debugging with Node.js and Chrome runtimes. It's possible to write a Javascript project in Cloud9, start it in Node.js in debug mode and use the GUI to suspend, resume the execution or set breakpoints. The feature uses the debuggers built into the Javascript VMs.

Cloud9 uses ACE as the editor component. Where Skywriter draws the editor contents using Canvas, ACE uses the DOM. The editor content pane is a DIV element; the ACE determines which lines in the editor's backing store are visible on the screen, renders each as DIV elements and adds them do the editor's DIV. ACE uses multiple layered DIVs to render different elements of the editor, in particular selection highlights and the cursor.
Turns out today's HTML renderers and DOMs are fast enough to make this possible and let ACE run fast enough to feel like a native editor component.

An HTML5 API useful for editor components is the Web Worker API, which allows Javascript code to fire up new Javascript processes; not threads but instead shared-nothing processes, that communicate sending messages that can contain JSON data. In a programmer's editor it's crucial to run tasks in the background; a lot of work has to be done for every keystroke or every operation. Syntax highlighting using regexes is one thing, but modern editors need to parse the source code to do semantic highlighting, ie. color local variables differently from global ones, static methods differently from virtual methods, etc. Other tasks are code-aware folding, etc.
Running all these tasks on the foreground thread (GUI thread, event dispatching thread) can work by using the setTimeout function in clever ways. Web Workers avoid hacks of this kind, and can be used to run extra tasks in the background, potentially making use of multiple cores.

While it's name might suggest otherwise, Cloud9's default installation runs locally and can access the local filesystem. For that, it uses a backend written in Javascript on Node.js with which it communicates via a socket. Contents of files are provided by Node.js via WebDAV, which uses the jsdav library.

The Skywriter and Cloud9 teams have announced an interest in cooperating and making it possible to share plugins, language specific features, etc. Good if it'll work out - another IDE war avoided.

The Cloud9 IDE blog provides updates and information on new releases. The GitHub repositories are a good way to get started with the source. The Cloud9 IDE can be installed by checking out the source and, running the backend server with Node.js and pointing a browser at it. 

RedCar - JRuby

RedCar is an extensible editor, with IDE ambitions, written in Ruby, JRuby to be precise. RedCar uses SWT as its GUI framework which available across many platforms.

A built-in REPL makes it possible to explore and experiment with the API, and the existing plugins make it easy to get started with extending the system. Actually, RedCar can be extended with HTML/Javascript as well. Views can contain a SWT web component, which allows to build GUIs or displays using HTML/Javascript/CSS, instead of having to use the SWT component or drawing APIs.

TextMate users will be happy to hear that RedCar has support for TextMate bundles, making the transition easier.

A more thorough introduction to RedCar, the concepts and how to extend it, can be found in InfoQ's interview with RedCar creator Dan Lucraft. The Redcar Twitter account or the Redcar Blog are good places to get current information on new projects and features. Redcar can be installed with Ruby Gems.

Rate this Article

Adoption
Style

BT