Blog

An Interview with an Add-on wizard - Henri Kerola

By  
Tanja Repo
·
On Nov 6, 2014 10:00:00 AM
·

We sat down with one of our Vaadin guys here at the office, famous for his super scalable add-ons, Henri Kerola.

Henri Kerola - Vaadin Expert

1) Henri, you're the creator of the Scaladin addon. Where did the idea for the add-on come from and why Scala?
I think the original idea of providing something that makes it easier to use Vaadin came from Henri Muurimaa. He also invented the Scaladin name. The first name of the add-on was actually scala-wrappers but that wasn’t a very good name for the addon. Henri asked inside the company, who would be interested in creating something to make it easier to use Vaadin with Scala. I knew what Scala was but I had never used it, I decided to volunteer because I liked the syntax of Scala. Also functional programming sounded something I wanted to learn. Also Risto Yrjänä volunteered. Most of the code was written by Risto and me but we have also been happy to receive code contributions.

2) How did you actually create Scaladin?
Technically, how does it work? The idea behind Scaladin is simple: make it easy to use Vaadin with Scala. You don’t actually need anything extra in order to use Vaadin with Scala because Scala’s interoperability with Java is good. Here’s an example of Vaadin UI code written with Scala, without any helpers:

val myTable = new Table { 
  setSizeFull() 
  setImmediate(true) 
  setSelectable(true) 
  setContainerDataSource(createContainer) 
  addValueChangeListener(new ValueChangeListener { 
    def valueChange(event: ValueChangeEvent): Unit = "Table clicked!" 
  }) 
}

As you can see, it’s just Java with Scala syntax. Here’s the same code written with Scaladin:

val myTable = new Table { 
  sizeFull() 
  immediate = true 
  selectionMode = SelectionMode.Single 
  container = createContainer 
  valueChangeListeners += Notification.show("Table clicked!") 
}

This looks much better. In order to provide as pure and clean a Scala API as possible, Scaladin wraps Vaadin classes inside their own classes. An instance field on the wrapper holds the actual instance of a Vaadin component, and methods in the wrapper delegate to this instance. This means that with Scaladin you don’t use classes from the com.vaadin package, you use vaadin.scala instead. Another approach for providing Scala API for Vaadin is to extend Vaadin classes instead of wrapping them. There is actually an addon in Vaadin Directory that does that: Rinne. The disadvantage of this approach is that you have both Java and Scala APIs mixed into the same class.

3) How about client-side Scala? Are there any plans for writing the GWT side in Scala as well?
There is an experimental Scala+GWT project, which makes it possible to write your GWT code with Scala instead of Java. But that project is not developed anymore. However, there is a project called Scala.js, that has nothing to do with GWT, but it provides a Scala to JavaScript compiler.

I have done some prototyping with Scala.js, and it looks like it would be possible to provide an API for writing your own Vaadin widgets and extensions with Scala. Unfortunately I don’t have anything to show right now.

4) What tips would you give add-on writers, where to get started, how to do it, etc?
Try to do something simple and just release it in the Vaadin Directory. Eclipse and Vaadin Plug-in for Eclipse provide a very convenient way to create your add-on project quickly. I have noticed that if you spend too much time on setting up the project, you don’t have time or motivation for the actual development.

5) What are you working on next? What can we expect from Scaladin or any other addons in the near future?
I already have some unreleased updates to the addon, which I should publish. These changes contain, for example, support for Scala versions 2.10 and 2.11. The new Grid component should be released by the end of this year, so a Scaladin wrapper class for that would be great to have, at the same time as when the final Vaadin 7.4 is out.

sbt-vaadin-plugin is one of my addons I would like to highlight here. sbt is a build tool for Scala (and Java) projects. Like the name says, sbt-vaadin-plugin is a plugin for sbt, which provides needed functionality to build Vaadin or Scaladin applications with sbt. It for example provides tasks for widgetset compilation and launching a development time server.

 

Watch the Online Webinar on how to create Add-ons with Vaadin

 

 

Tanja Repo
Tanja Repo is Vaadin's Marketing Magician which means her responsibilities are marketing communication and its coordination in all its glory. Tanja has vast experience around events and has worked with various software industry players. Technology has always been a mystery to her, that she wants to unveil. Loves to laugh, smile and drive around with her Vespa. You can follow her on Twitter – @RenjaTapo
Other posts by Tanja Repo