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.
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...
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
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.