为什么 Java 经常用于企业应用程序?

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

Why is Java frequently used for enterprise applications?

javajakarta-ee

提问by alimango

As a Java newbie I'm wondering: of all the languages in the world, why is Java frequently used for enterprise applications? What makes it that way compared to the other languages? Will it continue to be this way in the upcoming years?

作为 Java 新手,我想知道:在世界上的所有语言中,为什么 Java 经常用于企业应用程序?与其他语言相比,是什么让它如此呢?在接下来的几年里,它会继续这样吗?

I'd appreciate your insights. Thanks in advance :)

我很感激你的见解。提前致谢 :)

采纳答案by Rob H

One word: libraries. Java has an vast array of excellent libraries for solving most of the common problems one needs to solve when developing enterprise applications. In many cases, there is more than one good choice for addressing a particular need, and oftentimes those libraries are free and open source under a business-friendly license.

一个字:图书馆。Java 拥有大量优秀的库,用于解决开发企业应用程序时需要解决的大多数常见问题。在许多情况下,满足特定需求的好选择不止一个,而且这些库通常是免费的、开源的,并且拥有商业友好的许可证。

Some have argued that there are, in fact, too many choices in the Java ecosystem, and that developing enterprise software in Java requires developers to make a large number of decisions that can have far-reaching impact on the end product for better or worse. This has probably helped propel the popularity of alternatives like .NET, which has a reputation of offering fewer choices, but with the benefits of a more well-integrated application stack and tools set. What direction you choose depends, I guess, on whether you place more value on "freedom of choice" or "freedom from choice".

有些人认为,实际上 Java 生态系统中有太多选择,而且用 Java 开发企业软件需要开发人员做出大量决策,这些决策可能对最终产品的好坏产生深远影响。这可能有助于推动 .NET 等替代品的流行,它以提供更少的选择而闻名,但具有集成度更高的应用程序堆栈和工具集的好处。我想,你选择的方向取决于你更看重“选择的自由”还是“选择的自由”。

回答by Rich Seller

There are lots of reasons a large company (the type to go for enterprise solutions) would pick Java. Note I'm not saying all these reasons are correct or valid. But the relevant point is that they appear valid to a CTO at MegaCorp.

大公司(采用企业解决方案的类型)选择 Java 的原因有很多。请注意,我并不是说所有这些原因都是正确的或有效的。但相关的一点是,它们对 MegaCorp 的 CTO 来说似乎是有效的。

Learning Curve

学习曲线

Java is a simple language without much of the flexibility of other members of the C family, this cuts both ways, but it is seen as a straightforward language for use by an army of programmers. Enterprise projects tend to involve large numbers of developers (rightly or wrongly) and it is much easier to get a developer to a minimum level of competence in Java than C++. You also have a whole generation of graduates who have probably been largely schooled in Java.

Java 是一种简单的语言,没有 C 家族其他成员的灵活性,这是双向的,但它被大量程序员视为一种直接使用的语言。企业项目往往涉及大量开发人员(无论正确或错误),让开发人员达到最低水平的 Java 能力比 C++ 容易得多。您还有整整一代的毕业生,他们可能在很大程度上接受过 Java 教育。

Choice

选择

Java has a vast array of libraries, frameworks, tools and IDEs, and server providers. To an enterprise its good to have choice, even if that's just for use as a bargaining chip when negotiating price. The language lends itself to code quality tools that allow enforcement of corporate standards (and as mentioned there are a lot of those tools).

Java 拥有大量的库、框架、工具和 IDE 以及服务器提供程序。对于企业来说,有选择是好事,哪怕只是作为讨价还价的筹码。该语言适用于允许执行企业标准的代码质量工具(并且如上所述有很多这样的工具)。

Platform Independence

平台独立性

Java is write once, run (well, debug) everywhere. Sun has actively encouraged open standards that allow multiple vendors to implement their solutions. These standards give the customer the comfort that they can migrate from one vendor to another if a given vendor goes under or starts charging more. Of course the reality is that each vendor does their best to provide some "added value" features that tie the customer to them quite nicely.

Java 编写一次,到处运行(好吧,调试)。Sun 积极鼓励允许多个供应商实施其解决方案的开放标准。这些标准让客户放心,如果给定的供应商欠费或开始收取更高的费用,他们可以从一个供应商迁移到另一个供应商。当然,现实情况是每个供应商都尽力提供一些“附加值”功能,将客户与他们很好地联系起来。

Maturity

到期

Its been around a long time, running a lot of servers. If your web application needs to be "6 sigma" or similar and you are the MegaCorp CTO, you are not going to look that kindly on Joe the developer wanting to do it in RoR.

