.NET/Mono或Java是跨平台开发的更好选择吗?

时间:2022-02-10 12:21:28

How much less libraries are there for Mono than for Java?

Mono的库比Java少多少?

I lack the overview over both alternatives but I have pretty much freedom of choice for my next project. I'm looking for hard technical facts in the areas of

我对这两种方案都不了解,但我对下一个项目有很大的选择*。我在寻找技术方面的硬道理。

  • performance (for example, I'm told Java is good for threading, and I hear the runtime code optimization has become very good recently for .NET)
  • 性能(例如,我听说Java对线程有好处,我听说最近对于。net来说,运行时代码优化变得非常好)。
  • real world portability (it's both meant to be portable, what's Catch-22 for each?)
  • 现实世界的可移植性(它都是可移植性的,每个都有什么限制?)
  • tool availability (CI, build automation, debugging, IDE)
  • 工具可用性(CI、构建自动化、调试、IDE)

I am especially looking for what you actually experienced in your own work rather than the things I could google. My application would be a back-end service processing large amounts of data from time series.

我特别要寻找的是你在自己的工作中所经历的,而不是我能做的事情。我的应用程序将是一个后端服务,处理来自时间序列的大量数据。

My main target platform would be Linux.

我的主要目标平台是Linux。

Edit: To phrase my question more adequately, I am interested in the whole package (3rd party libraries etc.), not just the language. For libraries, that probably boils down to the question "how much less libraries are there for Mono than for Java"?

编辑:为了更充分地表达我的问题,我对整个包(第三方库等)感兴趣,而不仅仅是语言。对于库,这可能归结为“Mono的库比Java少多少”的问题。


FYI, I have since chosen Java for this project, because it seemed just more battle-worn on the portability side and it's been around for a while on older systems, too. I'm a tiny little bit sad about it, because I'm very curious about C# and I'd love to have done some large project in it, but maybe next time. Thanks for all the advice.

顺便提一下,我已经为这个项目选择了Java,因为在可移植性方面,Java似乎已经过时了,在旧的系统上,它也已经存在了一段时间。我有点难过,因为我对c#很好奇,我很想在它里面做一些大的项目,不过也许下次吧。谢谢你的建议。

15 个解决方案

#1


94  

Well....Java is actually more portable. Mono isn't implemented everywhere, and it lags behind the Microsoft implementation significantly. The Java SDK seems to stay in better sync across platforms (and it works on more platforms).

好....Java实际上更便于携带。Mono并没有在任何地方实现,而且它远远落后于Microsoft实现。Java SDK似乎在不同的平台上保持了更好的同步(并且它可以在更多的平台上工作)。

I'd also say Java has more tool availability across all those platforms, although there are plenty of tools available for .NET on Windows platforms.

我还想说Java在所有这些平台上都有更多的工具可用性,尽管Windows平台上有很多。net可用的工具。

Update for 2014

更新为2014

I still hold this opinion in 2014. However, I'll qualify this by saying I'm just now starting to pay some attention to Mono after a long while of not really caring, so there may be improvements in the Mono runtime (or ecosystem) that I haven't been made aware of. AFAIK, there is still no support for WPF, WCF, WF, of WIF. Mono can run on iOS, but to my knowledge, the Java runtime still runs on far more platforms than Mono. Also, Mono is starting to see some much improved tooling (Xamarin), and Microsoft seems to have a much more cross-platform kind of attitude and willingness to work with partners to make them complimentary, rather than competitive (for example, Mono will be a pretty important part of the upcoming OWIN/Helios ASP.NET landscape). I suspect that in the coming years the differences in portability will lessen rapidly, especially after .NET being open-sourced.

我在2014年仍然持这种观点。然而,我将通过说我刚刚开始注意Mono,在很长一段时间没有真正关注它之后,因此Mono运行时(或生态系统)可能有一些改进,而我还没有意识到这些改进。AFAIK,仍然没有对WPF, WCF, WF的支持。Mono可以在iOS上运行,但据我所知,Java运行时仍然比Mono在更多的平台上运行。此外,Mono开始看到一些改进了的工具(Xamarin),微软似乎有一种更跨平台的态度和意愿,愿意与合作伙伴合作,使它们相互补充,而不是相互竞争(例如,Mono将是即将到来的OWIN/Helios ASP的相当重要的一部分)。净景观)。我怀疑在未来几年,可移植性方面的差异将会迅速减少,尤其是在。net是开源的之后。

#2


110  

Mono does a better job at targeting the platforms I want to support. Other than that, it is all subjective.

Mono在针对我想支持的平台方面做得更好。除此之外,一切都是主观的。

I share C# code across the following platforms: - iOS (iPhone/iPad) - Android - The Web (HTML5) - Mac (OS X) - Linux - Windows

我在以下平台上分享c#代码:iOS (iPhone/iPad) - Android - Web (HTML5) - Mac (OS X) - Linux - Windows

I could share it even more places: - Windows Phone 7 - Wii - XBox - PS3 - etc.

我可以分享更多的地方:Windows Phone 7, Wii, XBox, PS3等等。

The biggie is iOS since MonoTouch works fantastically. I do not know of any good way to target iOS with Java. You cannot target Windows Phone 7 with Java, so I would say that the days of Java being better for mobile are behind us.

“biggie”是iOS,因为MonoTouch的功能非常棒。我不知道用Java攻击iOS有什么好办法。你不能把Windows Phone 7和Java作为目标,所以我想说,对移动设备来说,Java更好的时代已经过去了。

The biggest factor for me though is personal productivity (and happiness). C# as a language is years ahead of Java IMHO and the .NET framework is a joy to use. Most of what is being added in Java 7 and Java 8 has been in C# for years. JVM languages like Scala and Clojure (both available on the CLR) are pretty nice though.

对我来说,最大的因素是个人生产力(和幸福)。c#作为一种语言,比Java IMHO领先了很多年,使用。net框架是一种乐趣。Java 7和Java 8中添加的大部分内容已经在c#中添加多年了。不过,像Scala和Clojure这样的JVM语言(在CLR上都可用)还是很不错的。

I see Mono as a platform in it's own right (a great one) and treat .NET as the Microsoft implementation of Mono on Windows. This means that I develop and test on Mono first. This works wonderfully.

我认为Mono本身就是一个平台(一个很好的平台),我把。net当作Windows上Mono的微软实现。这意味着我首先要开发和测试Mono。这个工作的非常好。

