aspose file tools*
The moose likes Scala and the fly likes Scala for GUI? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Languages » Scala
Bookmark "Scala for GUI?" Watch "Scala for GUI?" New topic
Author

Scala for GUI?

Andriy Tsykholyas
Greenhorn

Joined: Feb 24, 2009
Posts: 15
Hi all!

I'm going to make a little desktop application which would run on JVM. I'm considering Scala as a language for it.
I know that Scala would work with swt or swing. I've also found some swing dedicated Scala libraries: ScalaGUI and scala-swing (this one is included in Scala API).
So, would you recommend to use Scala for GUI application?
If yes, what option is preferable:
- (pure java) swing
- swt
- ScalaGUI
- scala-swing
- a combination of multiple options above
?
Also, Groovy's power feature for swing is swing builder. Has Scala anything similar?


Thanks
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
From what I've heard about Scala, I got the impression that it's great for back-end work. Personally, I think you might find JavaFX, or something similar for a GUI.
Burk


SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Andriy Tsykholyas
Greenhorn

Joined: Feb 24, 2009
Posts: 15
Hi Burk,

thanks for you reply.
I've missed some details in my previous post which probably are important why JavaFX was not on the list
The details are:
- my primary platform is Linux;
- I'm familiar with Swing/Java and not familiar with Linux programming;
- I'm going to learn Scala (and maybe SWT)
- one of main reason why I've chosen Java is ease of deployment (you need only JRE and application jar file/files).
I think JavaFX has following drawbacks which are not the issue for Swing/SWT based Scala (of Java) solution:
- problems with Linux;
- immaturity;
- heavyweight (AFAIK JavaFX is build upon Swing with significant hierarchy of classes).
So, that's why I prefer not to choose JavaFX.

Andriy
Venkat Subramaniam
Author
Ranch Hand

Joined: Jan 28, 2008
Posts: 79
Hi Andriy, the first thing you will find interesting and refreshing is how Scala idioms intermixes well for
event handling. The way you register for handlers (for buttons, etc.) is quite different and nice. Second,
Scala also allows you to let the GUI code handle in the main thread while rest of your applications can
deal with tasks in other threads. The last thing I can think of that may be of interest to you is
the conciseness of GUI code. I agree that I would not consider GUI development as the significant strength
of Scala, however, if you are using Scala and want to use it for GUI development, then the answer is most certainly
a yes; you can and you have some benefits like I mentioned above.
Andriy Tsykholyas
Greenhorn

Joined: Feb 24, 2009
Posts: 15
Hi Venkat,

thanks for your answers. I think the advantages of Scala pointed out by you should be quite helpful. So, I'm going to try it

Andriy
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Andriy Tsykholyas wrote:The details are:
- my primary platform is Linux;
- I'm familiar with Swing/Java and not familiar with Linux programming;
- I'm going to learn Scala (and maybe SWT)
- one of main reason why I've chosen Java is ease of deployment (you need only JRE and application jar file/files).
I think JavaFX has following drawbacks which are not the issue for Swing/SWT based Scala (of Java) solution:
- problems with Linux;
- immaturity;
- heavyweight (AFAIK JavaFX is build upon Swing with significant hierarchy of classes).
So, that's why I prefer not to choose JavaFX.

Andriy

Andriy,
No problem, but you've got some misconceptions. Things have changed since the early days.
1) JafaFX is available for Linux. Go here - http://javafx.com/downloads/linux.jsp to download it.
2) JavaFX runs on the JVM and builds on what you know about Java and (to a lesser degree) Swing.
3) The JavaFX runtime is part of the JRE since Java 6 update 10 so you've probably already got what you need to run it.
4) It deploys just like a Java app.
5) Does not build on the Swing components - though you can wrap Swing components with JavaFX code is you need or want to.

There's been a lot of changes since the beginning of the year and it's probably worth taking another look at. That said, if you want to do a pure Scala app then that's your choice. I just wanted to make sure you knew that a number of the things you listed were not true or were no longer true.

Burk
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Hi!

It seems like Scala could be used very nicely for lots of different things besides its well-known use cases. From what I know Scala currently only provides some kind of core library, right? Do you think other libraries or frameworks (for example for GUIs, enterprise apps etc.) will start to grow soon in the near future? I know you can any time mix it with Java but it sounds like you could make lots of improvements and have advantages with "native" Scala libraries. How do you see Scala's place regarding other areas in software devlopment besides its core functionality? Maybe I just don't have enough experience here because Lift is the only popular Scala framework I know at the moment But I'd be glad to see Scala gaining more popularity in other fields.

Marco
Andriy Tsykholyas
Greenhorn

Joined: Feb 24, 2009
Posts: 15
Hi Burk,

thanks for your explanations. It looks like I need to take a closer look at JavaFX
The combination of back-end written in Scala and front-end in JavaFX may be quite interesting. The drawback is that accessing advanced Scala features from Java (and probably from JavaFX) is not too easy.

Andriy
Grigory Kislin
Greenhorn

Joined: Apr 10, 2008
Posts: 2
Have a look also here: http://code.google.com/p/scalafx/
Ivano Pagano
Ranch Hand

Joined: Dec 16, 2006
Posts: 47

Grigory Kislin wrote:Have a look also here: http://code.google.com/p/scalafx/


As for the moment, scalaFx is in my opinion still immature for serious enterprise development, it really need more consistency, more polishing and support for all the components.
At the same time you can gain a lot from it for small projects, and the dev team is working really hard right in this moment, so I expect many improvements in the near future.

For the time being I would stick to plain JavaFx, which can gain a lot from scala syntax and features, for example, as already said, in event handling, but not only that.

I would also take a glimpse at the visage project [1], if you like scalaFx syntax. It's a JVM language targeted to UI development that takes up from the first JavaFx releases, so it's compatible to Java, and Scala.

[1] http://code.google.com/p/visage/
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Scala for GUI?
 
Similar Threads
SWT versus Swing/awt
Similar coding between Swing and SWT
TableItem in SWT Designer Tutorial
Suggestions for developing desktop application in java
netbeans in Java (is there good books explain GUI in netBeans in details with examples)