Jython 可以取代 Java 吗?

发布于 2024-07-16 10:01:28 字数 1432 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

暖心男生 2024-07-23 10:01:28

不,Jython 不是 Java 的合适替代品。 例如,如果不在 Java 中编写接口,然后在 Jython 中编写利用该接口的类,它就无法提供实现接口的方法。

我们需要的是一个面向 JVM 的 Boo 等价物。 Boo 是一种针对 .NET CLR 的语言,大致受 Python 启发但不兼容,并且完全公开了 CLR 的功能(因此与 C# 功能等效)。 目前还没有一种Pythonic 语言具有与Java 相同的功能——而且这种语言必然与Python 不兼容,因为Python 根本不提供表达某些相关概念(例如接口类型信息)的方法。


由于对此存在一些疑问,但我澄清一下:

Jython 并不是 Java 的替代品,因为您不能采用任意 Java 项目,决定在 Jython 中实现该项目的随机子集,而不是开发团队中的其他人都知道或关心。 当然,Jython 适合许多与 Java 相同的项目类,除非您正在构建将从 Java 调用的接口,而不是相反。 由于“企业应用程序”往往有许多彼此紧密操作的组件,因此能够构建具有任意外部接口的类非常重要……并且在纯 Jython 中不容易完成。

No, Jython is not a suitable replacement for Java. Consider, for instance, that it provides no way to implement interfaces without writing the interface in Java and then writing a class leveraging it in Jython.

What's needed is a JVM-targeted equivalent to Boo. Boo is a language targeting the .NET CLR which is roughly inspired by Python but not compatible, and which fully exposes the CLR's functionality (thus being feature-equivalent with C#). There presently is no Pythonic language with feature parity with Java -- and such a language would necessarily be incompatible with Python, as Python simply doesn't provide a way to express some of the relevant concepts (such as interface typing information).


Since there have been some questions about this, yet me clarify:

Jython is not a replacement for Java in the sense that you can't take an arbitrary Java project, decide to implement a random subset of that project in Jython instead, and not have anyone else on the development team know or care. Certainly, Jython is suitable for many of the same classes of projects that Java is, except when you're building an interface which will be called from Java, rather than the reverse. Given as "enterprise applications" tend to have a lot of components which operate closely with each other, being able to build a class with an arbitrary external interface is important... and is something which isn't readily done in pure Jython.

黎夕旧梦 2024-07-23 10:01:28

这很大程度上取决于您的要求。 所有语言都有其优点和缺点。 没有完美的语言,对语言选择做出明智的决定是程序员的一项重要技能。

我不同意 Charles 的观点,即 Jython 无法取代 Java,因为你无法实现接口。 在动态语言中,它被视为不需要接口的功能(请参阅鸭子类型)。

Jython 继承了 Python 的强大语言特性,并将其与对大量 Java 库的轻松访问相结合。 然而,它确实有开销方面的代价,并且作为一种相当新的语言,您的程序员和支持人员较少。

Jython 的好处是,如果性能有问题,您可以用 Java 重写各个模块。 在可以通过硬件解决问题的服务器上,速度问题不太明显。 在移动电话上,性能仍然是关键,我看不到 Jython 在不久的将来会产生重大影响。

那么 Jython 会取代 Java 吗? 不,我不认为会——Java 背后的动力太大了。 但我们将看到越来越多的软件包含用 Jython 和其他针对 JVM 的语言编写的部分。

It depends largely what your requirements are. All languages have their strengths and weaknesses. There is no perfect language and making intelligent decisions about language choice is an important skill for a programmer.

I disagree with Charles that Jython can't replace Java because you can't implement Interfaces. In dynamic languages, it's seen as a feature that you don't need Interfaces (see duck typing).

Jython takes the great language features of Python and combines it with easy access to huge collection of Java libraries. However it does have a price in terms of overhead, and being a fairly new language you have less programmers and support to back you up.

The nice thing about Jython is that you can rewrite individual modules in Java if performance is a problem. The speed issue is less notable on servers where you can throw hardware at the problem. On mobile phones, performance is still key and I can't see Jython making a big impact there in the near future.

So will Jython replace Java? No, I don't think it will - the momentum behind Java is too great. But we will see increasingly more software with parts written in Jython and other languages targeting the JVM.

夜声 2024-07-23 10:01:28

不,Jython 无法取代 Java,因为 Python 是动态类型的。 是的,Jython 可用于服务器应用程序。

Jython 不适合 Java ME,因为 Java ME 的资源非常有限。 也许几年后。

编辑:动态类型,而不是弱类型

No, Jython cannot replace Java, because Python is dynamically typed. Yes, Jython can be used for server applications.

Jython is not good for Java ME, because Java ME has very limited resources. Maybe several years later.

Edit: dynamically typed, not weakly

偷得浮生 2024-07-23 10:01:28

是的。 动态语言是未来。 大约一年前,我从 SUN 代表那里听到了这一点。 Jython 令人惊奇的部分是 Java 库的“本机”使用。
服务和其他组件可能仍保留在 Java 中,但集成层肯定会向动态语言方向发展。
我认为 Python 与 Java 一样本质上是面向对象的,这就是它们如此匹配的原因。
我不希望 Perl 等其他脚本语言有类似的功能,但 Ruby 和 Groovy 肯定也是不错的选择。

Yes. The Dynamic languages are the future. I heard this from SUN representatives about one yar ago. The amazing part about Jython is "native" usage of java libraries.
Services and other components may remain in Java but integration layer will move for sure in the dynamic languages direction.
I think Python is natively object oriented like Java that's why they match so good.
I don't expect something like that from other scripting languages like Perl but for sure Ruby and Groovy are also good alternatives.

九公里浅绿 2024-07-23 10:01:28

您可以将 Jython 用于该域。
显然,Web 开发领域正在转向 Python 或 Ruby 等动态类型语言。 Jython 在这个领域很出色,因为它允许在企业中使用完整的“Java 堆栈”(应用程序服务器、Tomcat、部署和测试基础设施,...)。 您还可以用 Java 实现业务逻辑。

然而,Jython 并不是 Java 的替代品,因为它是 C#。 您(可能)会提高程序员的工作效率,但会失去性能和编译时间检查。 这些语言确实不同,并且针对不同的任务进行了“优化”。 我建议针对较小的非关键任务评估 Jython,例如开始在其中实现一些测试用例。

我怀疑 Jython 对于 Java ME 开发是否有用。 其他帖子中给出了原因:资源限制。

You can use Jython for that domains.
Obviously, the world for web development is moving towards dynamically typed languages as Python or Ruby. Jython is nice in this domain, since it allows to use the complete "Java stack" (App server, Tomcat, deployment and testing infrastructure,...) in enterprises. You can also implement your business logic in Java.

However, Jython is not a replacement for Java as it is C#. You (may) gain programmer productivity, but you lose performance and compile time checks. The languages are really different and are "optimized" for different tasks. I would propose to evaluate Jython for smaller, non-critical tasks, e.g. by starting to implement some test cases in it.

I doubt that Jython is useful for Java ME development. The reasons are given in the other posts: Resource constraints.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文