If both Java and .NET (Mono let's say) were Open Source projects without any corporate backing, I would choose Mono over Java every time. I believe it is just a better platform.

如果Java和。net(假设)都是开放源码项目,没有任何企业支持,我将每次都选择Mono而不是Java。我相信这只是一个更好的平台。

Both .NET/Mono and the JVM are great choices, although I would personally use some other language than Java on the JVM.

net / mono和JVM都是很好的选择,尽管我个人会在JVM上使用Java以外的其他语言。

My take on some of the other comments:

Issue: Performance.

问题:性能。

**Answer: Both the JVM and the CLR perform better than detractors say they do. I would say that the JVM performs better. Mono is generally slower than .NET (though not always).

**回答:JVM和CLR的表现都比批评者所说的要好。我认为JVM的性能更好。Mono通常比。net慢(虽然不是总是)。

I personally would take ASP.NET MVC over J2EE any day both as a developer and an end-user. Support for Google Native Client is pretty cool too. Also, I know that poor GUI performance for desktop Java apps is supposed to be a thing of the past but I keep finding slow ones. Then again, I could say the same for WPF. GTK# is plenty fast though so there is no reason they have to be slow.

我个人认为ASP。无论是作为开发人员还是最终用户,netmvc在任何时候都优于J2EE。支持谷歌本地客户端也很酷。此外,我知道桌面Java应用程序的GUI性能很差,这应该是过去的事了,但我一直在寻找速度较慢的程序。同样,对于WPF也是如此。GTK#虽然速度很快,但是没有理由一定要慢。

Issue: Java has a larger ecosystem of libraries available.

问题:Java拥有更大的可用库生态系统。

Answer: Probably true, but it is a non-issue in practice.

答:可能是真的,但在实践中这不是问题。

Practically every Java library (including the JDK) runs just dandy on .NET/Mono thanks to IKVM.NET. This piece of technology is a true marvel. The integration is amazing; you can use a Java library just like it was native. I have only had to use Java libraries in one .NET app though. The .NET/Mono ecosystem generally offers more than I need.

实际上,由于IKVM.NET,每个Java库(包括JDK)都可以在. net / mono上运行。这项技术真是一个奇迹。集成是惊人的;您可以使用Java库,就像它是本地的一样。不过,我只需要在一个。net应用程序中使用Java库。. net / mono生态系统通常提供了超出我需要的功能。

Issue: Java has better (broader) tools support

问题:Java有更好(更广泛)的工具支持

Answer: Not on Windows. Otherwise I agree. MonoDevelop is nice though.

答:不是窗户。否则我同意。MonoDevelop是好的。

I want to give a shout-out to MonoDevelop; it is a jewel. MonoDevelop integrates most of the tools I want use including code completion (intellisense), Git/Subversion integration, support for unit tests, SQL integration, debugging, easy refactoring, and assembly browsing with on-the-fly decompilation. It is wonderful to use the same environment for everything from server-side web to mobile apps.

我想对MonoDevelop做个大声疾呼;这是一个宝石。MonoDevelop集成了我想要使用的大多数工具,包括代码完成(intellisense)、Git/Subversion集成、对单元测试的支持、SQL集成、调试、轻松重构和使用动态分解的汇编浏览。从服务器端web到移动应用程序,使用相同的环境非常好。

Issue: Compatibility across platforms.

问题:跨平台兼容性。

Answer: Mono is a single code-base across all platforms, including Windows.

答:Mono是跨所有平台(包括Windows)的单一代码库。

Develop for Mono first and deploy to .NET on Windows if you like. If you compare .NET from MS to Java though then Java has the edge in terms of consistency across platforms. See next answer...

首先为Mono开发,如果你喜欢,可以部署到Windows上的。net上。如果你将。net与MS和Java进行比较,那么Java在跨平台的一致性方面具有优势。看到下一个答案…

Issue: Mono lags .NET.

问题:Mono滞后。net。

Answer: No it does not. IMHO, this is an often stated but incorrect statement.

答:没有。嗯,这是一个经常说的但不正确的说法。

The Mono distribution from Xamarin ships with C#, VB.NET, F#, IronPython, IronRuby, and I think maybe Boo out of the box. The Mono C# compiler is completely up to date with MS. The Mono VB.NET compiler does lag the MS version. The other compilers are the same on both platforms (as are other .NET languages like Nemerle, Boo, and Phalanger (PHP) ).

从Xamarin船舶与c#, VB的Mono分布。NET, f#, IronPython, IronRuby,我想可能会跳出框框。Mono c#编译器完全符合Mono VB女士的要求。NET编译器确实滞后于MS版本。其他的编译器在这两个平台上都是一样的(还有其他的。net语言,比如Nemerle, Boo和Phalanger (PHP)))。

Mono ships with a lot of the actual Microsoft written code including the Dynamic Language Runtime (DLR), Managed Extensibility Framework (MEF), F#, and ASP.NET MVC. Because Razor is not Open Source, Mono currently ships with MVC2 but MVC3 works on Mono just fine.

Mono附带了许多微软实际编写的代码,包括动态语言运行时(DLR)、托管可扩展性框架(MEF)、f#和ASP。净MVC。由于Razor不是开源的,所以Mono目前附带了MVC2,但是MVC3在Mono上运行良好。

The core Mono platform has kept pace with .NET or many years and the compatibility is impressive. You can use the full C# 4.0 language and even some C# 5.0 features today. In fact, Mono often leads .NET in many ways.

核心的Mono平台已经与。net或多年保持了同步,兼容性令人印象深刻。您可以使用完整的c# 4.0语言,甚至一些c# 5.0功能。事实上,Mono经常在很多方面引领。net。

Mono implements parts of the CLR spec that even Microsoft does not support (like 64 bit arrays). One of the most exciting new pieces of technology in the .NET world is Rosylyn. Mono has offered the C# compiler as a service for many years. Some of what Rosylyn offers is available via NRefractory as well. An example of were Mono is still ahead would be the SIMD instructions to accelerate gaming performance.

Mono实现了甚至连微软都不支持的CLR规范的部分(比如64位数组)。. net世界中最令人兴奋的新技术之一是Rosylyn。Mono多年来一直将c#编译器作为一种服务提供。Rosylyn提供的一些功能也可以通过n耐火材料获得。Mono的一个例子是SIMD指令,以加速游戏的性能。

Microsoft does offer a number of products on top of .NET that are not available in Mono which is were the misconception about Mono lagging comes from. Windows Presentation Foundation (WPF), Entity Framework (EF), WCF (Windows Communication Foundation) are examples of products which do not work, or are poorly supported, on Mono. The obvious solution is to use cross-platform alternatives like GTK#, NHibernate, and ServiceStack instead.

微软确实在。net上提供了一些产品,但在Mono中是没有的,这是关于Mono滞后的误解。Windows Presentation Foundation (WPF)、Entity Framework (EF)、WCF (Windows Communication Foundation)是在Mono上不工作或不支持的产品示例。显而易见的解决方案是使用跨平台的替代方案,比如GTK#、NHibernate和ServiceStack。

Issue: Microsoft is evil.

问题:微软是恶的。

Answer: True. So what.

答:真的。那么。

Many people offer the following reasons to avoid using Mono:

许多人提出以下理由来避免使用Mono:

1) You should not use Mono because Microsoft tech should be avoided

