Play with Java or Scala

1,952 views
Skip to first unread message

Stefan Gündhör

unread,
Jul 12, 2011, 1:22:40 PM7/12/11
to play-framework
Simple question but difficult to answer, at least for me.
Im new to Scala (but experienced with Java) and going to develop a
spatial web application,
and now I can't decide whether I should start using Scala and maybe
lose some time until beeing productive
or I should just stick to plain "old" Java...
I also wonder if the Anorm data access layer of the scala plugin
executes native sql (in order to be able to access PostGIS spatial
functions).

Maybe some of you can give me some advice or tell me sth. about their
own experiences ... just tell me if Scala is worth it :-)
Thanks

Ike

unread,
Jul 12, 2011, 3:05:34 PM7/12/11
to play-fr...@googlegroups.com
Do you need to meet any deadlines for this project?

If the answer is yes then go with Java. Otherwise, I would definitely recommend trying out scala. It's concise, it's powerful and it's worth it. But it's not ready for "prime time". Anorm can do native sql (in fact, that's all it does), and there are many other nice shortcuts here and there that you'll appreciate. However, things are not finalized and things are changing, sometimes dramatically. So be prepared to revisit your code with each new beta release.

Stefan Gündhör

unread,
Jul 12, 2011, 4:37:40 PM7/12/11
to play-framework
Okay thank you very much for this helpful answer - as this project
will be my diploma thesis
I have to or at least should finish it in a certain period of time, so
I'll stick to Java for now and
try Scala besides or next year.
Anorm is a cool thing, what a pity that's not available for play-
java :/

Pascal Voitot Dev

unread,
Jul 12, 2011, 4:44:28 PM7/12/11
to play-fr...@googlegroups.com
anorm is simply not really possible in Java due to lack of syntactic sugar :(

anyway there are nice stuff also in Java for Play ;)

Pascal

2011/7/12 Stefan Gündhör <ste...@guendhoer.com>
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.


v6ak

unread,
Jul 20, 2011, 4:55:12 AM7/20/11
to play-framework
It is a good answer. Scala itself is a great language, but Play-Scala
is not as documented, tuned etc. as Play-Java. Learning Scala because
of Play-Scala is IMHO not worth the time. (It will be probably
changed.) However, learning Scala because of another project (for
example, you have core in a Maven/SBT project and frontend in Play!)
is IMHO worth the time. It is much easier and much more fun than Java.
Regards,
Vít Šesták 'v6ak'

On Jul 12, 9:05 pm, Ike <ikes...@gmail.com> wrote:

Ivan Meredith

unread,
Jul 20, 2011, 6:41:18 AM7/20/11
to play-fr...@googlegroups.com
I totally disagree with that. Having a backend with maven/sbt... i dont really see what that gives you. That is scala code that probably won't rely on play specific code anyway, so it wont be affected by api changes. I have learnt scala mainly through using play-scala. Sure there is a few parts lacking, but overall it is very very nice. Nicer than lift for sure ;).

--
You received this message because you are subscribed to the Google Groups "play-framework" group.

Pascal Voitot Dev

unread,
Jul 20, 2011, 7:35:56 AM7/20/11
to play-fr...@googlegroups.com
On Wed, Jul 20, 2011 at 10:55 AM, v6ak <v6...@volny.cz> wrote:
It is a good answer. Scala itself is a great language, but Play-Scala
is not as documented, tuned etc. as Play-Java. Learning Scala because
of Play-Scala is IMHO not worth the time. (It will be probably
changed.) However, learning Scala because of another project (for
example, you have core in a Maven/SBT project and frontend in Play!)
is IMHO worth the time. It is much easier and much more fun than Java.
Regards,
Vít Šesták 'v6ak'

I'm not sure Scala is much easier than Java... you manipulate complicated concepts in Scala that Java can't even imagine and I still wonder what Scala produces with a "not very skilled" developer... I saw what C++ did when you took a bad C developer and made him write C++ and it was a messsssssss :)
 

On Jul 12, 9:05 pm, Ike <ikes...@gmail.com> wrote:
> Do you need to meet any deadlines for this project?
>
> If the answer is yes then go with Java. Otherwise, I would definitely
> recommend trying out scala. It's concise, it's powerful and it's worth it.
> But it's not ready for "prime time". Anorm can do native sql (in fact,
> that's all it does), and there are many other nice shortcuts here and there
> that you'll appreciate. However, things are not finalized and things are
> changing, sometimes dramatically. So be prepared to revisit your code with
> each new beta release.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.

Manuel Bernhardt

