- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Scala and SWT
I have been using Scala Swing and outside of some memory leaking, it works fine and elegantly. However I have been looking into SWT for some reasons, and I wonder if any one has experience with it? Also any one considering doing a wrapper for SWT like the scala.swing? Any considerations on this path?
Thomas
Thomas










Re: Scala and SWT
Thomas Sant Ana wrote:
> I have been using Scala Swing and outside of some memory leaking, it
> works fine and elegantly. However I have been looking into SWT for some
> reasons, and I wonder if any one has experience with it? Also any one
> considering doing a wrapper for SWT like the scala.swing? Any
> considerations on this path?
I'm considering a better Scala integration for http://novocode.com/naf/
(or even porting it to Scala entirely). Something similar to the
JavaScript bindings (inspired by JavaFX) which I added in the latest
release should work for Scala, too.
My main problem is a mismatch of available ideas and available time :)
Scala and SWT
Hello,
well I have had some time the last weeks for this topic and I started some work
towards an Scala SWT wrapper. I took as starting point the work in (referred in
this list last January)
http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/
but make some changes and add some new stuff. I would say, this version isn't as
functional as in the link above. I was inspired by the builder approach found in
Groovy's Swing builder or JavaFX. This means, the builder has a state tracking
the current position in the component tree. The API handle attributes of nodes
in a different way as the declaration of child nodes, also as in Groovy's Swing
builder and in XML documents. I think, in this way the tree structure can be
recognized easily.
Another design goals:
* enable an easy use in the RCP context. The builder has a secondary
constructor taking a composite as parameter.
* make the use of Java models as easy as Scala ones, specially for data binding
* use compiler type checking as much as possible to avoid errors and obtain
better IDE support
* the DSL should be intuitive and declarative, but not as a normal language,
the target users are programmers
I'm not completely happy with the result yet, but I wanted to get some feed back
from the community before investing more work on it. Specially data binding
could be more concise. I wish, I could write "bind(user.firstName)" instead of
two accessors, but I don't know how to get it, my Scala skills are still modest.
Also would be nice to have more flexibility in the API, for example if no
binding is wished, to leaved left and not to be forced of using an empty
binding. Scala 2.8 will maybe help in the last issue.
I implemented the same example as in the refereed link with the DSL and in plain
Java to compare and have a feeling of the potential win. The Java code is
larger, of course, but more relevant from my point of view is the readability
aspect. I compared using "wc" the method buildGui() in the Java version with the
equivalent Scala block and got this result:
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
77 220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
35 96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$
The numbers represents lines, words and chars.
Take a look at the code if you can and I'll be happy of getting any comments and
ideas. The Eclipse project containing the whole code is hosted at:
http://github.com/rodant/ScalaSWT/tree/master
In addition to Eclipse you need the Scala plug-in 2.7.4 to run the examples.
Cheers,
Antonio R. Rodríguez S.
Re: Scala and SWT
On Sun, Jun 7, 2009 at 8:22 AM, Antonio RamónRodríguez Santiesteban <rodant68 [at] googlemail [dot] com> wrote:
Re: Scala and SWT
thanks for your contribution! I included your changes in SWTBuilder, but with one change in the signature of your shell method's version. I wanted to keep both variants by overloading the method and the change was required to make the simpler version also available. This would be easier using Scala 2.8's default parameters.
The changes are now on Github, well at least I have committed, but I don't see it on the Web interface yet. Next time you want to contribute, you can also make a fork if you like.
Concerning real applications. Despite support for a lot of features is still missing, I think it could be used. In the areas where no support is available, it is possible to program against the Java APIs directly and apply a kind of hybrid approach, maybe.
Data binding is currently implemented to support the widget to model direction only. But eclipse data binding is very flexible and supports both. I was trying to make it work, but it is not trivial, if we don't want to impose strong requirements on the beans to be bound; they must fulfil an informal contract based on BeanPropertyChangeSupport. But if you need the bidirectional sync, I would continue working on it.
It was really great with your support and thanks again for that, that's the strength of open source!
Cheers.
2009/6/12 Naftoli Gugenheim <naftoligug [at] gmail [dot] com>
--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler
Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com
Re: Scala and SWT
2009/6/15 Antonio Rodríguez S. <rodant68 [at] googlemail [dot] com>
Re: Scala and SWT
2009/6/15 Naftoli Gugenheim <naftoligug [at] gmail [dot] com>
Re: Scala and SWT
Is it possible to use ScalaSWT with LWJGL or JORL?
On Sun, Jun 7, 2009 at 8:22 AM, Antonio RamónRodríguez Santiesteban <rodant68 [at] googlemail [dot] com> wrote:
Re: Scala and SWT
thanks for your feedback. My primary goal is the development of conventional user interfaces. Nevertheless animation, 3D and game programming could be a future issue for ScalaSWT as it is also in the case for JavaFX. Did you take a look at the animation features of last? I don't know it in detail, but it seams to be very promising.
Cheers,
Antonio R. Rodríguez S.
2009/6/7 Mason Green <mason [dot] green [at] gmail [dot] com>
--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler
Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com
RE: Scala and SWT
From: Antonio Rodríguez S. [mailto:rodant68 [at] googlemail [dot] com]
Sent: lundi 8 juin 2009 11:46
To: Mason Green
Cc: scala-user [at] listes [dot] epfl [dot] ch
Subject: Re: [scala-user] Scala and SWT
Hello Mason,
thanks for your feedback. My primary goal is the development of conventional user interfaces. Nevertheless animation, 3D and game programming could be a future issue for ScalaSWT as it is also in the case for JavaFX. Did you take a look at the animation features of last? I don't know it in detail, but it seams to be very promising.
Cheers,
Antonio R. Rodríguez S.
2009/6/7 Mason Green <mason [dot] green [at] gmail [dot] com>
--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler
Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com
Re: Scala and SWT
Cheers,
Antonio Rodríguez S.
2009/6/9 Gilles SCOUVART <Gilles [dot] SCOUVART [at] n-side [dot] be>
--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler
Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com
RE: Scala and SWT
From: Antonio Rodríguez S. [mailto:rodant68 [at] googlemail [dot] com]
Sent: mardi 9 juin 2009 22:42
To: Gilles SCOUVART
Cc: Mason Green; scala-user [at] listes [dot] epfl [dot] ch
Subject: Re: [scala-user] Scala and SWT
Thanks for the hint. I didn't know about XScalaWT, but I'll take a look at it. Are you involved in XScalaWT?
Cheers,
Antonio Rodríguez S.
2009/6/9 Gilles SCOUVART <Gilles [dot] SCOUVART [at] n-side [dot] be>
--
Dr. Antonio R. Rodríguez Santiesteban
Java-Plattform-Entwickler
Tel.: (030) 74921026
Priv. Tel.: (030) 470 03 470
Mobil: 01577 2856 033
E-Mail: rodant68 [at] googlemail [dot] com
Re: Re: Scala and SWT
well I had some time the last weeks for this topic and I started some work towards an Scala SWT wrapper. I took as starting point the mentioned work in
http://johlrogge.wordpress.com/2009/01/06/making-swt-shine-with-scala/
but make some changes and add some new stuff. I would say, may version isn't as functional in the link above. I was inspired by the builder approach found in Groovy's Swing builder or JavaFX. This means, the builder has a state tracking the current position in the component tree. The API handle attributes of nodes in a different way as the declaration of child nodes, also as in Groovy's Swing builder and in XML documents. I think, in this way the tree structure can be recognized easily.
Another design goals:
I'm not completely happy with it yet, but I wanted to get some feed back from the community before to invest more work on it. Specially data binding could be more concise. I wish, i could write "bind(user.firstName)" instead of accessor functions, but I don't know how to get it, my Scala skills are still modest. Also would be nice to have more flexibility in the API, for example if no binding is wished, to leaved left and not to be forced of using an empty binding.
I implemented the same example as in the refereed link with the DSL and in pure Java to compare and have a feeling of the potential win. The Java code is larger of course, but more relevant from my point of view is the readability aspect. I compared using "wc" the method buildGui() in the Java version with the equivalent Scala block and got this result:
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc java
77 220 3414 java
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$ wc scala
35 96 1703 scala
antonio@antonio-laptop:~/workspace_experimentos/SWT DSL/src$
The numbers represents lines, words and chars.
Take a look at the code if you can and I'll be happy of getting any comments and ideas. The Eclipse project containing the whole code is attached. If having the Scala plug-in 2.7.4 is all you need.
Cheers,
Antonio R. Rodríguez S.
2009/1/15 Stefan Zeiger <szeiger [at] novocode [dot] com>
--
Antonio R. Rodríguez Santiesteban
E-Mail: rodant68 [at] googlemail [dot] com
Re: Re: Scala and SWT
I'm sending my message (see below) again because I can't see it in the mailing list. Maybe it is a problem with the attachment. Now I send the link to the Github repository instead:
http://github.com/rodant/ScalaSWT/tree/master
Cheers,
Antonio Rodríguez S.
2009/6/4 Antonio Rodríguez S. <rodant68 [at] googlemail [dot] com>
--
Dr. Antonio R. Rodríguez Santiesteban
Java-Platform-Developer
E-Mail: rodant68 [at] googlemail [dot] com
Re: Scala and SWT
On Wed, Jan 7, 2009 at 6:01 AM, Thomas Sant Ana <mailleux [at] gmail [dot] com> wrote:
Re: Scala and SWT
On Wed, Jan 7, 2009 at 1:43 PM, James Iry <jamesiry [at] gmail [dot] com> wrote:
It's a nice approach to building the controls, but what I really like is the scala.swing way of handling events. However there is a catch in the design: it tends to generate memory leaks. That said I think it can be done in a way that does not generates leak, an still keep the clean approach of:
reaction += {
case SomeEvent(s) => // do ti
}
I think a nice build DSL and the reactions/proxy approach would be great. The real catch is getting experience in SWT from people like Jesse Eichar to avoid creating something that will endup throwing SWT out of resource exceptions.
One thing I ran into which is really cool is the MigLayoutManager. I like it's approach.
Thomas
Re: Scala and SWT
I have 5 years of SWT experience and have also considered a scala-SWT
wrapper. Only problem is time :(. But I would be willing to do what
I can to help and provide assistance if you are interested.
Jesse
On 7-Jan-09, at 3:01 PM, Thomas Sant Ana wrote:
> I have been using Scala Swing and outside of some memory leaking, it
> works fine and elegantly. However I have been looking into SWT for
> some reasons, and I wonder if any one has experience with it? Also
> any one considering doing a wrapper for SWT like the scala.swing?
> Any considerations on this path?
>
> Thomas