1)您不应该使用Mono,因为应该避免使用Microsoft tech

2) Mono sucks because it does not let you use every technology that Microsoft offers

2)Mono很糟糕,因为它不能让你使用微软提供的所有技术。

To me, it is clear that these statements are incompatible. I reject the first statement but will skip that argument here. The second statement is true of all .NET alternatives.

在我看来,这些说法显然是不相容的。我拒绝第一个声明,但会跳过这个论点。第二个语句适用于所有的。net选项。

The JVM is a great platform and the explosion of JVM languages is awesome. Use what makes you happy. For now, that is often .NET/Mono for me.

JVM是一个很棒的平台,JVM语言的爆炸式增长令人惊叹。用让你快乐的东西。现在,这对我来说是。net / mono。

#3


53  

I actually develop in .NET, run all my tests first on Mono, and then on Windows. That way I know my applications are cross platform. I have done this very successfully on both ASP.NET and Winforms applications.

我实际上是在。net中开发的,首先在Mono上运行所有测试,然后在Windows上运行。这样我就知道我的应用是跨平台的。我在这两个ASP上都做得很成功。净和Winforms应用程序。

I am not really sure where some people get the impression Mono is so horrible from, but it certainly has done it's job in my cases and opinions.It is true you will have a bit of lag for the latest and greatest inventions in the .NET world, but so far, .NET 2.0 on Windows and Linux is very solid for me.

我不确定人们从哪里得到的印象是如此的可怕,但它确实在我的案例和观点中起到了作用。的确,对于。net世界中最新的、最伟大的发明,你会有一些落后,但是到目前为止,Windows和Linux上的。net 2.0对我来说是非常可靠的。

Keep in mind there are obviously many quirks to this, but most of them come from making sure you are writing portable code. While the frameworks do a great job of abstracting away what OS you are running on, little things like Linux's case sensitivity in paths and file names takes a bit of getting used to, as do things like permissions.

请记住,显然有很多奇怪的地方,但是大多数都来自于确保您正在编写可移植的代码。虽然这些框架在抽象您正在运行的操作系统方面做得很好,但是像Linux在路径和文件名中的大小写敏感性这样的小事情需要慢慢习惯,就像权限之类的事情一样。

.NET is definitely very cross platform due to Mono based on my experiences so far.

基于我迄今为止的经验,. net绝对是非常跨平台的。

#4


26  

Java actually is as cross-platform as everyone says it is. There's a JVM implementation for just about any mainstream OS out there (even Mac OS X, finally), and they all work really well. And there's tons of open source tools out there that are just as cross platform.

Java实际上和大家说的一样是跨平台的。几乎所有主流操作系统都有JVM实现(最终甚至包括Mac OS X),它们都运行得非常好。还有大量的开源工具,就像跨平台一样。

The only catch is that there are certain native operations you can't do in Java without writing some DLLs or SOs. It's very rare that these come up in practice. In all those cases, though, I've been able to get around it by spawning native processes and screen-scraping the results.

惟一的问题是,如果不编写dll或SOs,就无法在Java中执行某些本机操作。这在实践中很少见。但是,在所有这些情况下,我能够通过生成本机进程和屏幕抓取结果来绕过它。

#5


18  

I think the question is phrased incorrectly. C# vs. Java is much less interesting in terms of cross-platform usage than is (a) which platforms you need to support, and (b) considering the core libraries and available third party libraries. The language is almost the least important part of the decision-making process.

我认为这个问题措词不正确。c#和Java在跨平台使用方面远不如(a)需要支持哪些平台,(b)考虑核心库和可用的第三方库有趣。语言几乎是决策过程中最不重要的部分。

#6


15  

Java is a better choice for Cross-Platform development.

Java是跨平台开发的更好选择。

  • Performance. Java and .Net have similar performance level due to the virtual machine, but JVM normally has better performance because of years and years optimization.

    的性能。由于虚拟机,Java和. net具有类似的性能水平,但是JVM由于多年的优化,通常具有更好的性能。

  • Library. Although this depends on your task, Java has much more open source or third party libraries available there. For server App, J2EE, Spring, Struts, etc. For GUI, although .Net provides Win32 layer API but this causes compatibility issues. Java has Swing, SWT, AWT, etc. It works in most cases.

    图书馆。尽管这取决于您的任务,但是Java有更多的开源或第三方库可用。对于服务器端应用程序,J2EE, Spring, Struts等。对于GUI,尽管。net提供了Win32层API,但是这会导致兼容性问题。Java有Swing、SWT、AWT等,在大多数情况下都可以使用。

  • Compatibility. This is the key issues that need to be considered when develop the cross-platform program. Two issue: first, platform compatibility. Java still wins since JDK is well maintained by single and original company Sun. Mono is not maintained by MS, so you have no guarantee yet for update compatibility. 2. Backward compatibility. Sun maintains a good reputation on their backward compatibility, although sometimes this seems too rigid and slows the pace.

    兼容性。这是开发跨平台程序时需要考虑的关键问题。两个问题:第一,平台兼容性。Java仍然是赢家,因为JDK是由独立的、原创的Sun公司很好地维护的。Mono不是MS维护的,所以您还不能保证更新兼容性。2。向后兼容性。Sun在向后兼容方面保持着良好的声誉,尽管有时这似乎过于死板,会减慢步伐。

  • Tools. Java has good cross-platform IDEs. Netbeans, Eclipse, etc. Most of them are free. VS Studio is good but only on Windows, and not cost a bit. Both of them provides good unit tests, debugs, profiles, etc.

    工具。Java具有良好的跨平台ide。Netbeans、Eclipse等大多数都是免费的。VS Studio很好,但只在Windows上使用,而且不会花多少钱。它们都提供了良好的单元测试、调试、概要文件等。