unread,
Jul 20, 2011, 9:13:27 AM7/20/11
to play-fr...@googlegroups.com
From my experience play-scala is less mature and less documented, but
being able to use scala (if you know it or are serious about wanting
to learn it) in my opinion compensates for this. We switched from lift
to play-scala for a rather big project recently and have been insanely
productive since then (the framework is not in your way, which has
been our experience with lift).

I also work on a rather big play-java application (5 months in the
doing) and switching back from the play-scala one feels like someone
just tied one of my hands behind my back.

Then again, I don't advise to rely simply on using play-scala to learn
the language. For this I can recommend "Programming Scala" by Venkat
Subramaniam.

Manuel

Ronald Haring

unread,
Jul 20, 2011, 9:39:52 AM7/20/11
to play-fr...@googlegroups.com
But how do you handle the persistence layer? I have tried working with anorm, but I ran into some issues which prevented me from using the play-scala stack as base. So is there a better option for the persistence then anorm?

Regards
Ronald

Julien Richard-Foy

unread,
Jul 20, 2011, 9:41:40 AM7/20/11
to play-fr...@googlegroups.com

Pascal Voitot Dev

unread,
Jul 20, 2011, 9:44:32 AM7/20/11
to play-fr...@googlegroups.com
you can also use directly Siena from Scala, it works quite well apparently even if I don't use it myself!

On Wed, Jul 20, 2011 at 3:41 PM, Julien Richard-Foy <j...@zenexity.com> wrote:
You should be able to integrate almost any other persistence
framework, see http://scala.playframework.org/documentation/scala-0.9.1/database#IntegratingotherexistingDatabaseaccesslibrairies
--
You received this message because you are subscribed to the Google Groups "play-framework" group.

Manuel Bernhardt

unread,
Jul 20, 2011, 9:44:55 AM7/20/11
to play-fr...@googlegroups.com
for the play-scala application we have mongo as a backend and use
casbah with salat and salatDAOs. this works very nicely. we actually
use the same model case classes to load data from YAML, dump it to
mongo and also to fetch it from the view.

actually I also needed to have access to JPA from the play-java
application which also has some parts written in scala (and thus needs
the play-scala module to be active). for this I needed to patch the
module to get rid of the ScalaModel type declaration which overrides
the java Model. see
http://play.lighthouseapp.com/projects/74274/tickets/17-playdbjpamodel-type-definition-leads-to-incompatibility-with-existing-java-models-applications

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.

> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/wbrL7w65g9oJ.

Rober Magnus

unread,
Jul 20, 2011, 10:27:36 AM7/20/11
to play-fr...@googlegroups.com
Hi

If you like documented, standard conform things, you may have a look at
JPA.

regards,
R. Magnus

--
Robert Magnus
akquinet tech@spree GmbH
Bülowstraße 66, D-10783 Berlin
Tel. +49 (0)30 235 520 - 44 Fax. +49 (0)30 217 520 - 12

Geschäftsführung: Martin Weber, Dr. Torsten Fink
Amtsgericht Berlin-Charlottenburg HRB 86780 B
USt.-Id. Nr.: DE 225 964 680

Ronald Haring

unread,
Jul 20, 2011, 11:19:15 AM7/20/11
to play-fr...@googlegroups.com
Yes, I am very familiar with JPA, but since it is stated on the play-scala pages that that is not the preferred way to go, I was wondering what the best way to go is for persistence layer. I tried anorm but ran into a number of issues which prevented me from using this as the persistence. But then I was stuck at what I should use instead.

Regards
Ronald

Jonas

unread,
Jul 20, 2011, 3:17:21 PM7/20/11
to play-framework
I was in the same situation as you a month ago. I did know Java well,
but I'm more curious about learning Scala, and it has been nice to use
with Play.

But Anorm is far from mature. It may be easier to use JDBC directly
with Scala. I find it hard to handle errors from the database when
using Anorm, and it's not good documented, but as long it works it's
nice. I use PostgreSQL, and some things aren't possible with Anorm
when using PostgreSQL. E.g. you can not use Magic. And Anorm doesn't
support all PostgreSQL statements like "Returning" on Insert.

But added to that I don't think JPA/Hibernate for Java is a good
persistence solution for Play Framework. Play used Netty - an event-
driven server, so it's not good to do long-running stuff on the main
threads, it would be much better to use an asynchronous database
driver, in my point of view.

The Hammersmith Scala driver (also based on Netty) for MongoDB, may be
a good persistence solution, but I have only read about it the last
few days.

