为什么在服务器端使用.NET 和Java?
Java 和.NET 是两种旨在消除平台依赖性的语言。这是通过在代码和操作系统之间添加虚拟机/框架来实现的。
那么,在服务器端使用它有什么意义,因为所有网站都可以通过浏览器访问,并且与平台无关?使用它们有什么特殊原因吗?
Java and .NET are two languages targeted at removing platform dependence. This is achieved by adding a virtual machine/framework between the code and the OS.
So, what is the point in using it on the server side, as all websites are accessible via browser, and that is platform independent? Is there any special reason for using them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
我这样理解你的问题:如果有更多其他舒适的方法来设置服务器,为什么选择 Java 或 .NET,因为客户端使用 HTTP 访问服务器?
您是对的,服务器操作系统或框架通常对客户端来说并不重要。
然而,客户端还可以包含小程序或代码,然后需要与服务器上的对应部分进行通信。然后 JSP 或 .NET 变得更有趣,因为您不必管理不同的客户端操作系统。然后网站变得很容易扩展。
如果您想集成来自第三方的一些不错的图形和图表解决方案(Telerik、Dundas 等 - 无意广告 - ),您还必须选择兼容的服务器基础设施来运行它们。
I understand your question this way: why choose Java or .NET if there are more other comfortable ways to setup a server because the clients use HTTP to access the server?
You are right that the server OS or framework does generally not matter to the client.
However the client side also can contain applets or code that then needs to communicate with its counterpart on the server. Then JSP or .NET becomes more interesting as you do not have to manage different client OS's. Then website become easily extensible.
If you want to integrate some nice graphing and charting solutions (Telerik, Dundas, ... or whatever - not meant to be advertisement - ) from 3rd parties you would also have to select a compatible server infrastructure to run them.
.NET 仅适用于 Windows 平台。 Java 是两者中唯一一个与平台无关的。
这些语言在服务器端占有很重要的地位,原因有很多:
.NET is meant for the Windows platform only. Java is the only one of the two that is meant to be platform independent.
These languages have a strong presence on the server end for many reasons:
实际上选择它们的原因几乎完全相反:
They're actually chosen for almost completely opposite reasons:
Java 和.NET 对于服务器端都有各自的好处。
例如,使用 .NET,您可以自由地为您正在处理的应用程序部分选择最佳语言,并且所有这些 .NET 语言可以协同工作。
因此,您可能希望使用 F# 来实现数据挖掘功能,使用 C# 来处理数据库,使用非托管 C++(通过薄的托管 C++ 层)来实现快速网络连接或系统调用,还有许多其他语言。 .NET 目前不太独立于平台,但独立于语言。
Java 可以在多种不同的操作系统上使用,如果您销售解决方案,这将非常有利,因为您不关心客户使用的是什么操作系统。
现在,JVM 对语言的依赖程度越来越低,Clojure 和 Scala 都在其上运行,因此 Java 现在对于设计应用程序变得更加有趣。
Both Java and .NET have their own benefits for the server-side.
For example, with .NET you are free to pick the best language for the part of the application you are working on, and all of these .NET languages work together.
So, you may want to use F# for the data mining functions, C# to work with the database, unmanaged C++ (going through a thin managed C++ layer) for fast network connections, or system calls, and there are a host of other languages. .NET is less platform independent currently, but language independent.
Java can be used on several different OSes, which is advantageous if you are selling a solution, since you don't care what OS the customer is using.
Now the JVM is becoming less language dependent, with Clojure and Scala running off of it, so Java has become more interesting now, for designing applications.
它们虚拟化底层系统,因此可以在不同类型的服务器操作系统上运行。
而且,它们被设计为通用应用程序开发系统,因此它们可以在任何带有处理器的设备上运行。
如果您因为不明白为什么要接受抽象层的开销而提问,请记住 Java 和 .NET JIT 都涉及本机代码。
They virtualize the underlying system, so they can be run on different kinds of server operating systems.
And, they are designed to be general purpose application development systems, so they are intended to be run on anything with a processor.
If you are asking because you do not understand why one would accept the overhead of an abstraction layer, keep in mind that both Java and .NET JIT down to native code.
好吧,Web 应用程序不仅仅是为了好玩而渲染 HTML,它们还在服务器端执行操作,可能涉及与数据库通信、向 MOM 发送消息等。
这是部分答案,但我想至少在这里介绍一下 Java 的情况。我可以首先论证 Java 是一种安全、健壮、垃圾收集、面向对象、高性能、多线程、解释性、架构中立、跨平台、符合流行语的编程语言……但这不会并没有真正回答你的问题。实际上,在我看来,服务器端 Java 的一个大问题是,您可以从标准化企业 API(又名 J2EE)中受益,这些 API 允许您以标准方式使用硬件、操作来执行“企业事务”(JDBC、JTA、JMS 等)。系统和软件供应商的独立性(这对于合同谈判来说是一大优势)。换句话说,Java 非常适合大型组织中几乎总是存在的异构环境,并且不会将您锁定。
Well, web applications are not just rendering HTML for fun, they are doing things on the server-side that may involve talking to database(s), sending messages to a MOM, etc.
This is a partial answer but I wanted at least to cover the case of Java here. I could start by arguing that Java is a safe, robust, garbage-collected, object-oriented, high-performance, multi-threaded, interpreted, architecture-neutral, cross-platform, buzzword-compliant programming language... but this wouldn't really answer your question. Actually, the big deal with Java on the server side is IMO that you benefit from standardized Enterprise APIs (aka J2EE) that allow you to do "enterprise things" (JDBC, JTA, JMS, etc) in a standard way with hardware, operating system and software vendor independence (which is a big plus for contract negotiation). In other words, Java is perfect for heterogeneous environments which are almost always the case with big organizations and doesn't lock you in.
虽然平台独立性非常值得努力,但我会说 Java
和 .net 是常用的,因为有大量框架
可用,这使得开发企业级变得更加容易
应用程序。对于java来说尤其如此,你有一个
令人难以置信的高质量技术选择,其中大部分是
足够灵活,可以满足大多数项目的需求,使您能够
专注于您的应用程序的功能。
此外,Java 和 .net 无意引发一场口水战,
更好的开发工具支持并且开发更容易/更快
对于普通程序员来说。
While platform independence are great to strive for I would say Java
and .net are commonly used as there are a large number frameworks
available which make it so much easier to develop enterprise level
applications. This is especially true with java, where you have an
incredible choice of high quality technologies most of which are
flexible enough to meet the needs of most projects, allowing you to
focus on your application's functionality.
Also, without no intent to start a flame war, Java and .net have
better development tool support and are easier/quicker to develop
with for your average programmer.
在早期的网络时代,主要是 Perl,偶尔也有一些勇敢的人不喜欢 Perl 或希望使用 C++ 获得更高的性能。然后Sun为Java开发了JDBC和Servlet,然后是其他J2EE部分,Java成为Perl的更高性能替代品,并且比C++更容易。随着 J2EE 的出现,许多大公司的应用程序服务器产品出现了,现在您拥有了一个大型的 Java Web/应用程序服务器社区。
然后,在输掉与 Sun 的 J++/Java 战争后,Microsoft 出现了,并使用 .NET 创建了类似的 Web 应用程序基础架构。使用 .NET,您的选择更少,但同时也带来了所有优点和缺点。
因此,我认为答案是良好的性能、安全性和企业功能以及主要企业支持的结合。对于大多数人来说,C++ 太难而且太危险。 Perl、PHP、Python 和 Ruby 有其粉丝,但没有企业支持。我认为 Java/.NET 在虚拟机上这一事实对于服务器端来说并不重要。 Java最初使用VM作为客户端。 Sun 必须努力打造快速的服务器虚拟机。我认为微软使用VM是为了与Sun竞争,并且更容易支持多种语言。看看 Google 的 Go 语言是否会成功将会很有趣,它可能在安全性和功能方面超越 Java 和 C#,但没有 VM。
In early web days, it was mostly Perl and occasional brave souls who didn't like Perl or wanted more performance used C++. Then Sun developed JDBC and Servlets for Java, and then other J2EE pieces, and Java became a higher performance alternative to Perl, and easier than C++. With J2EE came a lot of application server products from big companies, and now you have a big Java web/app server community.
Then Microsoft came along, after losing the J++/Java war with Sun, and created a similar web app infrastructure with .NET. With .NET you have fewer choices, with all of the advantages and disadvantages that brings.
So, I think the answer is a mix of decent performance, safety and enterprise features, and major corporate backing. C++ is too hard and dangerous for most people. Perl, PHP, Python, and Ruby have their fans, but not the corporate backing. I don't think the fact that Java/.NET are on Virtual Machines is important for the server side. Java used a VM originally for the client. Sun had to work hard to make a fast sever VM. I think Microsoft used a VM to compete with Sun, and to make it easier to support multiple languages. It will be interesting to see if Google's Go language takes off, which may surpass Java and C# for safety and power but no VM.
浏览器无权访问这些框架有权访问的服务器资源(数据库、文件等)。你不可能拥有一个只有 javascript 的应用程序(并且做有意义的事情)
the browser doesn't have access to the server resources (database, files etc.) that those frameworks have access to. You couldn't have an application that is only javascript (and does meaningful things)