Hence I'd suggest that Java is a better choice. As a show case, there are some famous desktop cross-platforms apps developed by Java: Vuze, Limewire, BlogBridge, CrossFTP, not to mention those IDEs. As to .Net, I have limited knowledge on such success apps.

因此我认为Java是更好的选择。作为一个例子,有一些著名的由Java开发的桌面跨平台应用:Vuze, Limewire, BlogBridge, CrossFTP,更不用说那些ide了。至于。net,我对这类成功应用的了解有限。

#7


8  

I've been asking the same question off-late and IMHO, .NET/Mono seems to be a better option simply because Mono has a great track record for cross-platform desktop applications (as opposed to Java) and of course, Mono is improving by leaps and bounds these days.

我最近一直在问同样的问题,而IMHO, . net /Mono似乎是一个更好的选择,因为Mono在跨平台桌面应用程序(而不是Java)方面有着良好的记录,当然,Mono现在正在飞速发展。

#8


8  

I'm going to say Java as well. If you look at it in terms of maturity, a lot more time and effort has been expended by Sun (and others) in getting the JVM to work on non-Windows platforms.

我也要说Java。如果从成熟度的角度来看,Sun(和其他人)花费了大量的时间和精力让JVM在非windows平台上工作。

In contrast, Mono is definitely a second class citizen in the .NET ecosystem.

相比之下,Mono绝对是。net生态系统中的二等公民。

Depending on who your target customers are, you may also find there is real pushback against using Mono - does Novell offer the same kind of vendor support for Mono that you would get for Java or .NET on Windows?

根据您的目标客户是谁,您可能还会发现使用Mono确实存在阻力——Novell是否提供与Windows上的Java或.NET相同的Mono供应商支持?

If you were primarily targeting hosting your service on Windows, it would make sense to be considering this choice, but since you're targeting Linux primarily, it seems like kind of a no-brainer to me.

如果您的目标主要是在Windows上托管服务,那么考虑这个选择是有意义的,但是由于您的目标主要是Linux,对我来说这似乎是一个无需动脑筋的问题。

#9


7  

Java was designed to be cross-platform; C#/.Net wasn't. When in doubt, use the tool that was designed for your purpose.

Java设计为跨平台;c# /。净不。当有疑问时,使用为你设计的工具。

EDIT: in fairness, .NET was designed to work on embedded/PC/Server environments, so that's SORT of cross-platform. But it wasn't designed for Linux.

编辑:公平地说,. net是设计用来处理嵌入式/PC/服务器环境的,所以这是一种跨平台。但它不是为Linux设计的。

#10


6  

To add a bit more to the conversation, Java is more portable if you remain about one version behind - Java 5 still has many excellent features so you can wait for Java 6 and still have a lot of range in terms of language and libraries to develop with. The Mac is the primary platform that can take some time to catch up to the latest Java version.

要想在会话中添加一点内容,如果您仍然保留一个版本,Java就更方便了——Java 5仍然有许多优秀的特性,所以您可以等待Java 6,并且在语言和库的开发方面还有很多的范围。Mac是主要的平台,可能需要一些时间才能赶上最新的Java版本。

Java also has an excellent standards body that intelligently grows the platform based on input from many different companies. This is an oft overlooked feature but it keeps even new features working well across multiple platforms and provides a lot of range in library support for some esoteric things (as optional extensions).

Java也有一个优秀的标准体系,它基于许多不同公司的输入智能地开发平台。这是一个经常被忽视的特性,但它甚至使新特性在多个平台上运行良好,并为一些深奥的东西(作为可选扩展)提供大量的库支持。

#11


6  

I think the answer is "it depends." Java runs on just about anything, but .NET/Mono are (IMHO) a better framework for the desktop. So I guess the answer really depends on what platforms you plan on targeting.

我认为答案是“视情况而定”。Java运行在任何东西上,但是。net / mono (IMHO)是一个更好的桌面框架。所以我想答案取决于你计划针对哪些平台。

#12


5  

I would vote for Java being more portable than C#. Java definitely also has a very rich set of standard libraries. There is also a broad set of open source 3rd party libraries out there such as those provided by the Jakarta project (http://jakarta.apache.org/).

我认为Java比c#更具可移植性。Java当然也有一套非常丰富的标准库。还有一组广泛的开源第三方库,如Jakarta项目提供的这些库。

All the usual suspects exist for CI, Unit testing, etc too. Cross platform IDE support is also very good with the likes of Eclipse, Netbeans, IntelliJ IDEA etc.

所有常见的疑点都存在于CI、单元测试等。跨平台IDE支持也很好,如Eclipse、Netbeans、IntelliJ IDEA等。

#13


4  

There are other language choices too. I've become quite fond of Python, which works well on Windows, Linux, and Mac, and has a rich set of libraries.

还有其他的语言选择。我非常喜欢Python,它在Windows、Linux和Mac上运行良好,并且拥有丰富的库集。

#14


2  

While Mono has its share of problems I think it has a better cross-platform compatibility story especially IF you have reliance on native platform invocation.

虽然Mono也有一些问题,但我认为它有更好的跨平台兼容性,特别是如果您依赖于本地平台调用的话。

There are not enough words on Stack Overflow to stress how much smoother it is to get something native called and executed in .NET/Mono on (at least in my experience 3...) multiple platforms vs. the equivalent Java effort.

在Stack Overflow上没有足够的词来强调在. net / mono上(至少在我的经验中是这样的)多个平台上调用并执行一些本地的东西要比在同等的Java工作上顺利得多。

#15


2  

Gatorhall do you have some data to back that up?

佳得乐你有数据支持吗?

Performance. Java and .Net have similar performance level due to the virtual machine, but JVM normally has better performance because of years and years optimization.

的性能。由于虚拟机,Java和. net具有类似的性能水平,但是JVM由于多年的优化,通常具有更好的性能。

