在Jython上开发Django有问题吗?

时间:2022-09-19 07:28:25

The background

的背景

I'm building a fair-sized web application with a friend in my own time, and we've decided to go with the Django framework on Python. Django provides us with a lot of features we're going to need, so please don't suggest alternative frameworks.

我正在和我的朋友一起构建一个公平的Web应用程序,我们决定在Python上使用Django框架。 Django为我们提供了许多我们需要的功能,所以请不要建议其他框架。

The only decision I'm having trouble with, is whether we use Python or Jython to develop our application. Now I'm pretty familiar with Java and could possibly benefit from the libraries within the JDK. I know minimal Python, but am using this project as an opportunity to learn a new language - so the majority of work will be written in Python.

我遇到的唯一决定是,我们是使用Python还是Jython来开发我们的应用程序。现在我对Java很熟悉,可能会受益于JDK中的库。我知道最小的Python,但是我使用这个项目作为学习新语言的机会 - 所以大多数工作都是用Python编写的。

The attractiveness of Jython is of course the JVM. The number of python/django enabled web-hosts is extremely minimal - whereas I'm assuming I could drop a jython/django application on a huge variety of hosts. This isn't a massive design decision, but still one I think needs to be decided. I'd really prefer jython over python for the jvm accessibility alone.

Jython的吸引力当然是JVM。启用python / django的web主机的数量极少 - 而我假设我可以在各种主机上删除jython / django应用程序。这不是一个巨大的设计决定,但我认为仍然需要决定。我真的更喜欢仅仅jvm可访问性的jython而不是python。

Questions

问题

Does Jython have many limitations compared to regular python? Will running django on jython cause problems? How quick is the Jython team to release updates alongside Python? Will Django work as advertised on Jython (with very minimal pre-configuration)?

与常规python相比,Jython有许多限制吗?在jython上运行django会导致问题吗? Jython团队与Python一起发布更新的速度有多快? Django会像Jython上的广告那样工作(预配置非常少)吗?

Decision

决策

Thanks for the helpful comments. What I think I'm going to do is develop in Jython for the JVM support - but to try to only use Python code/libraries. Portability isn't a major concern so if I need a library in the JDK (not readily available in python), I'll use it. As long as Django is fully supported, I'm happy.

感谢您提供的有用评论。我认为我要做的是在Jython中开发JVM支持 - 但是尝试只使用Python代码/库。可移植性不是主要问题,因此如果我需要JDK中的库(python中不易提供),我将使用它。只要Django得到全面支持,我很高兴。

4 个解决方案

#1


3  

Django does work on Jython, although you'll need to use the development release of Jython, since technically Jython 2.5 is still in beta. However, Django 1.0 and up should work unmodified.

Django确实在Jython上工作,虽然你需要使用Jython的开发版本,因为技术上Jython 2.5仍处于测试阶段。但是,Django 1.0及以上应该可以不加修改地工作。

So as to whether you should use the regular Python implementation or Jython, I'd say it's a matter of whether you prefer having all the Java libraries available or all of the Python libraries. At this point you can expect almost everything in the Python standard library to work with Jython, but there are still plenty of third-party packages which will not work, especially C extension modules. I'd personally recommend going with regular Python, but if you've got a ton of JVM experience and want to stick with what you know, then I can respect that.

至于你是否应该使用常规的Python实现或Jython,我想说的是你是否更喜欢可用的所有Java库或所有的Python库。此时,您可以预期Python标准库中的几乎所有内容都可以与Jython一起使用,但仍有大量第三方软件包无法使用,尤其是C扩展模块。我个人建议使用普通的Python,但是如果你有大量的JVM经验并且想要坚持你所知道的,那么我可以尊重它。

As for finding Python hosting, this page might be helpful.

至于查找Python托管,此页面可能会有所帮助。

#2


3  

I'd say that if you like Django, you'll also like Python. Don't make the (far too common) mistake of mixing past language's experience while you learn a new one. Only after mastering Python, you'll have the experience to judge if a hybrid language is better than either one.

我想如果你喜欢Django,你也会喜欢Python。在学习新语言时,不要混淆过去语言的经验(太常见)。只有掌握了Python之后,您才有经验判断混合语言是否优于任何一种。

It's true that very few cheap hostings offer Django preinstalled; but it's quite probable that that will change, given that it's the most similar environment to Google's app engine. (and most GAE projects can be made to run on Django)

确实很少有便宜的主机提供Django预装;但鉴于它与谷歌的应用程序引擎最相似的环境,这很可能会发生变化。 (大多数GAE项目都可以在Django上运行)

#3


1  

I have recently started working on an open source desktop project in my spare time. So this may not apply. I came to the same the question. I decided that I should write as much of the code as possible in python (and Django) and target all the platforms CPython, Jython, and IronPython.

