Java 是开发跨平台 GUI 应用程序的最佳语言吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/389051/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 14:07:44  来源:igfitidea点击:

Is Java the best language to develop cross-platform GUI applications?

javauser-interfacedesktop-application

提问by

For "best" I intend that the code shouldn't need, or need very few, platform specific tweaks.

对于“最佳”,我打算代码不需要或只需要很少的平台特定调整。

回答by Howler

I would think that it depends on what kind of platforms you plan on targeting. Java will have the most platforms with a VM. However, if you just want to use Windows and Linux, you can use C# (using mono on linux).

我认为这取决于您计划定位的平台类型。Java 将拥有最多带有 VM 的平台。但是,如果您只想使用 Windows 和 Linux,则可以使用 C#(在 linux 上使用 mono)。

回答by Todd Gamblin

Java is certainly nice, but I've been doing just fine with Python and Qtvia PyQt4lately. I find that I get things done faster than I did in Swingor SWT, too.

Java当然很好,但我最近通过PyQt4使用Python和Qt做得很好。我发现我完成工作的速度也比在SwingSWT 中更快。

So far, no platform-specific tweaks have been necessary, and Qt4 widgets look nice on different platforms. The Qt GUI builder is very nice, and using Python has enabled easy integration with some other cross-platform frameworks (notably VTK, scipy-cluster, and some SWIG-wrapped objects for interfacing with files output from a performance tool).

到目前为止,还没有必要进行特定于平台的调整,而且 Qt4 小部件在不同平台上看起来都不错。Qt GUI 构建器非常好,使用 Python 可以轻松集成其他一些跨平台框架(特别是VTKscipy-cluster和一些SWIG包装的对象,用于与性能工具输出的文件交互)。

Note that Qt is not free unless you use it on open source projects.

请注意,除非您在开源项目中使用 Qt,否则它不是免费的。

回答by Will Dieterich

Based on your definition, no. Even wit the newest graphical libraries you can expect to do a bunch of testing on different platforms.

根据你的定义,没有。即使使用最新的图形库,您也可以在不同平台上进行大量测试。

Flash would probably be the best. Wide spread and better at looking the same across different platforms.

Flash可能是最好的。广泛传播,更好地在不同平台上看起来相同。

回答by Eli Courtwright

I strongly recommend Java for cross-platform GUI development. In particular, I recommend the GUI builder that comes with the Netbeans IDE. It's very simple and very powerful. You can point and click and drag and drop to create a GUI, and easily customize the actions which various buttons and other components take.

我强烈推荐 Java 进行跨平台 GUI 开发。我特别推荐Netbeans IDE附带的 GUI 构建器。它非常简单而且非常强大。您可以指向并单击和拖放以创建 GUI,并轻松自定义各种按钮和其他组件执行的操作。

I much prefer Python as a language, but none of the free tools for GUI development come anywhere close to this, and the same thing seems to be true for the other languages I've used. (I should point out that QThas wonderful GUI developers for various languages such as C and Python, but it's only free when used on open source projects.)

我更喜欢 Python 作为一种语言,但没有一个用于 GUI 开发的免费工具能与此相提并论,而且我使用过的其他语言似乎也是如此。(我应该指出,QT为 C 和 Python 等各种语言提供了出色的 GUI 开发人员,但它仅在用于开源项目时才免费。)

EDIT: QT has recently been relicensed as LGPL, so you're free to use it in commercial applications. The Python bindings for this (PyQT) have not been re-licensed, but another project called PySidehas been created to provide Python QT bindings.

编辑:QT 最近被重新授权为 LGPL,因此您可以在商业应用程序中自由使用它。此 (PyQT) 的 Python 绑定尚未重新获得许可,但已创建另一个名为PySide 的项目来提供 Python QT 绑定。

回答by seanhodges

These days there are many languages that allow you to create cross-platform GUI applications efficiently. Java, Python, Tcl/tk, C#...

如今,有许多语言可以让您高效地创建跨平台 GUI 应用程序。Java、Python、Tcl/tk、C#...

I think you need to define the requirements of your application a bit more, for instance:

我认为您需要更多地定义应用程序的要求,例如:

  • Will the UI be Web-based, or desktop-based?
  • Is the application going to be a large or a small?
  • Will it feature some sort of "extension" feature (e.g. plug-ins)?
  • Will it function over a network, and is it likely to be distributed/load balanced?
  • UI 是基于 Web 还是基于桌面?
  • 应用程序是大还是小?
  • 它是否具有某种“扩展”功能(例如插件)?
  • 它会在网络上运行吗,它是否可能是分布式/负载平衡的?

The list can go on forever, work out the defining points about your application, and start researching the language based on the whole.

该列表可以永远继续下去,找出有关您的应用程序的定义点,并开始基于整体研究该语言。

回答by thSoft