Background: I'm a Windows guy since Windows 3.1 and currently a Linux user (still running Windows 7, great OS, on a VM for Visual Studio 2010 and other tools).

背景:我从Windows 3.1开始就是一个Windows人,现在是一个Linux用户(仍然在Visual Studio 2010和其他工具的VM上运行Windows 7,很棒的OS)。

The point: me and a lot of users (windows, linux, etc) I know, may disagree from you. Java tends to perform slower even on a linux desktop application, ASP.NET perform's faster that java server pages many of the times. Some may agree that even non-compiled PHP performs better i several scenarios.

要点:我和很多用户(windows、linux等)可能不同意你的观点。即使在linux桌面应用程序ASP上,Java的执行速度也比较慢。NET执行速度比java服务器页面快很多次。一些人可能同意,即使是非编译的PHP也能更好地执行我的几个场景。

Java is more cross-platform? I have no doubts about this (the history back this on), but faster (not saying .NET is) not so certain and I would like to see some real benchmarks.

Java是跨平台?我对这一点毫无疑问(历史支持这一点),但更快(不是说。net是)不是那么确定,我希望看到一些真正的基准。

#1


94  

Well....Java is actually more portable. Mono isn't implemented everywhere, and it lags behind the Microsoft implementation significantly. The Java SDK seems to stay in better sync across platforms (and it works on more platforms).

好....Java实际上更便于携带。Mono并没有在任何地方实现,而且它远远落后于Microsoft实现。Java SDK似乎在不同的平台上保持了更好的同步(并且它可以在更多的平台上工作)。

I'd also say Java has more tool availability across all those platforms, although there are plenty of tools available for .NET on Windows platforms.

我还想说Java在所有这些平台上都有更多的工具可用性,尽管Windows平台上有很多。net可用的工具。

Update for 2014

更新为2014

I still hold this opinion in 2014. However, I'll qualify this by saying I'm just now starting to pay some attention to Mono after a long while of not really caring, so there may be improvements in the Mono runtime (or ecosystem) that I haven't been made aware of. AFAIK, there is still no support for WPF, WCF, WF, of WIF. Mono can run on iOS, but to my knowledge, the Java runtime still runs on far more platforms than Mono. Also, Mono is starting to see some much improved tooling (Xamarin), and Microsoft seems to have a much more cross-platform kind of attitude and willingness to work with partners to make them complimentary, rather than competitive (for example, Mono will be a pretty important part of the upcoming OWIN/Helios ASP.NET landscape). I suspect that in the coming years the differences in portability will lessen rapidly, especially after .NET being open-sourced.

我在2014年仍然持这种观点。然而,我将通过说我刚刚开始注意Mono,在很长一段时间没有真正关注它之后,因此Mono运行时(或生态系统)可能有一些改进,而我还没有意识到这些改进。AFAIK,仍然没有对WPF, WCF, WF的支持。Mono可以在iOS上运行,但据我所知,Java运行时仍然比Mono在更多的平台上运行。此外,Mono开始看到一些改进了的工具(Xamarin),微软似乎有一种更跨平台的态度和意愿,愿意与合作伙伴合作,使它们相互补充,而不是相互竞争(例如,Mono将是即将到来的OWIN/Helios ASP的相当重要的一部分)。净景观)。我怀疑在未来几年,可移植性方面的差异将会迅速减少,尤其是在。net是开源的之后。

#2


110  

Mono does a better job at targeting the platforms I want to support. Other than that, it is all subjective.

Mono在针对我想支持的平台方面做得更好。除此之外,一切都是主观的。

I share C# code across the following platforms: - iOS (iPhone/iPad) - Android - The Web (HTML5) - Mac (OS X) - Linux - Windows

我在以下平台上分享c#代码:iOS (iPhone/iPad) - Android - Web (HTML5) - Mac (OS X) - Linux - Windows

I could share it even more places: - Windows Phone 7 - Wii - XBox - PS3 - etc.

我可以分享更多的地方:Windows Phone 7, Wii, XBox, PS3等等。

The biggie is iOS since MonoTouch works fantastically. I do not know of any good way to target iOS with Java. You cannot target Windows Phone 7 with Java, so I would say that the days of Java being better for mobile are behind us.

“biggie”是iOS,因为MonoTouch的功能非常棒。我不知道用Java攻击iOS有什么好办法。你不能把Windows Phone 7和Java作为目标,所以我想说,对移动设备来说,Java更好的时代已经过去了。

The biggest factor for me though is personal productivity (and happiness). C# as a language is years ahead of Java IMHO and the .NET framework is a joy to use. Most of what is being added in Java 7 and Java 8 has been in C# for years. JVM languages like Scala and Clojure (both available on the CLR) are pretty nice though.

对我来说,最大的因素是个人生产力(和幸福)。c#作为一种语言,比Java IMHO领先了很多年,使用。net框架是一种乐趣。Java 7和Java 8中添加的大部分内容已经在c#中添加多年了。不过,像Scala和Clojure这样的JVM语言(在CLR上都可用)还是很不错的。

I see Mono as a platform in it's own right (a great one) and treat .NET as the Microsoft implementation of Mono on Windows. This means that I develop and test on Mono first. This works wonderfully.

我认为Mono本身就是一个平台(一个很好的平台),我把。net当作Windows上Mono的微软实现。这意味着我首先要开发和测试Mono。这个工作的非常好。

