Is it possible to call java/scala libraries from scalajs? - scala.js

I understand scalajs compiles to javascript so I can reuse javascript libraries. Is there anyway to reuse java libraries as well?

Short of reimplementing them in Scala.js, no, it is not possible to reuse Java libraries in Scala.js.

Related

writing netbeans RCP apps on 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.

convert scala to java for GWT?

For GWT client side you need Java source code so i got that idea to convert scala code to java code.
How can i archieve this conversion?
Or is there a production ready possibility to use scala directly?
Thanks for any help!
It can't be done because Scala compiles directly to byte code, not Java. Compiling to byte code is much easier than generating Java and besides, there's a lot of stuff the byte code allows that is forbidden by Java the language, such as not declaring checked exceptions.
There's a project going on at http://scalagwt.gogoego.com/ to generate a "java-like" language from Scala that GWT can read. It seems to be moving along nicely and I know Lex Spoon is involved with it. I know they briefly considered the other possibility of decompiling the generated Java but dropped that path quickly after determining that too much information was lost in that process.
If you only want to use Scala on the backend and write the client in Java, that's always been possible and works fairly well in Eclipse.
Some work has been done to allow GWT to be written in Scala, by an intern on the GWT team last summer. See http://www.youtube.com/watch?v=_1GjgFjX5gE

Are there any Scala template engines other than scalate?

I'm tring to embed scalate in my website with sbt+jrebel, but found there are some problems I can't resolve.
So I want to know if there any other template engines based on scala?
How about popping on the Scalate group and describing the actual problems you're having? Am sure its fairly straight forward to work around? If the issue you're having is to do with sbt + jrebel and class reloading of scala code that you want to use inside your template engine; switching template engine's isn't sounding like an option (unless you want to stop using Scala in your templates). Plus Scalate is really the best and most popular template engine that uses Scala expressions inside it.
Play framework for scala has a brand new scala template engine
not sure if it can be used outside of play
http://scala.playframework.org/documentation/scala-0.9.1/templates
Pure Scala DSLs:
scala-xml (not sure how long this will be supported though)
ScalaTags
"Regular" templating engines:
Twirl
JSP (Java)
Freemarker (Java)
Velocity (Java)
Thymeleaf (Java)
Mustache.java (Java)
Thanks to String Interpolation from Scala 2.10, now we can use native syntax to generated a complex text content.
Just use Fastring. It has both good performance and simple usage.
If you're running on the JVM, Scala's interoperability with Java would let you use Velocity or Freemarker.
I might want to look at Stitchr which was largely inspired by StringTemplate
Scalasti is a Scala wrapper around StringTemplate.
As already mentioned above, I would recommend using Twirl (the template system from Play). It's now very easy to use standalone. You'll have compile time checking of your templates and many more cool and simple stuff:
https://github.com/spray/twirl

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.

Groovy and GWT: Combining both paradigms

Is it possible to develop an application in groovy using GWT components?
Luis
If you want to use Groovy on the server-side and GWT for the UI, that is certainly possible. You can use Grails (a Groovy web framework on the server), and the Grails GWT plugin to help you integrate GWT with this framework.
I don't think so, because the GWT compiler is basically a Java to JavaScript source compiler (it would be possible if the GWT compiler needed Java bytecode). You can use Groovy on the server side though.
Right now you cant use Groovy on the client side. One big reason is that Groovy relies a lot on introspection, and this is not available on GWT.
I have also wondered this, as it would be very nice. Vaadin essentially does this and you can use their plugin: http://grails.org/plugin/vaadin
Doing it this model, though, it is compiling components into Javascript and delivering from the server. But unlike GWT components, these are calling back to the server every time you touch the API (though of course with Vaadin you can use GWT components as well).