C# 平台中立吗?
今天我购买了 C# 3.0 Pocket Reference(O'Reilly Publishers)。
在那本书的第一页第一段中给出了“C# 语言是 平台中立,但它是为与 Microsoft .Net 平台良好配合而编写的”
如果我没记错的话,平台中立意味着用该语言制作的软件应该在所有操作系统(例如 Mac、Windows、Linux 等)中运行。 )
我知道Java已经满足了这个特性,但是.Net还没有做到这一点(尽管MONO在Linux中取得了一些进展)
那么“PLATFORM NEUTRAL”这个词的意义是什么< /code> 到目前为止,c# 值得关注吗
?
Today I purchased C# 3.0 Pocket Reference (O'Reilly Publishers).
In that book in the first para of the first page it is given that "The C# language is
platform neutral, but it was written to work well with Microsoft .Net platform"
If I am not wrong, Platform Neutral mean that the softwares made from that language should run in all the OS(e.g.Mac, Windows,Linux etc.).
I know that this characteristic is being satisfied by Java but .Net has not yet been able to do that(Though MONO has made some progress in Linux).
Then what is the significance of that word "PLATFORM NEUTRAL"
so far c# is concern?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
C# 语言本身与 C 和 C++ 一样是平台中立的 - 您可以在任何平台上为其实现编译器等。
然而,.Net 平台及其相关库虽然被设计为能够很好地工作,但在设计上并不是平台中立的 - 它们被设计为在 Windows 上工作,尽管 Mono 确实在一定程度上弥补了这一点。
如果您编写一个 C# 程序而不使用任何 .Net 库的任何功能,那么它保证是平台无关的 - 您可以确定它会在任何具有 C# 工具的平台上运行...您只是不会不过,这是一个特别有用的程序;)
The C#-language itself is platform neutral like C and C++ are - you can implement a compiler et al for it on any platform.
The .Net platform and its associated libraries however, which it was designed to work well with, are not platform neutral in design - they are designed to work on windows, although Mono does compensate somewhat for that.
If you would write a C# program without using any features of any .Net-library it is guaranteed to be platform-independent - you can be sure it will run on any platform that has tools for C#... you just won't have a particularly useful program though ;)
C# 语言是平台中立的。
但通常与 C# 相关的框架(dotNEt 环境)却并非如此。它们在微软的操作系统上运行。
Mono 通过提供必要的运行时环境,在许多其他(主要是 unix-oid)平台上启用 C#,但它不附带运行典型 C# 程序所需的(全部)框架。
C#, the language, is platform neutral.
But the frameworks usually associated with C#, the dotNEt environment, are not. They run on Microsoft's OS-es.
Mono enables C# on many other (mostly unix-oid) platforms by providing the necessary runtime environment, but it doesn't come with (all) the frameworks needed to run typical C# programs.
不要忘记您可以在以下位置使用 C#:
覆盖范围并不完全差。该语言对运行时/操作系统的要求很少。
Don't forget you can use C# in:
Not exactly bad coverage. The language has very few requirements on the runtime / OS.
如果将 Mono 视为 Linux 上可靠的运行时,那么从操作系统的意义上来说,C# 是平台中立的(即操作系统中立)。
但是,C# 和 .Net 可以在 32 位和 64 位计算机上按原样运行,无需重新编译。我想这就是作者的意思。
C# is platform neutral in the sense of OS (i.e., OS neutral) if you count Mono as a reliable runtime on Linux.
But, C# and .Net can run as it is, without recompilation, on both 32 and 64 bit machine. I guess this is the meaning of the author.
在这种情况下,
平台中立
被定义为“能够在任何具有兼容的虚拟机"。根据您使用的语言功能和编译器,C# 可以被认为可以在运行最新版本的 Windows、Mac OS 和 Linux 的计算机上运行。In this case,
platform neutral
is defined as "being able to run on any machine that has a compatible virtual machine". Depending on what language features and compiler you use, C# could be considered able to run on machines running recent versions of Windows, Mac OS and Linux.C#语言可以在任何具有兼容编译器和虚拟机的平台上实现。该语言本身具有 ECMA 标准来实现,因此本身不包含任何平台(即 Microsoft)特定的语言元素。
C# the language can be implemented on any platform which has a compatible compiler and virtual machine. The language itself has an ECMA standard for implementation, and thus does not itself contain any platform (i.e. Microsoft) specific language elements.
在回答这个问题之前,我们必须考虑到当今任何语言如果没有它的库都是毫无用处的。也就是说,组成部分的许多命名空间只是窗口。许多只是微软技术的包装,如 com、win 表单等。
所有考虑的事情只需看一下 mono 为提供 .net 替代方案而做出的调整。 Miguel 多次提到,他们希望 Silverlight 胜出,而不是其他 ui 工具包,因为它真正独立于平台,而不是 wpf 和 winforms 等。
如果您想要真正的多平台语言和环境,请考虑 Java。
Before answering the question, one must consider that any language these days is useless without its libraries. That said many namespaces that make up part of are windows only. Many are just wrappers around microsoft technologies, like com, win forms, etc.
All things considered just take a look at the adjustments mono has made to provide alternatives to dot net. Miguel has mentioned many times that they hope Silverlight will win rather than other ui toolkits because it is truely platform independent rather than wpf and winforms etc.
If you want a true multi platform language and environment look at Java.
在我看来,微软声称 C# 是平台中立的(您引用的文本重复了这一点)是不诚实的。
这在技术上是正确的,但实际上,C# 应用程序到非 MS 操作系统的可移植性有限,尽管是 Microsoft 造成的,而不是因为它们。很明显,微软无意在任何非微软操作系统上支持 C# / .Net。事实上,许多人认为微软(通过与 Novell 的专利许可协议)正在使用 C# / Mono 作为破坏 GNU / Linux 生态系统的“楔子”。
在我看来,任何考虑使用 Mono 的人都需要考虑:1)如果 MS 决定对 .NET 专利采取强硬态度,他们的项目将面临风险;2)他们可能因此对开源生态系统造成损害。
In my view, Microsoft's claim that C# is platform neutral (repeated by the text you are quoting from) is disingenuous.
It is technically correct, but in practice the limited portability of C# applications to non-MS operating systems has happened despite Microsoft rather than because of them. It is pretty clear that Microsoft has no intention of supporting C# / .Net on any non-MS operating system. Indeed, many people think that Microsoft (via its patent licensing deal with Novell) is using C# / Mono as a "wedge" to damage the GNU / Linux ecosystem.
IMO, anyone thinking of using Mono needs to consider: 1) the risks to their project if MS decides to play hardball about .NET patents, and 2) the damage they might be doing to the open-source ecosystem as a result.