If both Java and .NET (Mono let's say) were Open Source projects without any corporate backing, I would choose Mono over Java every time. I believe it is just a better platform.

如果Java和。net(假设)都是开放源码项目,没有任何企业支持,我将每次都选择Mono而不是Java。我相信这只是一个更好的平台。

Both .NET/Mono and the JVM are great choices, although I would personally use some other language than Java on the JVM.

net / mono和JVM都是很好的选择,尽管我个人会在JVM上使用Java以外的其他语言。

My take on some of the other comments:

Issue: Performance.

问题:性能。

**Answer: Both the JVM and the CLR perform better than detractors say they do. I would say that the JVM performs better. Mono is generally slower than .NET (though not always).

**回答:JVM和CLR的表现都比批评者所说的要好。我认为JVM的性能更好。Mono通常比。net慢(虽然不是总是)。

I personally would take ASP.NET MVC over J2EE any day both as a developer and an end-user. Support for Google Native Client is pretty cool too. Also, I know that poor GUI performance for desktop Java apps is supposed to be a thing of the past but I keep finding slow ones. Then again, I could say the same for WPF. GTK# is plenty fast though so there is no reason they have to be slow.

我个人认为ASP。无论是作为开发人员还是最终用户,netmvc在任何时候都优于J2EE。支持谷歌本地客户端也很酷。此外,我知道桌面Java应用程序的GUI性能很差,这应该是过去的事了,但我一直在寻找速度较慢的程序。同样,对于WPF也是如此。GTK#虽然速度很快,但是没有理由一定要慢。

Issue: Java has a larger ecosystem of libraries available.

问题:Java拥有更大的可用库生态系统。

Answer: Probably true, but it is a non-issue in practice.

答:可能是真的,但在实践中这不是问题。

Practically every Java library (including the JDK) runs just dandy on .NET/Mono thanks to IKVM.NET. This piece of technology is a true marvel. The integration is amazing; you can use a Java library just like it was native. I have only had to use Java libraries in one .NET app though. The .NET/Mono ecosystem generally offers more than I need.

实际上,由于IKVM.NET,每个Java库(包括JDK)都可以在. net / mono上运行。这项技术真是一个奇迹。集成是惊人的;您可以使用Java库,就像它是本地的一样。不过,我只需要在一个。net应用程序中使用Java库。. net / mono生态系统通常提供了超出我需要的功能。

Issue: Java has better (broader) tools support

问题:Java有更好(更广泛)的工具支持

Answer: Not on Windows. Otherwise I agree. MonoDevelop is nice though.

答:不是窗户。否则我同意。MonoDevelop是好的。

I want to give a shout-out to MonoDevelop; it is a jewel. MonoDevelop integrates most of the tools I want use including code completion (intellisense), Git/Subversion integration, support for unit tests, SQL integration, debugging, easy refactoring, and assembly browsing with on-the-fly decompilation. It is wonderful to use the same environment for everything from server-side web to mobile apps.

我想对MonoDevelop做个大声疾呼;这是一个宝石。MonoDevelop集成了我想要使用的大多数工具,包括代码完成(intellisense)、Git/Subversion集成、对单元测试的支持、SQL集成、调试、轻松重构和使用动态分解的汇编浏览。从服务器端web到移动应用程序,使用相同的环境非常好。

Issue: Compatibility across platforms.

问题:跨平台兼容性。

Answer: Mono is a single code-base across all platforms, including Windows.

答:Mono是跨所有平台(包括Windows)的单一代码库。

Develop for Mono first and deploy to .NET on Windows if you like. If you compare .NET from MS to Java though then Java has the edge in terms of consistency across platforms. See next answer...

首先为Mono开发,如果你喜欢,可以部署到Windows上的。net上。如果你将。net与MS和Java进行比较,那么Java在跨平台的一致性方面具有优势。看到下一个答案…

Issue: Mono lags .NET.

问题:Mono滞后。net。

Answer: No it does not. IMHO, this is an often stated but incorrect statement.

答:没有。嗯,这是一个经常说的但不正确的说法。

The Mono distribution from Xamarin ships with C#, VB.NET, F#, IronPython, IronRuby, and I think maybe Boo out of the box. The Mono C# compiler is completely up to date with MS. The Mono VB.NET compiler does lag the MS version. The other compilers are the same on both platforms (as are other .NET languages like Nemerle, Boo, and Phalanger (PHP) ).

从Xamarin船舶与c#, VB的Mono分布。NET, f#, IronPython, IronRuby,我想可能会跳出框框。Mono c#编译器完全符合Mono VB女士的要求。NET编译器确实滞后于MS版本。其他的编译器在这两个平台上都是一样的(还有其他的。net语言,比如Nemerle, Boo和Phalanger (PHP)))。

Mono ships with a lot of the actual Microsoft written code including the Dynamic Language Runtime (DLR), Managed Extensibility Framework (MEF), F#, and ASP.NET MVC. Because Razor is not Open Source, Mono currently ships with MVC2 but MVC3 works on Mono just fine.

Mono附带了许多微软实际编写的代码,包括动态语言运行时(DLR)、托管可扩展性框架(MEF)、f#和ASP。净MVC。由于Razor不是开源的,所以Mono目前附带了MVC2,但是MVC3在Mono上运行良好。

The core Mono platform has kept pace with .NET or many years and the compatibility is impressive. You can use the full C# 4.0 language and even some C# 5.0 features today. In fact, Mono often leads .NET in many ways.

核心的Mono平台已经与。net或多年保持了同步,兼容性令人印象深刻。您可以使用完整的c# 4.0语言,甚至一些c# 5.0功能。事实上,Mono经常在很多方面引领。net。

Mono implements parts of the CLR spec that even Microsoft does not support (like 64 bit arrays). One of the most exciting new pieces of technology in the .NET world is Rosylyn. Mono has offered the C# compiler as a service for many years. Some of what Rosylyn offers is available via NRefractory as well. An example of were Mono is still ahead would be the SIMD instructions to accelerate gaming performance.

Mono实现了甚至连微软都不支持的CLR规范的部分(比如64位数组)。. net世界中最令人兴奋的新技术之一是Rosylyn。Mono多年来一直将c#编译器作为一种服务提供。Rosylyn提供的一些功能也可以通过n耐火材料获得。Mono的一个例子是SIMD指令,以加速游戏的性能。

Microsoft does offer a number of products on top of .NET that are not available in Mono which is were the misconception about Mono lagging comes from. Windows Presentation Foundation (WPF), Entity Framework (EF), WCF (Windows Communication Foundation) are examples of products which do not work, or are poorly supported, on Mono. The obvious solution is to use cross-platform alternatives like GTK#, NHibernate, and ServiceStack instead.

微软确实在。net上提供了一些产品,但在Mono中是没有的,这是关于Mono滞后的误解。Windows Presentation Foundation (WPF)、Entity Framework (EF)、WCF (Windows Communication Foundation)是在Mono上不工作或不支持的产品示例。显而易见的解决方案是使用跨平台的替代方案,比如GTK#、NHibernate和ServiceStack。

Issue: Microsoft is evil.

问题:微软是恶的。

Answer: True. So what.

答:真的。那么。

Many people offer the following reasons to avoid using Mono:

许多人提出以下理由来避免使用Mono:

1) You should not use Mono because Microsoft tech should be avoided

