7 ms·
Play framework for Java - a radical rethink of Java web app development?
- simonw 17y agoI just ran through the tutorial and it was a real breath of fresh air - everything ran out of the box, there was no need for an IDE or a build process and changes were live the second I saved them from my editor (it apparently ships with the on-the-fly compiler from Eclipse). Really impressed.
- rapind 17y agoAgreed. I still think it's a little cumbersome compared to rails, but it's definitely the best java web framework I've seen yet, and about as close to rails as you can probably get with java. Groovy for the template language is a good choice too. The example app was very useful. Including some real world jquery ajax functionality was a big bonus and a great way to compare functionality with other frameworks. (render methods and routing specifically).
- ConceptDog 17y agoAlso agreed. Play is closer to what I was hoping Lift would end up being for Scala. But with Scala support coming in Play 1.1, I'm officially excited.
- therockhead 17y agoWould you mind sharing some of your thoughts on lift? How does it compare to other web frameworks that you have worked with?
- nocivus 17y agoI think I would prefer the django template language. Seems like you type a lot less, though I have been mistaken before :)
- jrockway 17y agoJava has real lightweight threads, so what's the advantage of "shared nothing" here? Extra memory usage and less speed?
- mcav 17y agoIt seems to refer to this: > "Play is designed to operate in a ‘share nothing’ architecture. The idea is to keep the application completely stateless. By doing this you will allow your application to run on as many server nodes as needed at the same time. >What are the common traps you should avoid to keep the model stateless? Do not store any object on the Java heap for multiple requests" If that's all they're talking about when they say "stateless", that's no different than a lot of other "stateless" MVC frameworks like Pylons, Django, Rails, etc.
- modoc 17y agoI haven't done any real dev with those frameworks you list so I'm wondering how do you manage session state? user profile, shopping cart, breadcrumbs, multi-request flows, etc... Do you write/read all that into the db/memcached for each request?
- jshen 17y agotypically your session data is stored outside of the web app process. It could be in files, memcached, db, cookies, etc.
- mcav 17y agoYes. PHP does the same thing. Actually, most frameworks do that; very few keep state within the application server between requests. Statelessness, in that respect, improves scalability.
- ilyak 17y ago...while reducing perfomance...
- falsestprophet 17y agoWhat is the virtue of developing a web application in Java instead of a scripting language like Jython (aside from execution speed obviously)?
- henning 17y agoJava IDEs are mature and make it easy to refactor your application. (I realize that part of the necessity of this stems from the Java language itself. The tools are still good.) This advantage may be temporary if IDEs for other languages become highly sophisticated.
- ConceptDog 17y agoJava itself is extremely mature on a well documented and expansive platform. Fusing the rapid development aspect of languages like ruby or php with the maturity of Java is pure win for web developers.
- patio11 17y agoWell, at my day job, not having to throw out 10 years worth of legacy code would be considered "a bit of a plus". We also have 1,200 employees and precisely two engineers who have ever done a Rails application more complicated than the 15-minute-blog demo. I think we have one guy who coded a Python app once. Our favorite contractors and outsourcing providers also have (comparatively speaking) deep skills in Java and the related stacks. Some of them have forgotten more than I ever want to know about, e.g., serializing Java beans.
- martincmartin 17y agoIf you pick as JVM language as suggested, why would you need to throw out any code? When I worked at ITA Software which writes much of their stuff in Lisp (not the web stuff though), there was often worry that it meant new programmers would have to learn the language and so wouldn't be productive at first. But learning the code base takes a lot longer than learning the language, at least enough of the language to get significant stuff done. If you have 10 years worth of legacy code written by 12,000 employees, I assume you're in the same boat.
- c00p3r 17y agoLet me guess - it's yet another Java on Rails?
- simonw 17y agoYes, but run through the tutorial. It's very slick.
- c00p3r 17y agoJava is the yesterday, not the tomorrow. update: Before do stupid down-voting: JNI sucks. It was not designed for today's high-loaded applications. JVM sucks for IO, even with its NIO2. It's not portable any more. There is NO JVM for ARM-based platforms. Even Python is more portable. Java is the corporate platform for internal business-related projects (same as .NET is). It is not an universal or even portable platform. The game is over.
- turtle4 17y agoSeems that way, although it was the most thorough that I've seen. What are others? Groovy runs on JVM, Wicket on Wings exists, I believe. What are other Java options?
- fortybillion 17y agoWe've been using Grails (Groovy) at our startup with great success. A few warts early on with regard to how Grails wants to handle packages and URLs, but we push a lot of transactions through this system (sorry, I don't have exact numbers) and Grails has held up remarkably well. It also cut our initial development time by about half.
- mosburger 17y agoStripes is a great framework that promotes the "convention over configuration" mentality, and is quite minimalistic. But it doesn't support any specific ORM out-of-the-box, and doesn't have scripts to autogenerate a lot of stuff, so I'm not sure I'd call it "Rails-like." But it's been one of my favorite Java web frameworks to use.
- thangalin 17y agoMixing code and presentation is a bad idea.
- maheskrishnan 17y agojust copied features from ASP.Net MVC...
- regularfry 17y agoI can assure you that ASP.NET MVC has its share of copied features. And you know what? That's a good thing. Good ideas should be copied and propagated, and mixed in with whatever makes the next platform unique.
- FraaJad 17y agoThe FAQ is an interesting read -- http://www.playframework.org/documentation/1.0/faq http://www.playframework.org/documentation/1.0/faq
- ilyak 17y ago"Provides integration with Hibernate" == "Would be a huge pain in the ass". Otherwise, I'd still either pick JRuby on Rails or go ugly early with idiomatic java.
- kls 17y ago"The Play framework makes it easier to build Web applications with Java" Maybe you should not be building web applications with Java or C# or <insert language of choice>. Maybe you should be building web services with these languages and using AJAX, a client side toolkit, Javscript, HTML and CSS to build a UI that communicates with said services. Maybe this decouples your UI implementation from your business logic implementation so you can go mobile, IVR, Mind Jacking, without having to build the back end again. Maybe server side templating was wrong and a CMS is your best choice for static templating. Given that assembling templates during run-time as opposed to build time seems to be a waste of resources. A CMS can deliver already templated, flat HTML files, to the web server during build time. As well Ajax is your best bet for delivering dynamic information. It sure separates your concerns quite nicely, while allowing each developer to work in their domain of expertise. Just a thought.
- dasil003 17y agoYES! You seem to have gotten a lot of disagreement here, but I know exactly what you're talking about. Someone suggested that this would be bad for scalability, but in fact I was pushed in this direction precisely for scalability purposes. Consider this: Say you have a page that shows basically the same content for everybody, but has a handful of user-specific elements in there. In a typical MVC setup you'll a controller as the gatekeeper with overall knowledge of the request, it will assemble the data needed for the request and pass it to the view. The view may be one template, or it may be comprised of many, including a layout and several sub-templates. In order to fetch all the content efficiently, you want to know everything up front, so there is no n+1 problem or similar. This works pretty well for the gross content of the page, but not nearly so well for the minutiae. Whether a specific piece of data is often not reasonably known until deep inside a nested template. So you have a conundrum, do you make assumptions about or replicate the view logic in your controller in order to efficiently load everything? Or do you suffer the performance penalties of looking things up in an ad-hoc basis within the templates at the point their needed? The answer is simple, you leverage the client. The controller loads the gross content and the templates puts placeholder values for all the other data (classes and maybe some custom attributes). Then you have a javascript library that scrapes up the references to the needed data and requests it directly from the server. This effectively converts your page into a static page that can be served to everybody, cached to your heart's content, etc, and it offloads a good chunk of your processing to client machines which of course by definition scale in constant time. I've done this in Rails using resources and json, and the performance and scalability benefits are amazing. You just need to know how to write good Javascript and be aware of the security concerns. The only thing that's need to make this uber-efficient in Rails is some kind of request bundling so that if you have more than 2 or 3 resource types needed you don't need to send a separate request for each one. To all the doubters, you need to open your mind about this. I'm guessing most of you just don't like Javascript, to which I simply direct you to Douglas Crockford.
- martincmartin 17y agoHow does it compare to Groovy and Grails?
- cschneid 17y agoSide question: is there a CPAN or Gems repository for similar open-source Java libraries? I know that Apache has lots of Java libs, but beyond that, I have no idea where to look.
- fizx 17y agoLook into Maven.
- cschneid 17y agoFrom what I understand, Maven is a build dependency manager, but not a package manager the way CPAN is. I'm looking for a central place to find packages that do everything. "ohh you need to interact with AWS, here's the package" type stuff.
- strlen 17y agoThere's a bunch of maven repositories (usually googling '+"library name" +"maven" +"pom.xml" works), but I haven't yet found anything like CPAN's search website. mvn:create can bring up an interface that's very smilar to CPAN's shell. What needs to be done is a shell that allows functionality such as "search /amazon/" or "search guice, jersey" or "info google-collections". Scala would be a great choice to make sort of a "REPL" shell :-)
- brianm 17y agobest way to find maven repo info for open source java stuff, that I know of, is with http://repository.sonatype.org/ http://repository.sonatype.org/
- mosburger 17y agoHeh - I'm working on building such a monster now. :) Until mine is ready, you can try mvnrepository.com. The reason that I'm building my own is because mvnrepository.com is often down, slow, and is not very easy to use. But it's there until I'm finished with mine!
- robspychala 17y agohttp://m.mlb.com/ http://m.mlb.com/ uses a hybrid Freemarker / Groovy / Java framework called MVC+GF. During the 2009 season it was able to scale with out issues during peak hours (9th innings, etc). That's hundreds of requests a sec a server - pretty cool. Groovy is used cause it has closures (java doesn't) and is simpler and easier than Scala.
- 10ren 17y agoIt reminds me of Sinatra. The HTTP paramater/object binding is similar, for example: http://www.playframework.org/documentation/1.0/5things http://www.playframework.org/documentation/1.0/5things A difference is that the routes, model, controller and template/renderer are in separate directories. It's a bit awkward for the simple project of the one in the video, but essential for more complicated projects. It even includes a captcha generator, and their examples seem to be of real (though very simple) applications - as opposed to toy academic ones. I get the feeling that its developers are very familiar with the real needs and problems of actual web development. It almost makes me want to get into web development! The only thing is that combining HTML, Groovy templating, Javascript and JQuery looks a little complex - but they're probably very straightforward for common tasks.
- deleted 17y ago[deleted]
- mhd 17y agoHmm, too much code in the template library, too much magic in general. I do like the general packacking, the automatic compilation and the snazzy error and testing interfaces. Seems a bit hard to change from their Groovy template system to something like StringTemplate, though.
- guillaume 17y agoAlthough I think that the built-in template system is very very nice, it would be really easy to write a play module that provide any template engine you want.
- mhd 17y agoWell, both systems are basically diametrical opposites. StringTemplates is very strong on MVC separation whereas the play templates feature a fully-fledged programming language. I'll have to dive deeper into play to see how much more I would have to do in the Controller part to prepare the output for the template...
- deleted 17y ago[deleted]
- scotth 17y agoHow does the following work? Must be a preprocessing step, if I'm not mistaken. With play, you can just write: Article article = Article.findById(id); User user = User.getConnected(); render(article, user); And retrieve objects from their Java local name in the template. That saves a lot of useless lines of code...
- guillaume 17y agoYep there is one step of byte code enhancement, during the compilation phase. But as the compilation phase itself it totally transparent, you can't call that a 'preprocessing step'.
- hariharan 17y agoNice collection of web tools. Especially ready made libraries for validation, captcha etc and a built-in template engine. But I am not convinced with 'on the fly' compilation because most editors already do a better job there and refreshing the web page to look for compilation errors does not look productive.
- guillaume 17y agoIf you use a Java IDE you will of course see compilation errors before trying the app in the browser. So it is not a problem.
- beamso 17y agoI just watched the screencast. I'm sure that the static methods on the controllers and the public attributes will drive purists up the wall, but the speed of development appears excellent. Looks most definitely faster than running glassfish in debug mode and reloading classes/redeploying all the time.
- jeduan 17y agoWeird, I had just convinced my boss to use Spring Roo, because of the productivity, and this seems to be more productive