writing netbeans RCP apps on scala - scala

Have anyone tried to write a Netbeans RCP application in scala (Instead of Java). The reason for my question there is an API in Scala which wraps JavaFX. Likewise is there any API to make to develop Netbeans RCP based apps written in scala.

For wrapping JavaFX there is ScalaFX. Netbeans Rich Client Platform is not small, and a Scala wrapper seems impractical to me (I am not aware of any); just call the Java code from Scala. Java/Scala interoperability is generally decent, so while you might occasionally have to write a little bit of Java as an interface, you can pretty much just use Scala for any Java project.
(Getting the build process to work might be a little tricky, though; expect to invest a little time there.)

I personally dont see any useful use case to use JVM language to develop NB RCP/Plugin. NB It self provides a IDE where you can use the drag-drop feature, codegen, annotation based IDE to created it. If you want to have a syntax sugar in writing NB RCP then i feel its waste of time where we already have a good IDE. JVM is not going to do any much difference that the existing environment.
If you see that you need a NB like modular, GUI based framework in Scala ecosystem that, I personally feel writing binding wont solve that problem. Scala need some framework like Griffon.

Related

Scala RAD tools

I am trying out on some application with Scala. I have been troubled a lot by its Swing support. Having to write the code seems to be painful. I love Netbeans Matisse function in this case.
Is there any Scala RAD tools available?
Is there any Scala RAD tools available?
No (as far as I know).
Having to write the code seems to be painful.
It really shouldn't be, with something like XScalaWT. Unfortunately, I don't know if there is a Swing equivalent.
I love Netbeans Matisse function in this case.
You can generate Java classes using Matisse and extend them in Scala.

Use Scala as if it was Java