1)您不应该使用Mono,因为应该避免使用Microsoft tech

2) Mono sucks because it does not let you use every technology that Microsoft offers

2)Mono很糟糕,因为它不能让你使用微软提供的所有技术。

To me, it is clear that these statements are incompatible. I reject the first statement but will skip that argument here. The second statement is true of all .NET alternatives.

在我看来,这些说法显然是不相容的。我拒绝第一个声明,但会跳过这个论点。第二个语句适用于所有的。net选项。

The JVM is a great platform and the explosion of JVM languages is awesome. Use what makes you happy. For now, that is often .NET/Mono for me.

JVM是一个很棒的平台,JVM语言的爆炸式增长令人惊叹。用让你快乐的东西。现在,这对我来说是。net / mono。

#3


53  

I actually develop in .NET, run all my tests first on Mono, and then on Windows. That way I know my applications are cross platform. I have done this very successfully on both ASP.NET and Winforms applications.

我实际上是在。net中开发的,首先在Mono上运行所有测试,然后在Windows上运行。这样我就知道我的应用是跨平台的。我在这两个ASP上都做得很成功。净和Winforms应用程序。

I am not really sure where some people get the impression Mono is so horrible from, but it certainly has done it's job in my cases and opinions.It is true you will have a bit of lag for the latest and greatest inventions in the .NET world, but so far, .NET 2.0 on Windows and Linux is very solid for me.

我不确定人们从哪里得到的印象是如此的可怕,但它确实在我的案例和观点中起到了作用。的确,对于。net世界中最新的、最伟大的发明,你会有一些落后,但是到目前为止,Windows和Linux上的。net 2.0对我来说是非常可靠的。

Keep in mind there are obviously many quirks to this, but most of them come from making sure you are writing portable code. While the frameworks do a great job of abstracting away what OS you are running on, little things like Linux's case sensitivity in paths and file names takes a bit of getting used to, as do things like permissions.

请记住,显然有很多奇怪的地方,但是大多数都来自于确保您正在编写可移植的代码。虽然这些框架在抽象您正在运行的操作系统方面做得很好,但是像Linux在路径和文件名中的大小写敏感性这样的小事情需要慢慢习惯,就像权限之类的事情一样。

.NET is definitely very cross platform due to Mono based on my experiences so far.

基于我迄今为止的经验,. net绝对是非常跨平台的。

#4


26  

Java actually is as cross-platform as everyone says it is. There's a JVM implementation for just about any mainstream OS out there (even Mac OS X, finally), and they all work really well. And there's tons of open source tools out there that are just as cross platform.

Java实际上和大家说的一样是跨平台的。几乎所有主流操作系统都有JVM实现(最终甚至包括Mac OS X),它们都运行得非常好。还有大量的开源工具,就像跨平台一样。

The only catch is that there are certain native operations you can't do in Java without writing some DLLs or SOs. It's very rare that these come up in practice. In all those cases, though, I've been able to get around it by spawning native processes and screen-scraping the results.

惟一的问题是,如果不编写dll或SOs,就无法在Java中执行某些本机操作。这在实践中很少见。但是,在所有这些情况下,我能够通过生成本机进程和屏幕抓取结果来绕过它。

#5


18  

I think the question is phrased incorrectly. C# vs. Java is much less interesting in terms of cross-platform usage than is (a) which platforms you need to support, and (b) considering the core libraries and available third party libraries. The language is almost the least important part of the decision-making process.

我认为这个问题措词不正确。c#和Java在跨平台使用方面远不如(a)需要支持哪些平台,(b)考虑核心库和可用的第三方库有趣。语言几乎是决策过程中最不重要的部分。

#6


15  

Java is a better choice for Cross-Platform development.

Java是跨平台开发的更好选择。

  • Performance. Java and .Net have similar performance level due to the virtual machine, but JVM normally has better performance because of years and years optimization.

    的性能。由于虚拟机,Java和. net具有类似的性能水平,但是JVM由于多年的优化,通常具有更好的性能。

  • Library. Although this depends on your task, Java has much more open source or third party libraries available there. For server App, J2EE, Spring, Struts, etc. For GUI, although .Net provides Win32 layer API but this causes compatibility issues. Java has Swing, SWT, AWT, etc. It works in most cases.

    图书馆。尽管这取决于您的任务,但是Java有更多的开源或第三方库可用。对于服务器端应用程序,J2EE, Spring, Struts等。对于GUI,尽管。net提供了Win32层API,但是这会导致兼容性问题。Java有Swing、SWT、AWT等,在大多数情况下都可以使用。

  • Compatibility. This is the key issues that need to be considered when develop the cross-platform program. Two issue: first, platform compatibility. Java still wins since JDK is well maintained by single and original company Sun. Mono is not maintained by MS, so you have no guarantee yet for update compatibility. 2. Backward compatibility. Sun maintains a good reputation on their backward compatibility, although sometimes this seems too rigid and slows the pace.

    兼容性。这是开发跨平台程序时需要考虑的关键问题。两个问题:第一,平台兼容性。Java仍然是赢家,因为JDK是由独立的、原创的Sun公司很好地维护的。Mono不是MS维护的,所以您还不能保证更新兼容性。2。向后兼容性。Sun在向后兼容方面保持着良好的声誉,尽管有时这似乎过于死板,会减慢步伐。

  • Tools. Java has good cross-platform IDEs. Netbeans, Eclipse, etc. Most of them are free. VS Studio is good but only on Windows, and not cost a bit. Both of them provides good unit tests, debugs, profiles, etc.

    工具。Java具有良好的跨平台ide。Netbeans、Eclipse等大多数都是免费的。VS Studio很好,但只在Windows上使用,而且不会花多少钱。它们都提供了良好的单元测试、调试、概要文件等。

Hence I'd suggest that Java is a better choice. As a show case, there are some famous desktop cross-platforms apps developed by Java: Vuze, Limewire, BlogBridge, CrossFTP, not to mention those IDEs. As to .Net, I have limited knowledge on such success apps.

因此我认为Java是更好的选择。作为一个例子,有一些著名的由Java开发的桌面跨平台应用:Vuze, Limewire, BlogBridge, CrossFTP,更不用说那些ide了。至于。net,我对这类成功应用的了解有限。

#7


8  

I've been asking the same question off-late and IMHO, .NET/Mono seems to be a better option simply because Mono has a great track record for cross-platform desktop applications (as opposed to Java) and of course, Mono is improving by leaps and bounds these days.

