Scripting Eclipse – just rapid prototyping?

When I started my work on scripting support for the Eclipse platform I had three major goals in mind:

  • First inexperienced programmers should get a simple language not forcing them to deal with complex data types or object orientation.
  • On the other hand the language should allow for complex structures and object-oriented design if users do want this.
  • Finally, interaction with the running IDE should be possible.

EclipseScript already used Rhino as an engine and added a static Document Object Model (DOM) to it which allowed interaction with some workbench elements. Eclipse Monkey took the concept a step further and allowed to extend the DOM via extension points. Having a DOM that can be extended during runtime was just the logical next step. After having a first prototype ready the Eclipse Advanced Scripting Environment (EASE) was born.

To get started simply install a script engine from our p2 site. Switch to the Scripting Perspective and type print(„Hello world“) in the Rhino Script Shell view.

The Rhino Shell accepts JavaScript code, allows to access JDK classes as well as the whole Eclipse API of your current installation. In case you want more convenience, have a look at the Modules Explorer View to the right and browse through the available functions. To try them out simply drop a command to the shell. While EASE ships with some predefined modules we encourage you to write your own (no knowledge of EASE required).

Interacting with given Eclipse APIs allows to explore their functionality in an easy way. Simply use a script shell and call any method you are interested in. Oh, did I mention that you have code completion support even for Java classes?

More script demos and tutorials are available on our scripting repository.

Automation and UI Integration

Scripts provide a convenient way of automating recurring tasks. I do use scripts to generate new workspace projects based on given templates, update plugin version numbers or to run certain external builds. Once your script library grows you need to organize them in a library. EASE preferences allow to provide library locations and accumulate existing scripts into a nice view. But wouldn't it be much nicer to integrate your scripts directly into the IDE?

EASE scripts do understand magic keywords in header comments. Some of them allow to attach a script to toolbars, view menus, and popups. But keywords can do even more. Scripts may trigger on startup or shutdown, they may react on resource changes or even on events to the event bus. Do you have ideas for other keywords? EASE allows to define your own...

Unit Testing

Now we got this nice script language, so why not use it for writing simple, expressive regression tests? Behavior driven testing is an exciting topic nowadays. EASE does not support Gherkin style feature descriptions (yet), but with the help of modules your users are able to write unit tests without having lots of programming background. Further such tests will be simple to read and understand. A first test may look as simple as that:

startTest(„sum 2 values“);
assertEquals(5, thisIsYourSumFunction(2, 3));
endTest();

Given the right set of custom modules you may provide your own DSL for test developers. Then write expressive tests for web services, IoT devices, or the C++ project you are working on in CDT. EASE provides nice frontends to run and debug your tests. Of course support for automation and Jenkins integration is also available.

With our latest release we extended the unit test framework to support python scripts too. Next to the simple, functional syntax we introduced OO testing similar to Junit. For python we integrated support for pyunit tests.

The Quest for the Right Script Language

Scripting is powerful. Some claim that JavaScript is not. We do not intend to start religious wars on the best scripting language, so we simply support them all. Starting out with Rhino we added more and more interpreters over the years: Jython, Groovy, Jruby, Beanshell, Nashorn and finally full python support via Py4J.

Using Py4J you may interact with any local python interpreter on your system. This allows to use the powers of numpy and scipy for scientific calculations. If python alone were not enough we also integrated support for Jupyter notebooks right in the Eclipse IDE.

Interested? If you're at EclipseCon Europe (Oct 24-26, 2017) join our extended python tutorial. We do also have an introductory talk where we demo the main features of EASE.

About the Author

Christian Pontesegger

Christian Pontesegger
Infineon Technologies AG