它已经存在很长时间了,运行了很多服务器。如果您的 Web 应用程序需要是“6 sigma”或类似的,并且您是 MegaCorp 的 CTO,那么您不会对想要在 RoR 中做到这一点的开发人员 Joe 表现出那么友善的态度。

Timing/Marketing

时间/营销

Java came out when programming was moving towards the web. It was positioned cleverly and got a strong position early in web development. Because of the open standards, there are some very big companies producing these platforms and they market Java pretty hard to sell those platforms.

当编程转向网络时,Java 出现了。它被巧妙地定位并在 Web 开发的早期获得了强势地位。由于开放标准,有一些非常大的公司生产这些平台,他们很难推销这些平台。

Inertia

惯性

Large corporations move forward at a glacial pace (a lot are still using Java 1.4 five years after 5 was released), so once they've picked Java, it takes a massive investment to move to another platform. With each day that goes by they're cranking out more Java that would need to be migrated. Most of these companies are not primarily coding shops, so it is a very hard sell to convince the business to spend a few tens of millions rewriting their entire code base for no immediate business benefit.

大公司以极快的速度向前发展(许多公司在 Java 5 发布五年后仍在使用 Java 1.4),因此一旦他们选择了 Java,就需要大量投资才能转移到另一个平台。随着时间一天天过去,他们正在开发更多需要迁移的 Java。这些公司中的大多数都不是主要的编码商店,因此很难说服企业花费数千万美元重写他们的整个代码库而没有直接的商业利益。

回答by Jeroen van Bergen

Another reason might be the care Sun has taken to keep Java backwards compatible. The vast majority of Java code can be run on the latest version of the JVM without a problem. That is quite an achievement, given the age of Java. On the other hand you might argue Java has not changed all that much in all these years.

另一个原因可能是 Sun 非常注意保持 Java 向后兼容。绝大多数 Java 代码都可以在最新版本的 JVM 上运行而不会出现问题。考虑到 Java 的时代,这是一项了不起的成就。另一方面,您可能会争辩说,Java 这些年来并没有发生太大的变化。

Enterprises like stability in a platform.

企业喜欢平台的稳定性。

回答by Yishai

Sun targeted Java to speak to the needs of enterprises early on. It pushes standards that promote vendor independance at every level. Platform independant, database independant, application server independant, etc.

Sun 很早就瞄准了 Java 来满足企业的需求。它推动在各个层面促进供应商独立的标准。平台无关、数据库无关、应用服务器无关等。

In addition they promoted enterprise level tools for it, in terms of messaging, transaction management and other things that the enterpise worries about.

此外,他们还为它推广了企业级工具,在消息传递、事务管理和其他企业担心的事情方面。

Before Java, enterprise level stuff tended to be done in C++ (there were plenty of exceptions (does anyone remember PowerBuilder?) but that was the rule) and Java fits well as a successor to C++ for business applications, where that kind of memory management isn't something worth paying for.

在 Java 之前,企业级的东西往往是用 C++ 完成的(有很多例外(有很多人记得 PowerBuilder 吗?)但这是规则)并且 Java 非常适合作为 C++ 的后继者用于商业应用程序,在那里那种内存管理不是值得付出的东西。

In addition to all of that the language itself speaks to enterprises in terms of avoiding hard-to-get-right constructs that can really mess up a code base, such as operator overloading. Enterprise level applications tend to get handled by many different hands, not all of which are the top of the line programmers, and having safty nets to prevent shooting themselves in the foot is a desirable thing.

除了所有这些之外,该语言本身还与企业对话,以避免难以获得正确的构造,这些构造可能会真正弄乱代码库,例如运算符重载。企业级应用程序往往由许多不同的人处理,并不是所有的人都是顶级程序员,拥有安全的网络来防止自己被射中脚是一件可取的事情。

It also came along at the right time. A new paradigm (this was well before .NET existed) that promissed to combine multiple vendors into an ability to compete with Microsoft, which got the likes of IBM and Oracle on board, that happened to fill a new hole, which was the emerging requirement to develop web applications, where C++ was no longer an obvious choice.

它也出现在正确的时间。一种新的范式(早在 .NET 出现之前),它承诺将多个供应商结合起来,以增强与微软竞争的能力,后者让 IBM 和 Oracle 等公司加入,这恰好填补了一个新的漏洞,这是新兴的需求开发 Web 应用程序,其中 C++ 不再是显而易见的选择。

回答by Powerlord

I shouldn't be saying this, but...

我不应该说这些,但是...

The real reason is because it's named after coffee!

真正的原因是因为它以咖啡命名!

回答by Spence

Business is about time, money and opportunity.

