为什么您会选择 Java 编程语言而不是其他语言?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/209555/
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
Why would you choose the Java programming language over others?
提问by alsadk
Why would you choose java over others? Why did you choose java to program your application?
为什么你会选择java而不是其他人?您为什么选择 java 来编写您的应用程序?
Please include what you are using java for (desktop application/ web application/ mobile).
请包括您使用 java 的目的(桌面应用程序/网络应用程序/移动设备)。
回答by IAmCodeMonkey
Java provides a very rich API right out of the box and hands-down produces the most portable applications since there is a Java VM for almost every platform.
Java 提供了一个非常丰富的 API,开箱即用,并且可以生成最便携的应用程序,因为几乎每个平台都有一个 Java VM。
BTW: I haven't used Java since I left college since I work for a Microsoft shop, but I can't think of a single thing I can do in C# that I can't do in Java, whether it be enterprise applications, web applications, or desktop applications.
顺便说一句:自从我在微软商店工作后,我离开大学后就没有使用过 Java,但我想不出有什么我可以用 C# 做而我不能用 Java 做的事情,无论是企业应用程序, Web 应用程序或桌面应用程序。
回答by johnstok
- Excellent tooling: IDE, CI, etc.
- Vast array of 3rd party libraries.
- Huge amount of documentation available.
- Large pool of developers available.
- Platform ubiquitous.
- Excellent performance.
- Excellent specification.
- Sturdy garbage collection.
- Managed memory.
- Native threads.
- Choice - implemented by multiple vendors.
- 优秀的工具:IDE、CI等。
- 大量的 3rd 方库。
- 大量可用的文档。
- 大量的开发人员可用。
- 平台无处不在。
- 完美的表现。
- 优秀的规格。
- 坚固的垃圾收集。
- 托管内存。
- 本机线程。
- 选择 - 由多个供应商实施。
I have used Java to build various middle-ware products: Inventory mgmt; CMS; chemical registration; etc.
我曾使用 Java 构建过各种中间件产品:库存管理;内容管理系统;化学品注册;等等。
回答by Brian Knoblauch
Using it for desktop applications.
将其用于桌面应用程序。
Excellent IDEs available, wonderful API, "C-style" syntax makes it easy to pickup. Once the JVM starts, the performance is great.
优秀的 IDE 可用,精彩的 API,“C 风格”语法使其易于上手。一旦JVM启动,性能就很好。
回答by Davide
回答by Denis Fradlin
I use Java for our BPM platform and used Java in the past for enterprise web apps.
我将 Java 用于我们的 BPM 平台,并在过去将 Java 用于企业 Web 应用程序。
It depends on what you want to do. Considering language features, libraries available and IDE experience, I personally would choose C# over Java. C# 3.0 has many useful features that Java lacks, such as LINQ, Lambda expressions, etc. Some people prefer the huge library choice that is available for Java, but I think there are just too many ways of doing things. Java IDEs like Eclipse and NetBeans are getting better, but I think Visual Studio is still much easier to work with.
这取决于你想做什么。考虑到语言特性、可用库和 IDE 体验,我个人会选择 C# 而不是 Java。C# 3.0 有很多 Java 缺乏的有用功能,例如 LINQ、Lambda 表达式等。有些人更喜欢 Java 可用的大量库选择,但我认为做事的方法太多了。Eclipse 和 NetBeans 等 Java IDE 越来越好,但我认为 Visual Studio 仍然更容易使用。
Of course,if you are not using Windows, you don't have much of a choice but to choose Java. Ruby and Python can be good options for things like utility apps and GUIs, including Web apps, but for enterprise apps that don't use Windows, Java is pretty much the only option.
当然,如果你不使用Windows,你别无选择,只能选择Java。Ruby 和 Python 对于实用程序和 GUI(包括 Web 应用程序)来说是不错的选择,但对于不使用 Windows 的企业应用程序,Java 几乎是唯一的选择。
回答by WolfmanDragon
Portability is the key to java. I know that a program that i am coding will run on any system, there is no need to create different releases for different OS's.
Java also offers built in security, making the coding of the safe programs easier.
Java is fast, with clean codejava is benchmarking in the same range as C++.
可移植性是java的关键。我知道我正在编写的程序可以在任何系统上运行,无需为不同的操作系统创建不同的版本。Java 还提供内置的安全性,使安全程序的编码更容易。
Java 速度快,代码干净,Java 的基准测试范围与 C++ 相同。
C# is the language that gets compared to java the most often. C# isn't as portable as java, and has very few features that java doesn't. This makes java much more attractive unless the program will ONLY be run on a single OS, in that case i might code it in C++.
C# 是最常与 Java 进行比较的语言。C# 不像 java 那样可移植,而且很少有 java 没有的特性。这使得 java 更具吸引力,除非该程序只能在单个操作系统上运行,在这种情况下,我可能会用 C++ 对其进行编码。
回答by Daniel Spiewak
One of the nice things about Java is that everyoneknows it. Of course, now that I've said that, I'll get 80 comments from people claiming to have never learned the language. Be that as it may...
Java 的优点之一是每个人都知道它。当然,既然我这么说了,我会收到 80 条自称从未学过这门语言的人的评论。是因为它可能...
Like it or not, Java is the closest thing to a lingua franca (the idiom means "common language") we have in the industry today. Just about every has either used Java at some point, or (more commonly) is actively using it now. That sort of ubiquity can be extremely attractive to some companies, particularly those reliant on consultants. If you start a project in Java, you're pretty much guaranteed to be able to find talent to maintain the code base for years down the road.
不管喜欢与否,Java 是当今行业中最接近通用语言(习语的意思是“通用语言”)的东西。几乎每个人都曾在某个时候使用过 Java,或者(更常见)现在正在积极使用它。这种无处不在的现象对某些公司极具吸引力,尤其是那些依赖顾问的公司。如果您使用 Java 开始一个项目,那么您几乎可以保证能够找到人才来维护代码库多年。
On a different tack, Java is an excellent language for developing cross-platform desktop applications...it's just that nobody knows it. Most of Java's dominance is on the server side coupled with a little bit of love from the J2ME crowd. However, if you objectively consider Swing in Java 6uN, it's hard to find a better tool for the job. Don't get me wrong, I see that it has its flaws, but many of those have been fixed in recent releases. Most of the issue now is mindshare: everybody knowsthat Java is slow and ugly (neither of which is strictly true anymore). The other problem is that Swing is very much a cross-platform UI toolkit. This means that it is inherently much harder to create professional UIs in Swing than in Cocoa or even WinForms.
另一方面,Java 是一种用于开发跨平台桌面应用程序的优秀语言……只是没有人知道它。Java 的大部分优势都在服务器端,再加上来自 J2ME 人群的一点点喜爱。但是,如果您客观地考虑 Java 6uN 中的 Swing,则很难找到更好的工具来完成这项工作。不要误会我的意思,我看到它有它的缺陷,但其中许多已在最近的版本中得到修复。现在的大部分问题是思想共享:每个人都知道Java 既缓慢又丑陋(这两者都不再是绝对正确的)。另一个问题是 Swing 在很大程度上是一个跨平台的 UI 工具包。这意味着在 Swing 中创建专业 UI 本质上比在 Cocoa 甚至 WinForms 中更难。
Finally, a really great reason to pick Java (as opposed to .NET or Objective-C) is the ecosystem. Other answers have mentioned libraries, which really deserve a significant spotlight; but I'm thinking specifically of the rising language diversity. If you write an application in Java today, you can seamlessly transition to Scala at any time. You also have the option to do scripting in Groovy or JRuby, not to mention taking advantage of the powerful concurrency abstractions in Clojure. Because of its portability and high-level nature, the JVM is increasingly the preferred target for language compilers and interpreters (even more than the CLR). Java is really at the center of that nexus, not really benefiting directly from the vast cloud of languages which swarm around it, but certainly deriving value from all of the interoperability, present and future.
最后,选择 Java(而不是 .NET 或 Objective-C)的一个真正重要的原因是生态系统。其他答案提到了图书馆,这确实值得关注;但我特别想到的是不断上升的语言多样性。如果您今天使用 Java 编写应用程序,则可以随时无缝过渡到 Scala。您还可以选择在 Groovy 或 JRuby 中编写脚本,更不用说利用 Clojure 中强大的并发抽象了。由于其可移植性和高级特性,JVM 越来越成为语言编译器和解释器的首选目标(甚至超过 CLR)。Java 确实处于这种联系的中心,它并没有直接从围绕它的大量语言中直接受益,但肯定会从所有互操作性中获得价值,
回答by Uri
I switched from years of C++ to Java because I was working on higher level stuff and needed the benefits of memory management, reflection, and sandboxed execution that I get with Java.
我从多年的 C++ 转向 Java,因为我正在研究更高级别的东西,并且需要使用 Java 获得的内存管理、反射和沙盒执行的好处。
I have tried COM in the late nineties and could not touch it.
我在九十年代后期尝试过 COM,但无法触及它。
.NET looks promising and in many ways is now much better than Java. Unfortunately, being window-centric is a complete dealbreaker for me.
.NET 看起来很有前途,而且现在在很多方面都比 Java 好得多。不幸的是,以窗口为中心对我来说是一个彻底的破坏者。
回答by Dónal
Another benefit is the awesome static analysis tools available e.g. FindBugs. These perform a lot of checking on your code above and beyond those performed by the compiler, and can help identify bugs and/or code smells before testing begins.
另一个好处是可用的很棒的静态分析工具,例如FindBugs。这些对您的代码执行大量检查,超出编译器执行的检查范围,并且可以帮助在测试开始之前识别错误和/或代码异味。
回答by runrig
Why would I choose Java? If I happened to have a team of replaceablecode monkeysdevelopers that knew Java better than anything else, that is probably what I'd go with.
为什么我会选择Java?如果我碰巧有一个由可替换代码开发人员组成的团队,他们对 Java 的了解胜过其他任何事情,那可能就是我的选择。