219 points · by fatiherikli · 13y ago · 186 comments
I used Play in a startup backend and I won't be able to say I was satisfied with it. Play v2 is especially slower on your local development box, compilation takes some time and I actually still like Play 1.2.x family more. Its memory consumption was horrible on production (I made really a lot jvm adjustments and could not get it properly).
Personally, I now like Python frameworks (e.g Flask) and they are much easier, but I am not sure if you should rely your whole service infrastructure or enterprise software on a dynamically typed language stack. There are companies out there achieved this but I think Java or Scala will be just fine for LinkedIn, and by the way why the hack they don't allow comments on their engineering blog?
I had some technical concerns as well - in particular the database connectivity stuff is a bit painful.
I can say that the few small things I pushed out with Lift greatly benefited from the fact that the views were strictly html. To the point that nobody else involved even had to learn scala. Even though they did make some changes to the scala code. Being able to let folks edit that to their hearts content was ridiculously nice. That is, the fact that I did not have to (a) educate everyone on the templating mechanisms or (b) split apart templates received from someone else was huge.
As for the database connectivity, I guess you didn't like the agnostic approach they took?
Templating wise the Wicket approach is the best I've ever used, and I wish that style was available in other languages. You don't put any logic or control in your templates; your object graph in code controls your page hierarchy, your components are genuinely reusable objects.
Honestly, I think for me the big win with them is actually the inversion of how the template is done. Instead of writing some template that specifies how it is manipulated, you write a template and then directly manipulate it in the framework. (That make sense?) In essence, it seems that it is automating the typical first task on getting some html from a designer. This is great, because often the template can be redone and then all of the modifications the programmer was going to make to them is just part of the framework.
As noted by TylerE above, I can see how this might not be a factor. I personally loved it.
Doesn't that question seem rather non-productive? At least if you asked why he has that opinion you could engage in some sort of potentially constructive conversation on the topic.
I am comparing to Python frameworks and Node and everything mentioned there has been available in the Python stack for a while and now Node (extra points for realtime websockets stuff).
As per the post Play boasts of:
Rapid iteration, Reactive (only for the server not the client), Open, Supported, Flexible, Java & Scala
Maybe I would consider Java & Scala just for the enterprise community scale but definitely not the only one for functional paradigms or rapid iterations.
Everything else is there in other modern web frameworks in Python, Javascript & even perhaps Ruby.
Probably a new thing for Java but why the choice? Is LinkedIn constrained to use the JVM?
Unfortunately, we found developer productivity in the Java/Scala world to be a huge problem. We also found that most Java/Scala web stacks, based on servlets, were far behind other web frameworks (RoR, Django, etc) in terms of keeping up with the requirements of modern web development. Play helps on both fronts: it dramatically improves developer productivity and handles all the requirements of a modern web stack (MVC, web sockets, powerful routing, easy JSON handling, DRY form handling, etc).
Is it better than RoR, Django, Node? In some ways yes (e.g. Play's reactive programming model is dramatically better than JavaScript's callback mess), in some ways no (e.g. it's hard to compete with dynamic/interpreted languages for pure reload time). Is it better than everything else in the Java/Scala world? We think so.
With optional static typing you can pretty much pick and choose the best mode for each part of your application, which for me seems like nirvana. Even with static typing enabled, I find the syntax more concise and productive in Groovy than I do with Scala (I'm more experienced with Groovy so there's a lot of bias in that though).
the whole servlets/jsp/jsf thing is dead imo, is that where you guys were losing time?
Play makes this dramatically faster/easier. TDD is better with Play as well: the plugin support, strong test tools, and sbt's ~test command are amazingly productive.
Our Play backends, if they use JDBC to talk to a database, are fully blocking, since pretty much all JDBC drivers are blocking. One of the nice things about Play is it's easy to configure the thread pool to handle this configuration as well.
Not really. I don't see what features Play Framework has that are revolutionary or things that no other framework running on the JVM/Java wasn't able to do before.
"Rapid iteration" is the kind of "feature" that every framework claims to allow. No one advertises they allow "slow iteration".
Rapid iteration is probably obvious for PHP, Rails or Django, but on the JVM (or .net), it's pretty rare to see a framework that really supports it well.
I am sorry, what ?
Scala isn't functional; Scala is proper (pure) OO in a way that Java never was. Scala doesn't support top-level functions (only singleton objects), which doesn't exactly prevent it from being functional, but certainly suggests that the primary paradigm is still object-orientation.
It just so happens that pure OO, when properly done, happens to embody a lot of features similar to functional programming - Smalltalk is the easiest example of this (eg. the similarities between Smalltalk message passing and Haskell's implicit currying are very clear).
The reason for this is that it's trivial to create a good object system in a purely functional language, so the FP-OO relationship isn't an either-or so much as a 'special case' (ie, OO can be seen as a 'special case' of FP). The converse isn't so true; it's hard and clumsy to build a truly functional paradigm within an OO paradigm.
What GP probably meant is that Scala isn't a good choice for those who are coming from an FP background, since they'll likely notice that Scala seems very OO by comparison (because it is). Even on the JVM, there are other languages (ie, Clojure) which embody functional paradigms more transparently. On the other hand, Scala is a decent choice for OO programmers who want to get a taste of functional programming (or who want to incorporate those paradigms into their code), because Scala allows several aspects of the FP paradigm to come through as well.
If you ask someone coming from ML or Haskell, Scala is more "FP" than Clojure.
If you ask someone coming from Lisp, Clojure is more "FP" than Scala.
Ultimately, it doesn't matter what you call it. Pick your tools based on what they do, not on what other people call them.
This is neither here nor there. Scala has "package objects" and functions put into a package object are scoped directly at the top level of the package. They are not nested within any other object. The only downside to this that I can see, is that at the moment, a package can only have a single package object, which means all the top-level functions for the package have to reside within a single file.
That's quite a claim you're making here. I, on the other hand, pretend that object-orientedness and functionalness are orthogonal concepts.
I'm actually using Play 2.0.x for my first independent venture, which I posted a Show HN about a few hours ago:
On the JVM and especially since version 2.1 Play is one of the most lightweight/modular frameworks. At it's core it's just a fast/async http server. So why can't that just be a library you pull in and fire up in a main method?
You can have an IDE or somthing like sbt recompile your changes on the fly so you can get rapid feedback. Ultimately more rapid feedback comes for automated tests vs refreshing your browser and verifying something manually (unless it's UI/lookandfeel changes which are not generally limited by having to compile)
- controller methods are static
- DB access using the framework seems to involve calling play.db.DB.getDatasource()
- Play's Cache API involves calling Cache.get(), Cache.set()
Are Play applications easy to write unit tests for? Does it involve reconfiguring the framework to use some sort of stub services rather than the real DB/Cache implementation?
FooPlugin foo = Play.current.plugin(FooPlugin.class); foo.doSomething();
What instance you get depends on configuration (typically, a play.plugins file), which makes it easy to swap out implementations at test time. Much of Play's built-in functionality is implemented as a plugin too, including the DB code, so writing unit tests is pretty simple. There is strong support for "fake applications", integration tests, etc: http://www.playframework.com/documentation/2.1.0/ScalaTest
We'll blog more about Play plugins in the future.
For Play! components, they don't hole you into one DI framework or another. Instead, you can use your favorite DI framework (or with Scala, the cake pattern) on top of any Play API calls.
Scala's language support for traits, implicit conversions, implicit parameters etc. make dependency injection trivial. Once you get used to it, things like test mocks or IOC containers seem like obvious language smells.
(I work for Typesafe.)
In Play 1 development happened on Java first and Scala second.
In Play 2 development happened on Scala first and Java second.
- build json rest backend in whatever (java jaxrs/jersey, nodejs express, etc)
- build UI with html css js
- If initial page load is an issue due to lots of ajax calls, then use server side templating to ONLY insert a single variable which would contain a json object. This way the initial load is fast since the json is templated directly into the page. After load the UI calls rest services to get more data.
I've found that this enforces a clean separation of concerns.
WIth Play2.0 they introduced Scala Many folks has the opinion that Scala is complex, and i also lost trust in play because of no backward compatibility and i stuck up with huge code base which is not backward compatible
now iam looking build my other new applications on frameworks like Ruby on Rails , django leaving play.
You know in the time it took you to write that you could have Google'd this information.
Play for Java : http://www.manning.com/leroux/ Play for Scala: http://www.manning.com/hilton/
It's pretty much the same as when Microsoft announced nuget after ruby gems and apt-get existed for so long. Why don't they just cut the bull out and call it for what it is?
I feel that when I try to do anything in Java I always have to consult the documentation which slows me down. The good thing is that there's plenty of it on the Internet but it's still a productivity drag.
"One of the favorite features in Play" is being able to show errors in the browser and not in a log? What year is this? 1995?
The biggest key selling point for me is the 'hot' reloading: make changes in your code, refresh your browser, and see the changes immediately. You don't need the whole project to be rebuilt. As far as I am aware, this is what makes Play unique. The 'hot' reloading is probably the reason why it's useful to show nicely formatted errors in the browser (during dev / debug mode), you can see immediately where you stuffed up soon after browser refresh. Errors are also pushed to the console.
However, I realise that ASP.Net MVC View templates can be updated during debugging session, I only wish to be able to do the same with the .Net classes without having to rebuild it.
Plus, being on the JVM you'll have plenty of PaaS deployment options for cloud hosting provider (e.g. Google App Engine, Heroku, OpenShift).
I see the play people tout this all the time, and I assume it is in reaction to an assumption of dynamic language people that you have to manually compile every time you make a change. But it is really misleading. You make a change, refresh the page, and wait 10 seconds for it to compile and reload. Iteration speed was just as poor with play as it was with bloated J2EE monsters on jboss.
The refresh speed may indeed be annoying and could be better, but it's less of an issue with Play than in Rails or Django or whatever, because you're working with a static language and while writing code you feel less of a need to see what your new lines of code produce. In Scala, if you're using it as a functional language, all the code you write tends to be correct if it compiles and Play itself uses many functional idioms making it very suitable for a functional style.
It's worth noting what Play gives you when compared to Rails, Django and the like.
Remember that Rap Genius article from a few days ago, in which people complained about Heroku's Bamboo stack and having to work with over 70 Heroku dynos? I have a Scala module on top of Heroku that's processing 25,000 requests per second in under 100ms per request and that's running with just 8 Heroku dynos. And I'm actually dissatisfied because a high-CPU server on top of EC2 would be able to handle all 25K.
With Play you get the best of both worlds. A productive framework and the full power of the JVM. It's not easy to describe how it feels to get this combination, but it feels great, trust me.
Me too.
>but it's less of an issue with Play than in Rails or Django or whatever
>It's worth noting what Play gives you when compared to Rails, Django and the like.
Perhaps for some, but we have no interest in dynamic languages or frameworks written in them. We were evaluating frameworks for decent languages only. I was only commenting on the compilation speed issue because they constantly brag about fast iteration when it is no faster than a typical bloated J2EE monster.
It is? Are you building a war/ear and copying it to a server to deploy or something? I think every java IDE has support for locally building and deploying within the IDE, which is no slower than play's reloading.
True. Reloading pages on Play 1 (Java) took less than a second. It's about ten seconds now on Play 2 because of Scala.
The move to Scala feels like a mixed bag to me: it added both features and bloat to Play. Play 1 feels so light and fast in comparison.
It seems to me the Play developers moved to Scala more for personal fun than for their users (nothing wrong with that, just making an observation).
Maybe they moved to Scala because Scala is a superior language.
And where I work, we are users of Play specifically because it supports Scala well.
There's a project out there somewhere for integrating Groovy with Play but it looks quite immature.
https://github.com/robfig/revel
It didn't feel like idiomatic Go to me, but was a very nice, featureful, and complete framework.
When you use "sbt ~run", sbt compiles each file as soon as it changes. I.e., as soon as you save out the editor buffer. By the time you click on the reload button, sbt has usually already compiled all your changes, and it only takes a second or two for either your working page to reload, or for you to see a compiler error message.
It is not necessarily the case that you would use Play 2 for new projects.