I've been reading up on Scala a lot recently and I really want to get into it. I do my Java web development from within Eclipse with Tomcat as my preferred server and I'd like to keep it that way. I've tried the Scala Eclipse plugin but it's safe to say, it isn't there yet. I had to uninstall it because it simply ins't working. On top of that, it doesn't seem to provide anything for doing web projects (I could be wrong there).
Since Scala is a compiled language just like Java is, I was wondering if it's possible to simply swap out Java with Scala, as in, where I'd normally would create Java classes I would now be able to create Scala classes instead? Maybe even mix Java and Scala?
Is there anyone out there who's been able to set up a decent Scala workflow in Eclipse for web development without the dreaded "official" Scala Eclipse Plugin?
PS: I've tried the Play framework (I think it recently added Scala support) but it simply isn't for me. I like my classes compiled and to use JSP's for my views.
You don't say anything about what version of the Scala IDE for Eclipse you were using, or what you tried to do to resolve your issues. I suggest that before changing your workflow you head over to http://groups.google.com/group/scala-ide-user and see if we can help you out.
Since Scala is a compiled language
just like Java is, I was wondering if
it's possible to simply swap out Java
with Scala, as in, where I'd normally
would create Java classes I would now
be able to create Scala classes
instead?
Yes, absolutely. That's one of Scala's big advantages over some other JVM languages.
Maybe even mix Java and Scala?
Yes, absolutely. That's one of Scala's big advantages over some other JVM languages.
Make sure you have familiarity with the Java and Scala collections libraries (and that you keep them straight -- if you're planning using advanced Scala features on Java collections, definitely use a Scala 2.8 release candidate). Also make sure you're faimilar with the #BeanProperty annotation -- it can simplify your Scala coding somewhat.
As Miles said, you should give us the version of Eclipse you are working with.
I'm also new to Scala and found difficult to work through Eclipse. I was using Eclipse Galileo 3.5.2 and found specially long to compile all the scala libraries. I switched to IntelliJ (IDEA 9.0.2) and I'm much more confortable now. I recomend trying it although it's more a personal matter.
Even so, I agree, the plugins are not there yet specially for web development. The great news is that you can use everything you have in Java and mix it with Scala. Since Scala is compiled to Java BitCode, they are totally compatible. See Combining Scala and Java.
When writing in Scala you always have (almost) all the Java libraries at your service plus anything you have created before. You will have to be carefull with the types (i.e. primitive types) but it normally works out very well.

GUI in Scala/Groovy/Clojure

Last time I had to deal with Java was 2005 and I forgot almost everything about it since then.
Today I need to build a GUI app on the top of Java. I guess it is better to use one of Scala/Groovy/Clojure languages.
The question is: which of them is better for desktop GUI programming? My program will transform and display a series of jpeg/png files + there will be ~10 dialogs (with tons of options in each with all possible widgets).
The main requirement is compactness: I hate to write a dozen lines of code only to draw a simple frame with a button. My background in GUI is (mostly) Tcl/Tk and GTK+.
DISCLAIMER: I'm a Clojure programmer. I'm obviously biased.
Of all of those languages, I think Clojure and Groovy are probably the most compact. Scala is a curly-bracket language like Java, so it tends to take up a bit more space. However, it's nowhere near as verbose as Java is, and I think Scala is pretty awesome. I know that Scala has a swing wrapper. I've never done GUI development in Scala, so I can't really say how it feels.
I've done some swing development in Clojure, and it doesn't really take much. Using swing direct from Clojure can be tedious until you write yourself some abstractions, but altogether, swing apps are smaller than the same thing in Java because Clojure code tends to be shorter and more concise than Java code.
Clojure also has some wrappers of sorts to make swing development more Clojury. One of which is clj-swing. I've seen some code written using it, and it's pretty cool, and definitely more concise than direct interop.
Now, I don't know Groovy. I really don't know much of anything about it, but I know it's more compact than Java, so I imagine GUI development would be fairly compact as well.
I think Clojure is a safe bet. With clj-swing, or even directly using the Java GUI toolkits directly is going to be really compact compared to Java, and the ability to build abstractions over non-compact stuff with macros is definitely a huge plus. Clojure has my vote.
Scala comes with fairly complete sample applications for basic GUI elements, which you can run by typing scala scala.swing.test.UIDemo at the command line. You can browse the source code for them here.
You may also look at this document to get an idea of the design principles behind Scala's Swing wrappers.
Groovy has the Griffon framework which uses convention over configuration for building GUI apps on the JVM. It's similar to grails/rails but for a rich GUI rather than a web app.
Groovy has something called the swing builder for making GUI programming easier. Here is a piece of sample code from the groovy website, it creates a frame with a button and counts the number of times you click it:
int count = 0
new SwingBuilder().edt {
frame(title:'Frame', size:[300,300], show: true) {
borderLayout()
textlabel = label(text:"Click the button!", constraints: BL.NORTH)
button(text:'Click Me',
actionPerformed: {count++; textlabel.text = "Clicked ${count} time(s)."; println "clicked"},
constraints:BL.SOUTH)
}
}
I am currently developing an SWT application in Scala and quite like it. But I do expect Clojure would be even more compact.
I've been writing a GUI by using Clojure directly with Swing. It has worked very well indeed so far. I've also written some custom UI components in Java that have proved very easy to integrate with the Clojure part of the code base.
I also think that clj-swing looks great - possibly easier than using Swing directly if you don't have prior Swing experience.

Another Java vs. Scala perspective - is this typical?

I have been reading about Scala for a while and even wrote some small programs to better understand some of the more exoteric features.
Today I decided to do my first "real project", translating some 60 lines of ugly Java code to Scala to rewrite it using the better pattern-matching features (why? because the Java version was becoming hard to maintain due to excessive combination of regex and conditionals).
About halfway through the editing process, Eclipse thew up this error:
alt text http://img269.imageshack.us/img269/1243/errorms.jpg
I get the general impression that the Scala IDE in Eclipse is a lot buggier and less complete than its Java equivalent. Is this correct or do I just have a bad installation? Is there a better IDE for Scala?
I really like IntelliJ Idea Community Edition's Scala support. I've been using it from it's early days. I've also tested Netbeans and Eclipse plugins but I really don't like them that much. Especially all Eclipse Scala plugins are crap. I also tested Textmate Scala bundle, which is very nice but doesn't offer auto completion.
Here is my Scala Ide top list:
IntelliJ Idea Community Edition
Netbeans
Textmate (This is here, since I really like Textmate for writing Rails applications)
Eclipse
When you learn IntelliJ Idea keyboard shortcuts and add some live templates you can be very productive programmer. Furthermore, if you buy the Intellij Idea Ultimate Edition you can even share the settings with multiple computers or with your team.
What I suggest:
Download IntelliJ Idea Community Edition
Install the Scala plugin
Learn the keyboard shortcuts: Windows and Linux, Mac
Configure Live Templates when you get more familiar with the ide
The Eclipse IDE Scala support has not been great for some time, but is now receiving additional development effort alongside the introduction of Scala 2.8, and appears to be improving. For Scala 2.7 I have found the Intellij plugin to be in a better state.
One problem that both of these plugins have is that Scala itself is a moving target - Scala 2.8 has introduced additional syntax and structures to Scala 2.7.
From my own experience with Eclipse, using it for languages other than Java is never quite as good.
You might find this post of interest.
I get the general impression an IDE for a new, young, niche language is a lot buggier and less complete than a widespread, supported, mature language
Try Netbeans. Its plugins are generally of a simpler construction anyway, so should have less 'gotchas'
One point to make is that it is possible that people are still put off IntelliJ because they assume that the licence is expensive, especially if they are happy with Eclipse and are unaware of the Community Edition which is free and open source.
I cannot give any comparison with the other IDEs as I have always used IntelliJ, however the Scala support is certainly good, all things considered, and getting better.
We are using Eclipse Scala plugin at work and working with it is quite terrible. One cannot really trust reported errors inside IDE, runtime exceptions are the order of the day. Our best experience is with build from 25-11-2009.
At home I play with IntelliJ 9 and its Scala plugin and I find it much much better. I am newbie to IntelliJ but I am very impressed with all those little details which (once you get used to them) increase your productivity... a lot.
The drawback is in IntelliJ there is no compile-error reporting on the fly (at the time you're writing code) yet implemented and only Scala up to 2.7 is supported (2.8 by nightly builds only), but there are NO runtime exceptions while working with the IDE. I would recommend you to try IntelliJ, community edition at least.
I never really get on with IDEs at the best of times because they are usually pretty awful at actual text editing, but Eclipse's Scala plugin is particularly brittle to the point that projects "forget" that they are Scala after a while. Battling Eclipse seems to consume more effort than it saves. I just went back to my Emacs and sbt REPL in a terminal.
A light play with IntelliJ confirmed that it does at least do the job as a Scala IDE, but again I didn't care for its editor. It's also commercial software. However, if you are seeking a robust Scala IDE, this is perhaps where you should be looking.
What I have since settled on is perhaps perverse and not for the newcomer, but suits somebody who has definite opinions about their text editor. ENSIME is an editor plugin and server component that adds what you need from a Scala IDE to Emacs. It also claims support for vim, Atom, and Sublime, but I've not tested these. Occasionally it also has a bad day—obscure kinds of macros particularly confuddle it—but it generally does the job.

Developing Eclipse plugins without Java

Is it possible to create Eclipse plugins/program Eclipse RCP apps without Java? (preferably in Jython)
This will be possible in the next Eclipse major release e4:
One of the goals of e4 is to provide support for writing plugins in other languages.
The quote is from http://wiki.eclipse.org/E4/JavaScript which summarizes the current state of using javascript to implement eclipse plug-ins in e4.
This issue in eclipse's bugzilla issue #227058 also has some discussion on that, but I believe it is outdated.
I am currently not aware of activity regarding other languages.
No. An Eclipse plugin is an OSGi bundle, and that requires interacting with a variety of things that can't implemented in Jython as far as I can see.
If you want to avoid Java, you can look at other things that target the JVM, but you will have to figure if you can produce and consume the specific items needed to call the necessary things and be called in the necessary ways.
OSGi bundles may be written in other JVM languages like Scala. Eclipse plug-ins, as of now, does not support any language other than Java. The Eclipse Plug-in Development Environment heavily makes use of JDT which ties it to Java. However there are some plans I heard that plug-ins might be supported in other languages. But I don't see that coming in near future.
You can write your main code in Jython and use Java interfaces to call then from Java. Take a look at this for details. Also, I am writing a utility library (github.com/abhin4v/jywrapper) to do the same. It has very little documentation right now, but you can look at the examples provided.