java Playframework 和 Django
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1706146/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Playframework and Django
提问by n002213f
I have worked with Djangobefore and have recently seenthe Play framework.
Is this the Java community's answer to Django? Any experiences with it? Any performance comparisons with other Java web frameworks?
这是 Java 社区对 Django 的回答吗?有什么经验吗?与其他 Java Web 框架的任何性能比较?
Edit:Almost similar to this question, the responses, unfortunately don't say much about the framework.
编辑:与此问题几乎相似,答案很遗憾,对框架没有太多说明。
回答by Ryan Christensen
Play! is a breath of fresh air into Java and bypasses all the Enterprise cruft that has evolved over the years. Even the namespace is just play not com.playframework. It is supposed to be an answer to Rails, Django etc and is MVC based. It is needed for Java to stay relevant in all but deep entrenched enterprise shops.
玩!为 Java 注入了一股新鲜空气,绕过了多年来演变的所有企业产品。甚至命名空间也只是 play 而不是 com.playframework。它应该是 Rails、Django 等的答案,并且是基于 MVC 的。Java 需要在所有根深蒂固的企业商店中保持相关性。
Play! reduces the overabstraction and painful configuration of old Java. It is a complete stack it does not rely or play to the old Servlet/EJB methodology like Restlet tried to do (making REST easier in Servlets). Play! is a great REST based Java framework that is a valid contender to other platforms MVC frameworks.
玩!减少旧Java的过度抽象和痛苦的配置。它是一个完整的堆栈,它不依赖或使用旧的 Servlet/EJB 方法,如 Restlet 试图做的(使 REST 在 Servlets 中更容易)。玩!是一个很棒的基于 REST 的 Java 框架,它是其他平台 MVC 框架的有效竞争者。
It is very RESTful and it is easy to bind a parameter to a java method. They have also made JPA much easier to use through their play namespace.
它非常 RESTful,并且很容易将参数绑定到 java 方法。他们还通过播放命名空间使 JPA 更易于使用。
play.db.jpa.Model
play.db.jpa.Model
public void messages(int page) {
User connectedUser = User.find("byEmail", connected());
List<Message> messages = Message.find(
"user = ? and read = false order by date desc",
connectedUser
).from(page * 10).fetch(10);
render(connectedUser, messages);
}
Python is used for scripting instead of builds with Maven which might save a few lives.
Python 用于编写脚本而不是使用 Maven 进行构建,这可能会挽救一些生命。
I haven't been this excited about a Java framework since Red5 or Restlet. A bonus is they have easy ways to get your app up on Google AppEngine as well using the Java version of GAE.
自 Red5 或 Restlet 以来,我对 Java 框架从未如此兴奋。一个额外的好处是他们有简单的方法可以使用 Java 版本的 GAE 在 Google AppEngine 上安装您的应用程序。
回答by n002213f
I have been using Play! now for a few months and in fact have come to love the framework. I struggled with Rails and Django a bit, mostly because I am really not a fan of dynamically-typed languages; however, there was never a really good web development framework for Java to compete with these. In terms of productivity, Rails and Django were the leaders for the MVC arms race that was going on. Play! is awesome, it's concise, scalable, powerful, and it has a great community that is growing all the time. If you're still really into using a language like a Python or Ruby, you can use Play! with Scala too. I am really trying to get into Scala right now because I think it has a great future and it's a lot of fun to use. Anyway, I would recommend giving it a try!
我一直在使用 Play!现在几个月了,实际上已经爱上了这个框架。我在使用 Rails 和 Django 时遇到了一些困难,主要是因为我真的不喜欢动态类型语言;然而,从来没有一个真正好的 Java 网络开发框架可以与这些框架竞争。在生产力方面,Rails 和 Django 是正在进行的 MVC 军备竞赛的领导者。玩!很棒,它简洁、可扩展、功能强大,并且拥有一个一直在增长的伟大社区。如果您仍然非常喜欢使用 Python 或 Ruby 等语言,则可以使用 Play!Scala 也是。我现在真的很想进入 Scala,因为我认为它有一个美好的未来,而且使用起来很有趣。无论如何,我会建议尝试一下!
回答by Lastnico
The Play! framework is a really good piece of software, and that the JavaEE bloated environment should be inspired from.
表演!框架是一个非常好的软件,JavaEE 臃肿的环境应该受到启发。
I moved from Java -> Django because of the fast cycle "modify file" / "reload browser", and the Play! framework makes me came back to my favorite Java language.
由于“修改文件”/“重新加载浏览器”的快速循环和 Play! 框架让我又回到了我最喜欢的 Java 语言。
It could also be compared in some terms to what Grails and in general dynamic languages in Java (Groovy is used in Play!) are trying to import: simplicity, speed and reliability.
在某些方面,它也可以与 Grails 和 Java 中的一般动态语言(在 Play 中使用 Groovy!)试图导入的内容进行比较:简单性、速度和可靠性。
回答by koko
I am also a Django user. I've just visited the Play framework and skim thorugh its documentation. It has the simplistic design Django has been known of. It even has app engine support built-in. I'm sure many java developers will support it, and it only need some time to see cool plugins from the community.
我也是 Django 用户。我刚刚访问了 Play 框架并浏览了它的文档。它具有 Django 众所周知的简单设计。它甚至内置了应用引擎支持。我相信很多java开发者都会支持它,而且只需要一些时间就能看到来自社区的很酷的插件。
回答by KVISH
We recently started using Play for building a webservice for various mobile applications. I come from a Java environment. I can tell you that the learning curve isn't all that steep--literally in an hour I had the webservice running with basic API already. One week later we were on Amazon Web Services. I definitely see a future for Play as it simplifies web development for Java developers.
我们最近开始使用 Play 为各种移动应用程序构建网络服务。我来自 Java 环境。我可以告诉你,学习曲线并不是那么陡峭——实际上在一小时内我就已经使用基本 API 运行了 web 服务。一周后,我们使用了 Amazon Web Services。我绝对看到了 Play 的未来,因为它简化了 Java 开发人员的 Web 开发。
Couple of things that I noticed however (asset versioning, etc.) still are not built into the framework, but i'm sure they'll be there in time. I would say it is definitely worth a shot using Play.
然而,我注意到的一些事情(资产版本控制等)仍然没有内置到框架中,但我相信它们会及时出现。我会说使用 Play 绝对值得一试。
回答by berardino
I come from a very strong java background. So my answer here could be a little biased.
我来自非常强大的 Java 背景。所以我在这里的回答可能有点偏颇。
Play finally brings to the java community what django has been for all these years in the python community, but just a way better. Play is built on the jvm therefore inheritance all the goodies from a solid platform that has been proving over the years to be the most reliable and scalable one that allows to write and run applications at scale.
Play 终于为 Java 社区带来了 Django 多年来在 Python 社区中的地位,但只是一种更好的方式。Play 建立在 jvm 上,因此继承了一个可靠平台的所有优点,多年来该平台已被证明是最可靠和可扩展的平台,允许大规模编写和运行应用程序。
I want to say that I did try django. Its popularity among the web community made me curios and I wanted to give it a try.
我想说我确实尝试过 django。它在网络社区中的流行让我非常好奇,我想试一试。
Strangely I did not find it as easy to use as I had expected. So many configurations. Too may libraries doing the same thing and often not play very well with each other. A way too much magic. Furthermore, not having type safety makes very hard to manage and maintain web application at big scale. Don't get me wrong, I am pretty sure that people managed to do it, but in my experience I still find java/scala best suited for this, especially when you share the code base with a lot of other developers.
奇怪的是,我发现它并没有我预期的那么容易使用。这么多配置。图书馆也可能做同样的事情,但彼此之间往往不能很好地发挥作用。太神奇了。此外,没有类型安全使得大规模管理和维护 Web 应用程序变得非常困难。不要误会我的意思,我很确定人们设法做到了,但根据我的经验,我仍然发现 java/scala 最适合于此,尤其是当您与许多其他开发人员共享代码库时。
IDE support for Java it is unbeatable. If you implement TDD you will find yourself refactoring code and moving things around on the daily basis. And java IDEs give you all this power. With type safety and more.
IDE 对 Java 的支持是无与伦比的。如果您实施 TDD,您会发现自己每天都在重构代码并移动事物。Java IDE 为您提供了所有这些功能。具有类型安全性等等。
My take away is that as long as you find yourself writing a simple CRUD application/prototype/toy without even thinking too much of advanced features and big scale then you can probably find some advantages on using python/django. Otherwise the whole java ecosystem wins hands down. And play is the cherry on top.
我的结论是,只要您发现自己编写了一个简单的 CRUD 应用程序/原型/玩具,甚至没有考虑太多高级功能和大规模,那么您可能会发现使用 python/django 的一些优势。否则,整个 Java 生态系统就会获胜。玩是最重要的。