商业关乎时间、金钱和机会。

Using Java means that your number of errors in the code goes down, simply because pointers are hard. You use a GC and you instantly remove an entire class of errors from your code.

使用 Java 意味着代码中的错误数量会减少,这仅仅是因为指针很难。您使用 GC 并立即从代码中删除一整类错误。

Secondly, Java was one of the first languages to ship with a pre written library of functions, which really did cover a lot of the development phase. This restricted the way things were done but it meant that people could learn faster, had more tools at their disposal and had a great set of libraries to do things like network, GUI, web, encryption etc. Java on its own as a language really wasn't that special, but Java plus the Java API was.

其次,Java 是第一批带有预先编写的函数库的语言之一,它确实涵盖了很多开发阶段。这限制了事情的完成方式,但这意味着人们可以更快地学习,拥有更多可供使用的工具,并拥有一组很棒的库来执行网络、GUI、Web、加密等操作。 Java 本身确实是一门语言没有那么特别,但 Java 加上 Java API 是。

So if you've got a language that has less errors and more infrastructure for free, then you end up with more code in less time. Sure the code doesn't cure cancer, it's not as fast as C++ code to achieve the same task, but it will achieve the business' goal of getting an application.

因此,如果您拥有一种错误更少且免费基础结构更多的语言,那么您最终会在更短的时间内编写更多代码。当然,代码不能治愈癌症,完成相同任务的速度不如 C++ 代码,但它会实现业务获得应用程序的目标。

If you make more code, for less money, you can pursue more opportunities. You then bring inertia to the table in terms of code that's already been implemented in Java and you start seeing why the business doesn't want to move away from their comfort zone.

如果你用更少的钱做更多的代码,你可以追求更多的机会。然后,您将已经用 Java 实现的代码置于桌面上,并且您开始明白为什么企业不想离开他们的舒适区。

回答by Thorbj?rn Ravn Andersen

Personally I believe one major reason is the cross-platform issue.

我个人认为一个主要原因是跨平台问题。

Java programs written "correctly" (without assumptions of the underlying operating system) can run on any JVM. This means that you are not tied to a particular platform, unlike .NET which marries you to Windows.

“正确”编写的 Java 程序(不假设底层操作系统)可以在任何 JVM 上运行。这意味着您不受特定平台的束缚,这与将您与 Windows 结合的 .NET 不同。

I have seen Java code run on mainframes, Linux routers, inside Oracle database, and naturally on PC's.

我见过 Java 代码运行在大型机、Linux 路由器、Oracle 数据库中,当然也运行在 PC 上。

回答by Alan

Also for client-server applications, you have an abundance of choices for production-quality app servers that have the same J2EE interface (IBM WebSphere, BEA Weblogic, JBoss). Alternatively, you could use the Spring Framework on any server like Apache Tomcat the complies to the Servlet API if you're convinced you don't need EJBs. In contrast to .NET, it's hard to find choices with respect to app servers.

同样对于客户端-服务器应用程序,您可以选择大量具有相同 J2EE 接口的生产质量应用程序服务器(IBM WebSphere、BEA Weblogic、JBoss)。或者,如果您确信不需要 EJB,则可以在任何服务器(如 Apache Tomcat)上使用 Spring Framework,它符合 Servlet API。与 .NET 相比,很难找到有关应用服务器的选择。

There are an abundance of choices with regards to frameworks for a given task be it an ORM tool, logging, collections, caching, web UIs, etc. There is no hardly any need to reinvent the wheel.

对于给定任务的框架有很多选择,无论是 ORM 工具、日志记录、集合、缓存、Web UI 等。几乎不需要重新发明轮子。

Finally, while it's fashionable these days to lament the very real shortcomings of Java the language, it's a language where folks know how to get things done and how to avoid certain anti-patterns.

最后,虽然如今哀叹 Java 这门语言的真正缺点很流行,但人们知道如何在 Java 中完成工作以及如何避免某些反模式。

回答by Ehtyar

It's cheap, RAD, cross-platform, and developers abound.

它很便宜,RAD,跨平台,开发人员比比皆是。

回答by Leonard Ehrenfried

Developing in C++ is too slow and expensive and .NET has not been around for long enough. Business inertia is huge, remember.

用 C++ 开发太慢而且成本太高,而且 .NET 出现的时间还不够长。商业惯性是巨大的,记住。

Businesses want languages that are backed by a professional provider (ie. a company like Sun) and often stay away from Open Source languages for the simple reason that it was not written by a company.

企业需要由专业供应商(即像 Sun 这样的公司)支持的语言,并且经常远离开源语言,原因很简单,因为它不是由公司编写的。