The development of CRaSH 1.3 has been started a few months ago. The website now provides a 1.3 section for people that want to play with the 1.3 betas.
I haven't talked much about it so far but I think it's time to unveil what will be in this new version.
Polyglot
It makes a lot of sense to widen the scope of CRaSH and provide support for more JVM languages. Integrating a dynamic language is not hard, however creating an API for the interactions between the target language and the CRaSH runtime requires more work.
Surprisingly the first supported languages in this new beta is ... Java! With our experience we have now the possiblity to easily dynamically compile Java at runtime (using the Tool API). You can see that as a proof of concept of decoupling CRaSH from Groovy (it was actually less coupled than I originally thought). Simply put now you can have .java
commands and they will just be compiled fine by CRaSH (jmx command written in Java).
In the next iteration (beta4) we will focus with the integration of the Ruby language. I have been learning Ruby for the past few weeks and the language does not seem hard to learn, however I am lacking of experience for defining a decent Ruby API. So we are looking for someone with Ruby experience that could help us to define such API:
- Creating a command in Ruby
- Invoking a command from Ruby
- etc...
For Groovy I have the chance to know pretty well Guillaume Laforge and he often provided a lot of guidance for providing a great Groovy API. We are looking for anyone that could help us doing the same for Ruby. If you know such great guy, ask him to poke us on the crash-users list.
Improved Groovy support
Until CRaSH 1.2 we focused on the Groovy language because it is the best dynamic language for Java developers on the JVM. It took several iterations to provide the best Groovy support and this version covers the part for invoking commands from Groovy and how to assemble them in a command pipe line, here is an overview of the API:
Evaluating a command
A command name evalutes to a Groovy closure, allowing to call the command just like a function:
help()
Evaluating a compound command
Sub commands can be invoked by resolving a new closure from the initial command:
thread.ls()
Passing options and arguments
Command options and command arguments are passed as invocation parameters, options are used as a map or named parameters and arguments are the other invocation parameters:
thread.ls(h:true)
system.propget("file.encoding")
log.send(m:"hello", "the.category")
Command pipeline
Pipelines can be assembled with the |
(pipe) operator. When a command closure is combined with a pipe, it returns a new closure that will invoke the pipeline:
(system.propls | egrep { "java.*" })()
A pipeline can also contain Groovy closures in addition of the existing commands:
(thread.ls | { Thread thread -> [id:thread.id, name:thread.name] })()
Extended REPL
REPL stands for Read–eval–print loop, which is what you have when you have an interactive session with CRaSH. Until version 1.2, the only REPL is a language close to bash shell for invoking commands or creating command pipelines.
Since CRaSH 1.3 will be polyglot, this new version provides polyglot support for the REPL. The new repl
directive allow you to switch to other REPL implementation and we provide in this beta a Groovy REPL:
% repl groovy
Using repl groovy
In this mode you can type plain Groovy (it is similar to Groovy Shell) and most importantly you can use the improved Groovy support seen above, for instance:
% (thread.ls | { Thread thread -> [id:thread.id, name:thread.name] })()
id name
------------------------------------
2 Reference Handler
3 Finalizer
...
% cmd = thread.ls | { Thread thread -> [id:thread.id, name:thread.name] }
thread.ls | Script14$_run_closure1@47da4d19
% cmd()
...
Asciidoc documentation
The documentation is now written in Asciidoc, it is in many ways similar to the previous documentation. Asciidoc has gained a lot of traction in the past months thanks to the great job of Dan Allen on Asciidoctor and GitHub provides a native support for Asciidoc providing a decent doc preview. The 1.3 doc is also deployed live on the site as a preview.
Wrap up
CRaSH 1.3 will provide polyglot support with additional languages such as Ruby as main theme. The Groovy language support has been strenghtened providing the best Groovy support so far. You can download the 1.3 beta or read the documentation from the website.
blog comments powered by Disqus