Yes: use Eclipse RCP. You can write not only cross-platform, but e.g. multilingual applications with it. SWT provides the native look-and-feel for multiple platforms and windowing systems.

是:使用 Eclipse RCP。您不仅可以编写跨平台的应用程序,还可以使用它编写多语言应用程序。SWT 为多个平台和窗口系统提供了原生的外观。

回答by ivan_ivanovich_ivanoff

As long as someone defines "platform independence"correctly, Java is the best.

只要有人正确定义了“平台独立性”Java 就是最好的。

Some people argue that C# is the best, but those people seem to misunderstand the term "platform independence" ;)

有些人认为 C# 是最好的,但这些人似乎误解了“平台独立性”这个词;)

Note: I refer to the fact that C# is ported to Linux/Unixes only as long as Microsoft and Novel keep up their treaty. The community itself would never be able to maintain such huge platform as .NET

注意:我指的是 C# 仅在 Microsoft 和 Novel 遵守其条约时才移植到 Linux/Unix 的事实。社区本身永远无法维持像 .NET 这样庞大的平台

回答by dmihailescu

I would also consider Mono as serious contender for platform independence and a good IDE tool. Java's performance sucks on the desktop. Just check http://www.codeproject.com/KB/dotnet/RuntimePerformance.aspx

我还认为 Mono 是平台独立性的有力竞争者和优秀的 IDE 工具。Java 的性能在桌面上很糟糕。只需检查http://www.codeproject.com/KB/dotnet/RuntimePerformance.aspx

回答by mico

I personally despise the whole concept of emulating the native GUI that is where the Java GUIs are rooted. Instead of being at home wherever you go, it makes you a tourist everywhere, often needing an interpreter. The Eclipse GWT is a better toolkit that makes much better use of local resources, but it still holds that people love to write Java code, and hate to use Java applications, think of it: which Java applications you love on your desktop?

我个人鄙视模拟作​​为 Java GUI 的根的本机 GUI 的整个概念。无论您走到哪里,都不是在家里,而是让您到处都是游客,通常需要翻译。Eclipse GWT 是一个更好的工具包,可以更好地利用本地资源,但它仍然认为人们喜欢编写 Java 代码,讨厌使用 Java 应用程序,想一想:您喜欢桌面上的哪些 Java 应用程序?

Tk is just as ugly and limited on any operating system you choose to run it onto, and the same goes for Qt, in my opinion.

Tk 在您选择运行它的任何操作系统上都同样丑陋和受限,在我看来,Qt 也是如此。

Mono would need a good try, as it is a way to answer the question "why Linux sucks", if you remember that old post bi Miguel de Icaza. Mono comes with a mature set of widgets and Apis and does not try to limit what you can do in order to give you portability.

Mono 需要好好尝试一下,因为如果您还记得 Miguel de Icaza 的旧帖子,它是回答“为什么 Linux 很烂”这个问题的一种方式。Mono 附带了一套成熟的小部件和 API,并且不会试图限制您可以做的事情,以便为您提供可移植性。

Silverlight is close to portable and has a great interface definition language, but lacks access to the system, you have to split the application between a server and UI even on the same machine to overcome it.

Silverlight 接近可移植性,并且拥有出色的界面定义语言,但无法访问系统,您必须在服务器和 UI 之间拆分应用程序,甚至在同一台机器上才能克服它。

Adobe AIR is a dog and local system acces is not easy.

Adobe AIR 是一条狗,本地系统访问并不容易。

If I am able to choose, I tend to avoid GUIs altogether and try to use a web server, even a local web server, and Json, JQuery and all that stuff. I found out that I can have many more choices and am more productive than with native widgets. This combines the strengths of the use of a real language server side and the wonderful disordered geniality of JavaScript in the GUI.

如果我可以选择,我倾向于完全避免使用 GUI 并尝试使用 Web 服务器,甚至是本地 Web 服务器,以及 Json、JQuery 和所有这些东西。我发现与使用原生小部件相比,我可以有更多的选择并且效率更高。这结合了使用真实语言服务器端的优势和 GUI 中 JavaScript 奇妙的无序和友好性。

回答by rodrigogq

For native binaries, wxWidgets is a convenient solution.

对于原生二进制文件,wxWidgets 是一个方便的解决方案。

I would tell you that is even better than Java for the user experience side. Even though you can make the presentation layer look pretty much the same for all platforms in Java, they all look like Java. On the other hand, wxWidgets make the user feel like a platform specific build (and it is, indeed), but you can use the same code to compile for several platforms (at least the major ones).

我会告诉你,在用户体验方面,它甚至比 Java 更好。即使您可以使表示层在 Java 中的所有平台看起来都几乎相同,但它们看起来都像 Java。另一方面,wxWidgets 使用户感觉像是一个特定于平台的构建(确实如此),但是您可以使用相同的代码为多个平台(至少是主要平台)进行编译。