我最近在业余时间开始研究开源桌面项目。所以这可能不适用。我提出了同样的问题。我决定在python(和Django)中编写尽可能多的代码并定位所有平台CPython,Jython和IronPython。

Then, I decided that I would write plugins that would interface with libraries on different implementations (for example, different GUI libraries).

然后,我决定编写可以与不同实现的库接口的插件(例如,不同的GUI库)。

Why? I decided early on that longevity of my code may depend on targeting not only CPython but also virtual machines. For today's purposes CPython is the way to go because of speed, but who knows about tomorrow. If you code is flexible enough, you may not have to decide on targeting one.

为什么?我很早就决定,我的代码的寿命可能不仅取决于CPython而且还取决于虚拟机。为了今天的目的,CPython是因为速度而走的路,但谁知道明天。如果您的代码足够灵活,您可能不必决定定位代码。

The downside to this approach is that you will have more code to create and maintain.

这种方法的缺点是你将有更多的代码来创建和维护。

#4


0  

Django is supposed to be jython-compatible sinc version 1.0.

Django应该是jython兼容的sinc版本1.0。

This tutorial is a bit outdated, but from there you can see there are no special issues.

本教程有点过时,但从那里你可以看到没有特殊问题。

#1


3  

Django does work on Jython, although you'll need to use the development release of Jython, since technically Jython 2.5 is still in beta. However, Django 1.0 and up should work unmodified.

Django确实在Jython上工作,虽然你需要使用Jython的开发版本,因为技术上Jython 2.5仍处于测试阶段。但是,Django 1.0及以上应该可以不加修改地工作。

So as to whether you should use the regular Python implementation or Jython, I'd say it's a matter of whether you prefer having all the Java libraries available or all of the Python libraries. At this point you can expect almost everything in the Python standard library to work with Jython, but there are still plenty of third-party packages which will not work, especially C extension modules. I'd personally recommend going with regular Python, but if you've got a ton of JVM experience and want to stick with what you know, then I can respect that.

至于你是否应该使用常规的Python实现或Jython,我想说的是你是否更喜欢可用的所有Java库或所有的Python库。此时,您可以预期Python标准库中的几乎所有内容都可以与Jython一起使用,但仍有大量第三方软件包无法使用,尤其是C扩展模块。我个人建议使用普通的Python,但是如果你有大量的JVM经验并且想要坚持你所知道的,那么我可以尊重它。

As for finding Python hosting, this page might be helpful.

至于查找Python托管,此页面可能会有所帮助。

#2


3  

I'd say that if you like Django, you'll also like Python. Don't make the (far too common) mistake of mixing past language's experience while you learn a new one. Only after mastering Python, you'll have the experience to judge if a hybrid language is better than either one.

我想如果你喜欢Django,你也会喜欢Python。在学习新语言时,不要混淆过去语言的经验(太常见)。只有掌握了Python之后,您才有经验判断混合语言是否优于任何一种。

It's true that very few cheap hostings offer Django preinstalled; but it's quite probable that that will change, given that it's the most similar environment to Google's app engine. (and most GAE projects can be made to run on Django)

确实很少有便宜的主机提供Django预装;但鉴于它与谷歌的应用程序引擎最相似的环境,这很可能会发生变化。 (大多数GAE项目都可以在Django上运行)

#3


1  

I have recently started working on an open source desktop project in my spare time. So this may not apply. I came to the same the question. I decided that I should write as much of the code as possible in python (and Django) and target all the platforms CPython, Jython, and IronPython.

我最近在业余时间开始研究开源桌面项目。所以这可能不适用。我提出了同样的问题。我决定在python(和Django)中编写尽可能多的代码并定位所有平台CPython,Jython和IronPython。

Then, I decided that I would write plugins that would interface with libraries on different implementations (for example, different GUI libraries).

然后,我决定编写可以与不同实现的库接口的插件(例如,不同的GUI库)。

Why? I decided early on that longevity of my code may depend on targeting not only CPython but also virtual machines. For today's purposes CPython is the way to go because of speed, but who knows about tomorrow. If you code is flexible enough, you may not have to decide on targeting one.

为什么?我很早就决定,我的代码的寿命可能不仅取决于CPython而且还取决于虚拟机。为了今天的目的,CPython是因为速度而走的路,但谁知道明天。如果您的代码足够灵活,您可能不必决定定位代码。

The downside to this approach is that you will have more code to create and maintain.

这种方法的缺点是你将有更多的代码来创建和维护。

#4


0  

Django is supposed to be jython-compatible sinc version 1.0.

Django应该是jython兼容的sinc版本1.0。

This tutorial is a bit outdated, but from there you can see there are no special issues.

本教程有点过时,但从那里你可以看到没有特殊问题。