我最近一直在问同样的问题,而IMHO, . net /Mono似乎是一个更好的选择,因为Mono在跨平台桌面应用程序(而不是Java)方面有着良好的记录,当然,Mono现在正在飞速发展。

#8


8  

I'm going to say Java as well. If you look at it in terms of maturity, a lot more time and effort has been expended by Sun (and others) in getting the JVM to work on non-Windows platforms.

我也要说Java。如果从成熟度的角度来看,Sun(和其他人)花费了大量的时间和精力让JVM在非windows平台上工作。

In contrast, Mono is definitely a second class citizen in the .NET ecosystem.

相比之下,Mono绝对是。net生态系统中的二等公民。

Depending on who your target customers are, you may also find there is real pushback against using Mono - does Novell offer the same kind of vendor support for Mono that you would get for Java or .NET on Windows?

根据您的目标客户是谁,您可能还会发现使用Mono确实存在阻力——Novell是否提供与Windows上的Java或.NET相同的Mono供应商支持?

If you were primarily targeting hosting your service on Windows, it would make sense to be considering this choice, but since you're targeting Linux primarily, it seems like kind of a no-brainer to me.

如果您的目标主要是在Windows上托管服务,那么考虑这个选择是有意义的,但是由于您的目标主要是Linux,对我来说这似乎是一个无需动脑筋的问题。

#9


7  

Java was designed to be cross-platform; C#/.Net wasn't. When in doubt, use the tool that was designed for your purpose.

Java设计为跨平台;c# /。净不。当有疑问时,使用为你设计的工具。

EDIT: in fairness, .NET was designed to work on embedded/PC/Server environments, so that's SORT of cross-platform. But it wasn't designed for Linux.

编辑:公平地说,. net是设计用来处理嵌入式/PC/服务器环境的,所以这是一种跨平台。但它不是为Linux设计的。

#10


6  

To add a bit more to the conversation, Java is more portable if you remain about one version behind - Java 5 still has many excellent features so you can wait for Java 6 and still have a lot of range in terms of language and libraries to develop with. The Mac is the primary platform that can take some time to catch up to the latest Java version.

要想在会话中添加一点内容,如果您仍然保留一个版本,Java就更方便了——Java 5仍然有许多优秀的特性,所以您可以等待Java 6,并且在语言和库的开发方面还有很多的范围。Mac是主要的平台,可能需要一些时间才能赶上最新的Java版本。

Java also has an excellent standards body that intelligently grows the platform based on input from many different companies. This is an oft overlooked feature but it keeps even new features working well across multiple platforms and provides a lot of range in library support for some esoteric things (as optional extensions).

Java也有一个优秀的标准体系,它基于许多不同公司的输入智能地开发平台。这是一个经常被忽视的特性,但它甚至使新特性在多个平台上运行良好,并为一些深奥的东西(作为可选扩展)提供大量的库支持。

#11


6  

I think the answer is "it depends." Java runs on just about anything, but .NET/Mono are (IMHO) a better framework for the desktop. So I guess the answer really depends on what platforms you plan on targeting.

我认为答案是“视情况而定”。Java运行在任何东西上,但是。net / mono (IMHO)是一个更好的桌面框架。所以我想答案取决于你计划针对哪些平台。

#12


5  

I would vote for Java being more portable than C#. Java definitely also has a very rich set of standard libraries. There is also a broad set of open source 3rd party libraries out there such as those provided by the Jakarta project (http://jakarta.apache.org/).

我认为Java比c#更具可移植性。Java当然也有一套非常丰富的标准库。还有一组广泛的开源第三方库,如Jakarta项目提供的这些库。

All the usual suspects exist for CI, Unit testing, etc too. Cross platform IDE support is also very good with the likes of Eclipse, Netbeans, IntelliJ IDEA etc.

所有常见的疑点都存在于CI、单元测试等。跨平台IDE支持也很好,如Eclipse、Netbeans、IntelliJ IDEA等。

#13


4  

There are other language choices too. I've become quite fond of Python, which works well on Windows, Linux, and Mac, and has a rich set of libraries.

还有其他的语言选择。我非常喜欢Python,它在Windows、Linux和Mac上运行良好,并且拥有丰富的库集。

#14


2  

While Mono has its share of problems I think it has a better cross-platform compatibility story especially IF you have reliance on native platform invocation.

虽然Mono也有一些问题,但我认为它有更好的跨平台兼容性,特别是如果您依赖于本地平台调用的话。

There are not enough words on Stack Overflow to stress how much smoother it is to get something native called and executed in .NET/Mono on (at least in my experience 3...) multiple platforms vs. the equivalent Java effort.

在Stack Overflow上没有足够的词来强调在. net / mono上(至少在我的经验中是这样的)多个平台上调用并执行一些本地的东西要比在同等的Java工作上顺利得多。

#15


2  

Gatorhall do you have some data to back that up?

佳得乐你有数据支持吗?

Performance. Java and .Net have similar performance level due to the virtual machine, but JVM normally has better performance because of years and years optimization.

的性能。由于虚拟机,Java和. net具有类似的性能水平,但是JVM由于多年的优化,通常具有更好的性能。

Background: I'm a Windows guy since Windows 3.1 and currently a Linux user (still running Windows 7, great OS, on a VM for Visual Studio 2010 and other tools).

背景:我从Windows 3.1开始就是一个Windows人,现在是一个Linux用户(仍然在Visual Studio 2010和其他工具的VM上运行Windows 7,很棒的OS)。

The point: me and a lot of users (windows, linux, etc) I know, may disagree from you. Java tends to perform slower even on a linux desktop application, ASP.NET perform's faster that java server pages many of the times. Some may agree that even non-compiled PHP performs better i several scenarios.

要点:我和很多用户(windows、linux等)可能不同意你的观点。即使在linux桌面应用程序ASP上,Java的执行速度也比较慢。NET执行速度比java服务器页面快很多次。一些人可能同意,即使是非编译的PHP也能更好地执行我的几个场景。

Java is more cross-platform? I have no doubts about this (the history back this on), but faster (not saying .NET is) not so certain and I would like to see some real benchmarks.

Java是跨平台?我对这一点毫无疑问(历史支持这一点),但更快(不是说。net是)不是那么确定,我希望看到一些真正的基准。