在Google App Engine上选择Java vs Python [英] Choosing Java vs Python on Google App Engine

查看:78
本文介绍了在Google App Engine上选择Java vs Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前Google App Engine支持Python& Java的。 Java支持不太成熟。但是,Java似乎拥有更长的库列表,特别是对Java字节码的支持,无论用于编写该代码的语言如何。哪种语言会提供更好的性能和更强大的功能?请指教。感谢您!



编辑:
http://groups.google.com/group/google-appengine-java/web/will- it-play-in-app-engine?pli = 1



编辑:
通过powerI意味着更好的可扩展性以及框架外可用库的包含。不过,Python只允许使用纯Python库。

解决方案

我有点偏执(作为一名Python专家,但在Java中很生疏),但我认为GAE的Python运行时现在比Java运行时更先进和更完善 - 前者多有一年可以开发和成熟。毕竟。

事情会如何继续前进当然很难预测 - 在Java方面需求可能更强(尤其是因为它不仅仅是Java,而且其他语言也在JVM之上),所以它是运行的方式,例如PHP或App Engine上的Ruby代码);但是Python App Engine团队的确拥有Python的发明者Guido van Rossum和一位令人惊叹的强大工程师的优势。

就灵活性而言,Java如前所述,引擎确实提供了运行不同语言(而不仅仅是Java)的JVM字节码的可能性 - 如果你在一个多语言的商店中,这是一个非常大的积极因素。反之亦然,如果您讨厌Javascript但必须在用户的浏览器中执行一些代码,那么Java的GWT(为您从Java级代码生成Javascript)比Python方法更丰富和更先进(实际上,如果您选择Python,为此你将自己编写一些JS,而如果你选择Java GWT是一种可用的替代方法,如果你不喜欢写JS的话)。

它几乎是一种洗涤 - JVM受到足够的限制(没有线程,没有自定义类加载器,没有JNI,没有关系数据库)阻碍现有Java库的简单重用,甚至比现有Python库同样受到阻碍通过对Python运行时的类似限制。



就性能而言,我认为这是一种洗涤,尽管您应该对自己的任务进行基准测试 - 不要依赖关于高度优化的基于JIT的JVM实现的性能,折扣他们的大启动时间和内存占用,b因为应用程序引擎环境是非常不同的(启动成本将经常支付,因为您的应用程序的实例开始,停止,移动到不同的主机等等,所有东西都是透明的 - 对于Python运行时环境来说,这样的事件通常比使用更便宜与JVMs)。



XPath / XSLT情况(是委婉的......)在两边并不完美,感叹,虽然我认为它可能是一个点在JVM中不那么糟糕(显然,撒克逊的大部分子集可以运行,但需要注意)。我认为值得在 Appengine问题页面上打开问题,其中包含XPath和XSLT标题 - 现在只有问题需要特定的库,这是近视:我并不在乎如何实现一个好的XPath / XSLT,对于Python和/或Java,只要我可以使用它。 (特定的库可以简化现有代码的迁移,但这不像执行诸如以某种方式快速应用XSLT转换这样的任务重要!)。我知道我会在出现这样的问题时出现这样的问题(特别是以一种与语言无关的方式)。

最后但并非最不重要的一点是:请记住,您可以拥有不同版本的您的应用程序(使用相同的数据存储),其中一些使用Python运行时实现,一些使用Java运行时,您可以访问与默认/活动不同的显式URL版本。因此,您可以同时使用和修改相同的数据存储,使Python(em>和)Java代码(在您的应用的不同版本中)具有更大的灵活性(尽管只有一个具有漂亮 foob​​ar.appspot.com - 这可能仅对交互式用户访问浏览器很重要,我想; - )。


Currently Google App Engine supports both Python & Java. Java support is less mature. However, Java seems to have a longer list of libraries and especially support for Java bytecode regardless of the languages used to write that code. Which language will give better performance and more power? Please advise. Thank you!

Edit: http://groups.google.com/group/google-appengine-java/web/will-it-play-in-app-engine?pli=1

Edit: By "power" I mean better expandability and inclusion of available libraries outside the framework. Python allows only pure Python libraries, though.

解决方案

I'm biased (being a Python expert but pretty rusty in Java) but I think the Python runtime of GAE is currently more advanced and better developed than the Java runtime -- the former has had one extra year to develop and mature, after all.

How things will proceed going forward is of course hard to predict -- demand is probably stronger on the Java side (especially since it's not just about Java, but other languages perched on top of the JVM too, so it's THE way to run e.g. PHP or Ruby code on App Engine); the Python App Engine team however does have the advantage of having on board Guido van Rossum, the inventor of Python and an amazingly strong engineer.

In terms of flexibility, the Java engine, as already mentioned, does offer the possibility of running JVM bytecode made by different languages, not just Java -- if you're in a multi-language shop that's a pretty large positive. Vice versa, if you loathe Javascript but must execute some code in the user's browser, Java's GWT (generating the Javascript for you from your Java-level coding) is far richer and more advanced than Python-side alternatives (in practice, if you choose Python, you'll be writing some JS yourself for this purpose, while if you choose Java GWT is a usable alternative if you loathe writing JS).

In terms of libraries it's pretty much a wash -- the JVM is restricted enough (no threads, no custom class loaders, no JNI, no relational DB) to hamper the simple reuse of existing Java libraries as much, or more, than existing Python libraries are similarly hampered by the similar restrictions on the Python runtime.

In terms of performance, I think it's a wash, though you should benchmark on tasks of your own -- don't rely on the performance of highly optimized JIT-based JVM implementations discounting their large startup times and memory footprints, because the app engine environment is very different (startup costs will be paid often, as instances of your app are started, stopped, moved to different hosts, etc, all trasparently to you -- such events are typically much cheaper with Python runtime environments than with JVMs).

The XPath/XSLT situation (to be euphemistic...) is not exactly perfect on either side, sigh, though I think it may be a tad less bad in the JVM (where, apparently, substantial subsets of Saxon can be made to run, with some care). I think it's worth opening issues on the Appengine Issues page with XPath and XSLT in their titles -- right now there are only issues asking for specific libraries, and that's myopic: I don't really care HOW a good XPath/XSLT is implemented, for Python and/or for Java, as long as I get to use it. (Specific libraries may ease migration of existing code, but that's less important than being able to perform such tasks as "rapidly apply XSLT transformation" in SOME way!-). I know I'd star such an issue if well phrased (especially in a language-independent way).

Last but not least: remember that you can have different version of your app (using the same datastore) some of which are implemented with the Python runtime, some with the Java runtime, and you can access versions that differ from the "default/active" one with explicit URLs. So you could have both Python and Java code (in different versions of your app) use and modify the same data store, granting you even more flexibility (though only one will have the "nice" URL such as foobar.appspot.com -- which is probably important only for access by interactive users on browsers, I imagine;-).

这篇关于在Google App Engine上选择Java vs Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