中英文对照 介绍Play Framework 框架 FAQ

lyuehh 发布于 2010/07/14 01:12
阅读 1K+
收藏 3

经常被问到的问题

h1. Frequently Asked Questions

 

Play和其他的框架相比怎么样

How does Play compare to framework X?

 

现在,在开发web应用方面,你有很多的选择。Play作为一个Java Web应用开发框架,让我们和其他Java框架比较一下。

Play的实现为“无共享”架构(也可以认为是无状态框架),所以它和其他有状态和已组件为基础的框架(如Seam, Tapestry or Wicket等)完全不同,它和Spring MVC or Struts (or Struts 2)比较像,但是更加坚定.

 

Nowadays, you have a very large number of choices for developing web applications. Play being a Java web application framework, let’s compare it to other Java frameworks. Play is built for a ‘share nothing’ architecture (think about it as a stateless framework), so it’s very different from all these Java stateful and components based frameworks like Seam, Tapestry or Wicket. It’s closer to Spring MVC or Struts (or Struts 2), but way more opinionated.

 

 

但是Play是一个独一无二的Java框架,它不依赖与所谓的Java企业标准,它使用的是Java,但是它试着把其他基于脚本语言的框架如Ruby On Rails, Django, Pylons, Symfony, Grails and Cake PHP中好的想法带到Java世界中。我们真的试着从Java平台中得到更好的,而不是像传统的Java web开发中那样令人叫苦连连,太多的抽象,太多的配置文件。

 

However Play is a unique Java framework. It does not really rely on the so-called Java Enterprise standards. It uses Java, but tries to bring all the good things from the frameworks based on scripting languages like Ruby On Rails, Django, Pylons, Symfony, Grails and Cake PHP to the Java world. We really tried to get the best out of the Java platform without getting the pain of traditional Java web development: a slow development cycle, too much abstraction and too much configuration.

 

你为什么不把play重命名为‘org.playframework’

Why don’t you rename the ‘play’ package to ‘org.playframework’?!

 

你误解了。Play不是另外一个你需要添加到Servlet容器中的一个类库,它是一个可以独立运行你的应用的全栈式Java框架。

Java的包机制的命名约定是防止你使用不同的类库时的名字冲突。相信我,你永远不需要把‘play.jar’库放到你自己的项目中。那不是Play的运行方式,Play是一个平台,不要担心它。

 

You are missing the point. Play is not another library that you add to your Servlet container. It’s really a full stack Java framework that runs your application stand-alone. The Java package naming conventions exist to avoid name clashes when you use several different libraries from several vendors. But believe us, you will never put the **play.jar** library in your own project. This is not the way Play works. Play **is the platform**. Don’t worry about that.

 

为什么我需要Python(我更喜欢Maven)?

Why do I need Python (I would prefer Maven)?

 

我们需要很多脚本区管理Play的应用,去创建一个项目,运行它,打开浏览器等等,当然我们可以直接用Java写。但是用Java VM去运行像创建一个项目这样简单的任务太慢了,而且Java本身同操作系统交互时有很多的限制。

 

We need a lot of scripts to manage Play applications, for creating a new application, running it, launching a browser, etc… Of course we could write these in Java directly. But running a Java VM for simple tasks like project creation is very slow. And Java itself is very limited when it comes to OS interaction.

 

Python允许我们写这些脚本,而且是完全可移植的,它运行速度很快,很容易编写,可以在大多数的系统上运行,Windows上没有内置的python,所以我们在框架中绑定了一个Windows上的Python二进制发布包。

 

Python allowed us to write these scripts in a completely portable way. It’s fast to run, easy to write and available out of the box on most systems. It’s not on Windows, that’s why we bundle a Windows Python binary with the framework.

 

Play是一个Groovy框架吗?

Is Play a Groovy framework?

 

虽然我们使用Groovy在Play模板系统中作为基本的技术,但是它是绝对透明的。而且,你不能直接在应用的其他任何地方(例如控制器,模型和其他功能中)使用Groovy,如果你在寻找一个基于Groovy的框架,你应该看一下Grails。

 

No. Even though we use Groovy as the base technology for the Play templating system, it’s totally transparent. Also, you can’t directly write any other part of the application (such as controllers, models or other utilities) in Groovy. If you’re looking for a Groovy based framework you should have a look at Grails.

 

你们这些家伙甚至不知道怎么用Java写程序。

You guys don’t even know how to program in Java...

 

我们充分的认识到了我们在Java世界中做了非常不寻常的选择,而且Play盲目的追随那些所谓的Java“最佳实践”。

但是所有的Play小组成员都是非常有经验的Java开发者,而且我们非常了解我们所做的选择和打破的规则。

 

We are fully aware that we made choices that are pretty uncommon in the Java world, and that Play does not blindly follow all the so-called Java ‘good practices’. But all of the Play team members are very experienced Java developers and we are totally aware of the choices we made and the rules we broke.

 

Java本身是一个非常通用的编程语言,而且不是原生为web应用开发所设计的。去写一个通用的和可重用的库与创建一个web应用是非常不同的。一个web应用本身不需要去设计成可重用的,你需要更少的抽象,更少的配置。可重用存在在web应用中,但是是通过web service APIs,而不是语言方面的集成。

 

Java itself is a very generic programming language and not originally designed for web application development. It is a very different thing to write a generic and reusable Java library and to create a web application. A web application itself doesn’t need to be designed to be reusable. You need less abstraction, less configuration. Reusability does exist for web applications, but through web service APIs rather than language-level integration.

 

当开发实践趋近于零,你就可以把中心放到应用的功能模块上,然后快速的实验,而不是去把功能开发抽象化。

 

When the development time tends to zero you can concentrate on your application features and experiment quickly, instead of trying to abstract things for future developments.

 

Play速度快吗?

Is Play fast?

 

是的,Play本身很快。但是不意味着任何特殊的应用都很快。嵌入的HTTP服务器,基础的路由和控制器调用堆栈都非常非常快。使用现代的JVM和即时编译技术你可以很容易处理每秒钟上千次请求。不幸的是,如果你的应用使用了数据库,那么那将像通常那样成为瓶颈。

 

Yes, Play itself is fast. But that doesn’t mean that any particular application will be fast. The embedded HTTP server, the basic routing and the controller invocation stack are very very fast. Used with a modern JVM and Just In Time compiling you can easily get thousands of requests per second. Unfortunately, your application will likely use a database, which will become the bottleneck as usual.

 

在Play的堆栈中最占内存的是基于Groovy的模板引擎,但是play的应用时可以很容易扩展的,它并不是一个真正的问题,如果你需要很高的并发量,可以在多个服务器中做负载均衡。我们希望在新的JDK7中得到性能提升,因为它对动态语言有更好的支持。

 

The biggest CPU consumer in the Play stack at the moment is the Groovy-based template engine. But as Play applications are easily scalable, it is not really a problem if you need to handle very high traffic: you can balance the load between several servers. We also hope for a performance gain at this level with the new JDK7 and its better support for dynamic languages.

 

我可以把Play用于生产环境中吗?

Can I already use Play for a production application?

 

可以,已经有很多人http://www.playframework.org/community/testimonials 把PLay用于生产环境中去了,现在的1.0分支是一个维护分支,

意味着我们只是BUG修改和保持API兼容。

 

Sure, "a lot of people":http://www.playframework.org/community/testimonials already use Play in production. The 1.0 branch is now in maintenance mode, which means that we will just fix bugs and keep API compatibility in that branch.

 

其他的类库Play支持吗?

Is library X supported?

 

Play使用的是标准的Java,意味着任何基于标准Java的类库都可以很容易的被使用,但是一定要记得Play没有使用 Servlet API(虽然你可以用WAR包导出功能,让它在标准的Servlet容器中工作),所以除非你需要的类库中使用了Servlet API,否则它不会有任何问题。

 

Play is standard Java, so any standard Java library can easily be used. However keep in mind that Play does not use the Servlet API (although you can get it work in a standard Servlet container using the WAR export feature). So unless the library you want to use relies on the Servlet API, there won’t be any problem.

 

我怎么帮助你们或者怎样参与贡献

How can I help/contribute?

 

我们使用“launchpad”:https://launchpad.net作为我们主要的开发工具,launchpad本身是非常开放的,你只需要注册一个launchpad账号,然后就可以参与贡献了。你可以为自己分配任何一发现的BUG,将Play的官方分支和自己的分支交叉,或者在你修改了一些的时候提议和官方分支合并。

We use "launchpad":https://launchpad.net/ as our main development tool, and launchpad itself is very open. You can just register a launchpad account and start to contribute. You can assign any open bug to yourself, fork any Play official branch to your own branch, and propose a merge to us if you have fixed something.

 

文档本身是在Play的源码库中,保持"Textile":http://en.wikipedia.org/wiki/Textile_格式,所以你可以编辑他们就像对待代码一样。

The documentation itself is kept as "Textile":http://en.wikipedia.org/wiki/Textile_(markup_language%29 files in the framework source repository, so you can edit it and contribute just as you can with code.

 

翻译很累人啊.

 

加载中
0
红薯
红薯

楼主是一个积极响应翻译Play文档提议的会员:)

辛苦了

0
Turbidsoul
Turbidsoul

汗! 最近oschina上好多play的文章阿!

0
l
lyuehh

最近很闲,就顺便翻译一下。多了解一些技术,同大家一起进步。

0
iwork.f3
iwork.f3

最近很闲,就顺便翻译一下。多了解一些技术,同大家一起进步。

0
iwork.f3
iwork.f3

最近很闲,就顺便翻译一下。多了解一些技术,同大家一起进步。

0
iwork.f3
iwork.f3

window.alert(1)最近很闲,就顺便翻译一下。多了解一些技术,同大家一起进步。

0
iwork.f3
iwork.f3

最近很闲,就顺便翻译一下。多了解一些技术,同大家一起进步。

0
Kevin.
Kevin.

非常受用,感谢您的翻译。

返回顶部
顶部