Tuesday, August 26, 2014

Where are the JVM Scripting IDEs?

The raise of scripting languages in the past decade has been spectacular. And since the JVM platform is the largest, a few were designed specifically for that platform while many others were also implemented on top. It is thus that we have JRuby, Jython, Groovy, Clojure, Rhino, JavaFX and the more obscure (read more fun) things like Prolog and Scheme implementations. Production code is being written, dynamic language code bases are growing, whole projects don't even have any Java code proper. Yet when it comes to tooling, the space is meager to say the least.

What do we have? In Eclipse world, there's the Dynamic Languages Toolkit which you can explore at http://www.eclipse.org/dltk/, or some individual attempts like http://eclipsescript.org/ for the Rhino JavaScript interpreter or the Groovy plugin at http://groovy.codehaus.org/Eclipse+Plugin. All of those provide means to execute a script inside the Eclipse IDE and possible syntax highlighting and code completion. The Groovy plugin is really advanced in that it offers debugging facilities, which of course is possible because the Groovy implementation itself has support for it. That's great. But frankly, I'm not that impressed. Scripting seems to me a different beast than normal development. Normally you do scripting via a REPL, which is traditionally a very limited form of UI because it's constrained by the limitation of a terminal console. What text editors do to kind of emulate a REPL is let you select the expression to evaluate as a portion of the text, or take everything on a line, or if they are more advanced, then use the language's syntax to get to the smallest evaluate-able expression. It still feels a little awkward. Netbeans' support is similar. Still not impressed. "What more do you want?", you may ask. Well, don't know exactly, but more. There's something I do when I write code in scripting languages, a certain state of mind and a way of approaching problems that is not the same as with the static, verbose languages such as Java.

The truth is the IDE brought something to Java (and Pascal and C++ etc.) that made the vast majority of programmers never want to look back. Nothing of the sort has happened with dynamic languages. What did IDEs bring? Code completion was a late comer, compared to integrated debugging and the project management abilities. Code completion came in at about the same time as tools to navigate large code bases. Both of those need a structured representation of the code and until IDEs got powerful and fast enough to quickly generate and maintain in sync such a representation, we only had an editor+debugger+a project file. Now IDEs also include anything and everything around the development process, all with the idea that the programmer should not leave the environment (nevermind that we prefer to take a walk outside from time to time - I don't care about your integrated browser, Chrome is an Alt-tab away!).

Since I've been coding with scripting languages even before they became so hot, I had that IDE problem a long time ago. That is to say, more than 10 years ago. And there was one UI for scripting that I thought was not only quite original,  but a great match for the kind of scripting I was usually doing, namely exploring and testing APIs, writing utilities, throw away programs, prototypes, lots of activities that occasionally occupy a bigger portion of my time than end-user code.  That UI was the Mathematica notebook. If you have never heard of it, Mathematica (http://www.wolfram.com/mathematicais a commercial system that came out in the 90s and has steadily been growing its user base with even larger ambitions as of late. The heart of it is its term-rewrite programming language, nice graphics and sophisticated math algorithms, but the notion of a notebook, as a better than REPL interface, is applicable to any scripting (i.e. evaluation-based, interpreter) language. A notebook is a structured document that has input cells, output cells, groups of cells, groups of groups of cells etc. The output cells contain anything that the input produces which can be a complex graphic display or even an interactive component. That's perfect! How come we haven't seen it widely applied?

Thus Seco was born. On a first approximation, Seco is just a shell to JVM dynamic languages that imitates Mathematica's notebooks. It has its own ambition a bit beyond that, moving towards an experimental notion of software development as semi-structured evolutionary process. Because of that grand goal, which should not distract you from the practicality of the tool that I and a few friends and colleagues have been using for years, Seco has a few extras, like the fact that your work is always persisted on disk, the more advanced zoomable interface beyond the mere notebook concepts. The best way to see why this is worth blogging about is to play with it a little. Go visit http://kobrix.com/seco.jsp.

Seco was written almost in its entirety by a former Kobrix Software employee, Konstantin Vandev. It is about a decade old, but active development stopped a few years ago. I took a couple of hours here and there in the past months to fix some bugs, started implementing a new feature to have a centralized searchable repository for notebooks so people can backup their work remotely, access it and/or publish it. That feature is not ready, but I'd like to breathe some life into the project by making a release. So consider this an official Seco 0.5 release which besides the aforementioned bug fixes upgrades to the latest version of HyperGraphDB (the backing database where everything get stored) and removes dependency on the BerkeleyDB native library so it's pure Java now.    


  1. There are interesting thoughs build in seco, but I miss a better documentation in order to make use of it. For instance, I didn't manage to use Groovy as scripting language within 15 minutes...

  2. You are right, it should be no effort at all to use any of the more popular languages. There is a wiki page for explaining how to add languages: https://code.google.com/p/seco/wiki/AddingScriptingLanguages. I just tested the advice there to make sure it works, and it didn't :(. I should be able to fix this today, hang on. Thanks much for giving it a try, and more importantly for the feedback!

  3. thanx for the link to the wiki - it works when you create (as described) a new nice. At least, it worked for me.
    Seco contains some interesting concepts, but I still wonder in which situation they would be usefull. I guess the best use might be for some interactive tutorials - what do you think?

  4. I put an updated version of the InstallLanguages.nb and linked from the wiki, so that should work too now. It's actually easy to add any JSR 223 language, at least for evaluation purposes. Adding syntax coloring and code completion is more work and unfortunately still undocumented. But there are so many things to do in that project, that I'd prefer to be more reactive and prioritize bugs or features only if somebody complains.

    As for usage, I personally use it for several things: (1) As a complementary interface to a large project development, to prototype new components of a system before converting them to Java (2) to explore the API of a new library (3) to test and debug an existing project by calling directly the various layers of the system, (4) to perform various administrative tasks, e.g. there is a bug in some system, so periodically I have to examine some piece of data and repair it so I write a notebook to do that.

    Of course, all those things can be done in Java too, but you have much less feedback. For example, you can write a small Java program to solve problems like (4) above, but that program becomes a black box that's hard to adjust on the fly quickly in case something in the environment changes. So you start wasting time to make it more "generic" etc.

    But interactive tutorials are a really good use case actually. To teach algorithms or APIs etc. In fact, my next main ambition for Seco is a central location for people to download and upload notebooks. So if I find some new cool technology that I want to blog about and at the same time show how to use it, I could actually write a notebook and serve it up as HTML in addition to it being available to import in Seco.

  5. Add Scala to your blogpost. Scala is JSR-233 compatible. And it works. Very simply.

  6. Thanks, so you were able to plug Scala following to instructions for adding a language? Can you provide info what the Scala scripting factory class is, or in general what you did?

  7. Oh, I meant that Scala works in JSR-233 very fine. I don't know about it working in Seco. Will take a look.