MongoDB seem to have support for Spatial indexing, that can be useful
for you, if you don't have to go with PostGIS (based on PostgreSQL).
See http://www.mongodb.org/display/DOCS/Geospatial+Indexing

/Jonas

Stefan Gündhör

unread,
Jul 20, 2011, 10:43:03 PM7/20/11
to play-fr...@googlegroups.com
Thank you for the hint regarding MongoDB, Jonas!
I already knew MongoDB, but the last time I read about it, it didn't have such a good spatial support as it has now.

Erwan Loisant

unread,
Jul 21, 2011, 3:39:23 AM7/21/11
to play-fr...@googlegroups.com
Hi,

First thing: you can use an ORM (or Mongo as you said) with
play-scala, you're not forced to use Anorm. It's just that JPA won't
work well. So if your data is inherently relational and you don't like
Anorm, you can pick a Scala ORM such as Squeryl for example. There is
pretty much no integration between the data layer to the rest of the
framework so it doesn't matter what you use underneath.

On Wed, Jul 20, 2011 at 21:17, Jonas <jlpett...@gmail.com> wrote:
> I was in the same situation as you a month ago. I did know Java well,
> but I'm more curious about learning Scala, and it has been nice to use
> with Play.
>
> But Anorm is far from mature. It may be easier to use JDBC directly
> with Scala. I find it hard to handle errors from the database when
> using Anorm, and it's not good documented, but as long it works it's
> nice. I use PostgreSQL, and some things aren't possible with Anorm
> when using PostgreSQL. E.g. you can not use Magic. And Anorm doesn't
> support all PostgreSQL statements like "Returning" on Insert.

There has been some progress in master compared to 0.9, especially
regarding error handling. In 0.9 most queries where returning an
Either so you had to look specifically to see if there was any SQL
error. Now it's throwing an SQLException so you get the same feedback
as if you were using JDBC directly. Additionally, there was a bug in
Anorm where field names were not escaped. That would break on MySQL if
you had reserved names in your columns names (user, column...) but
work on H2 (so you saw the bug in prod but not dev). This has been
fixed too.

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.

> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>

--
Erwan Loisant

Robert Magnus

unread,
Jul 21, 2011, 8:01:05 AM7/21/11
to play-fr...@googlegroups.com
Hi

There are things to concern when you use jpa together with scala (see
http://scala.playframework.org/documentation/scala-0.9/database). But:
JPA has a long history and its used in a lot real life applications and
you got (for the jpa part) a _lot_ of documentation - that shouldn't be
underestimated.

For your choice, just check:
- do you need a strong relational database or more a NonSQL database
- how many data you do have: 100, 10.000, 1.000.000
- do you have an existing db schema, possibly big and strange
- do you have blobs


regards,
Robert

v6ak

unread,
Jul 21, 2011, 8:59:29 AM7/21/11
to play-framework
Maven and SBT have some advantages, but they aren't important now. The
important thing is: The core is the largest part of the application in
my case. It is not a simple CRUD app. In such case, Scala is a very
good language which helps me to be more productive. Although the Scala
standard library documentation is not as good as Java SE
documentation, it is good enough for me.

On the other hand, I'm not sure if I should recommend learning Scala
to somebody who would use it for Play applications (without any larger
Play-independent core) only. This will be probably changed.

Vít Šesták 'v6ak'

On Jul 20, 12:41 pm, Ivan Meredith <i...@ivan.net.nz> wrote:
> I totally disagree with that. Having a backend with maven/sbt... i dont
> really see what that gives you. That is scala code that probably won't rely
> on play specific code anyway, so it wont be affected by api changes. I have
> learnt scala mainly through using play-scala. Sure there is a few parts
> lacking, but overall it is very very nice. Nicer than lift for sure ;).
>

v6ak

unread,
Jul 21, 2011, 9:11:21 AM7/21/11
to play-framework
OK, Brainfuck is the simplest language I've ever seen. Java, Scala
(etc.) are much more complicated than Brainfuck.

Well, try to write something in any of these languages. Would you
choose Brainfuck? I wouldn't. Although the language is very simple,
writing something in BF can be very hard.

I believe there is a similar difference between Java and Scala. The
Scala language is more complex than Java, but writing something in
Scala is usually simpler and more fun.

I agree that "not very skilled" Scala developer can be a disaster. It
may be a worse disaster than "not very skilled" Java developer.
However, an "skilled enough" Scala developer can be more productive
than "skilled enough" Java developer.

On Jul 20, 1:35 pm, Pascal Voitot Dev <pascal.voitot....@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages