Choosing Java vs Python on Google App Engine - java
Currently Google App Engine supports both Python & Java. Java support is less mature. However, Java seems to have a longer list of libraries and especially support for Java bytecode regardless of the languages used to write that code. Which language will give better performance and more power? Please advise. Thank you!
Edit:
http://groups.google.com/group/google-appengine-java/web/will-it-play-in-app-engine?pli=1
Edit:
By "power" I mean better expandability and inclusion of available libraries outside the framework. Python allows only pure Python libraries, though.
I'm biased (being a Python expert but pretty rusty in Java) but I think the Python runtime of GAE is currently more advanced and better developed than the Java runtime -- the former has had one extra year to develop and mature, after all.
How things will proceed going forward is of course hard to predict -- demand is probably stronger on the Java side (especially since it's not just about Java, but other languages perched on top of the JVM too, so it's THE way to run e.g. PHP or Ruby code on App Engine); the Python App Engine team however does have the advantage of having on board Guido van Rossum, the inventor of Python and an amazingly strong engineer.
In terms of flexibility, the Java engine, as already mentioned, does offer the possibility of running JVM bytecode made by different languages, not just Java -- if you're in a multi-language shop that's a pretty large positive. Vice versa, if you loathe Javascript but must execute some code in the user's browser, Java's GWT (generating the Javascript for you from your Java-level coding) is far richer and more advanced than Python-side alternatives (in practice, if you choose Python, you'll be writing some JS yourself for this purpose, while if you choose Java GWT is a usable alternative if you loathe writing JS).
In terms of libraries it's pretty much a wash -- the JVM is restricted enough (no threads, no custom class loaders, no JNI, no relational DB) to hamper the simple reuse of existing Java libraries as much, or more, than existing Python libraries are similarly hampered by the similar restrictions on the Python runtime.
In terms of performance, I think it's a wash, though you should benchmark on tasks of your own -- don't rely on the performance of highly optimized JIT-based JVM implementations discounting their large startup times and memory footprints, because the app engine environment is very different (startup costs will be paid often, as instances of your app are started, stopped, moved to different hosts, etc, all trasparently to you -- such events are typically much cheaper with Python runtime environments than with JVMs).
The XPath/XSLT situation (to be euphemistic...) is not exactly perfect on either side, sigh, though I think it may be a tad less bad in the JVM (where, apparently, substantial subsets of Saxon can be made to run, with some care). I think it's worth opening issues on the Appengine Issues page with XPath and XSLT in their titles -- right now there are only issues asking for specific libraries, and that's myopic: I don't really care HOW a good XPath/XSLT is implemented, for Python and/or for Java, as long as I get to use it. (Specific libraries may ease migration of existing code, but that's less important than being able to perform such tasks as "rapidly apply XSLT transformation" in SOME way!-). I know I'd star such an issue if well phrased (especially in a language-independent way).
Last but not least: remember that you can have different version of your app (using the same datastore) some of which are implemented with the Python runtime, some with the Java runtime, and you can access versions that differ from the "default/active" one with explicit URLs. So you could have both Python and Java code (in different versions of your app) use and modify the same data store, granting you even more flexibility (though only one will have the "nice" URL such as foobar.appspot.com -- which is probably important only for access by interactive users on browsers, I imagine;-).
Watch this app for changes in Python and Java performance:
http://gaejava.appspot.com/
(edit: apologies, link is broken now. But following para still applied when I saw it running last)
Currently, Python and using the low-level API in Java are faster than JDO on Java, for this simple test. At least if the underlying engine changes, that app should reflect performance changes.
Based on experience with running these VMs on other platforms, I'd say that you'll probably get more raw performance out of Java than Python. Don't underestimate Python's selling points, however: The Python language is much more productive in terms of lines of code - the general agreement is that Python requires a third of the code of an equivalent Java program, while remaining as or more readable. This benefit is multiplied by the ability to run code immediately without an explicit compile step.
With regards to available libraries, you'll find that much of the extensive Python runtime library works out of the box (as does Java's). The popular Django Web framework (http://www.djangoproject.com/) is also supported on AppEngine.
With regards to 'power', it's difficult to know what you mean, but Python is used in many different domains, especially the Web: YouTube is written in Python, as is Sourceforge (as of last week).
June 2013: This video is a very good answer by a google engineer:
http://www.youtube.com/watch?v=tLriM2krw2E
TLDR; is:
Pick the language that you and your team is most productive with
If you want to build something for production: Java or Python (not Go)
If you have a big team and a complex code base: Java (because of static code analysis and refactoring)
Small teams that iterate quickly: Python (although Java is also okay)
An important question to consider in deciding between Python and Java is how you will use the datastore in each language (and most other angles to the original question have already been covered quite well in this topic).
For Java, the standard method is to use JDO or JPA. These are great for portability but are not very well suited to the datastore.
A low-level API is available but this is too low level for day-to-day use - it is more suitable for building 3rd party libraries.
For Python there is an API designed specifically to provide applications with easy but powerful access to the datastore. It is great except that it is not portable so it locks you into GAE.
Fortunately, there are solutions being developed for the weaknesses listed for both languages.
For Java, the low-level API is being used to develop persistence libraries that are much better suited to the datastore then JDO/JPA (IMO). Examples include the Siena project, and Objectify.
I've recently started using Objectify and am finding it to be very easy to use and well suited to the datastore, and its growing popularity has translated into good support. For example, Objectify is officially supported by Google's new Cloud Endpoints service. On the other hand, Objectify only works with the datastore, while Siena is 'inspired' by the datastore but is designed to work with a variety of both SQL databases and NoSQL datastores.
For Python, there are efforts being made to allow the use of the Python GAE datastore API off of the GAE. One example is the SQLite backend that Google released for use with the SDK, but I doubt they intend this to grow into something production ready. The TyphoonAE project probably has more potential, but I don't think it is production ready yet either (correct me if I am wrong).
If anyone has experience with any of these alternatives or knows of others, please add them in a comment. Personally, I really like the GAE datastore - I find it to be a considerable improvement over the AWS SimpleDB - so I wish for the success of these efforts to alleviate some of the issues in using it.
I'm strongly recommending Java for GAE and here's why:
Performance: Java is potentially faster then Python.
Python development is under pressure of a lack of third-party libraries. For example, there is no XSLT for Python/GAE at all. Almost all Python libraries are C bindings (and those are unsupported by GAE).
Memcache API: Java SDK have more interesting abilities than Python SDK.
Datastore API: JDO is very slow, but native Java datastore API is very fast and easy.
I'm using Java/GAE in development right now.
As you've identified, using a JVM doesn't restrict you to using the Java language. A list of JVM languages and links can be found here. However, the Google App Engine does restrict the set of classes you can use from the normal Java SE set, and you will want to investigate if any of these implementations can be used on the app engine.
EDIT: I see you've found such a list
I can't comment on the performance of Python. However, the JVM is a very powerful platform performance-wise, given its ability to dynamically compile and optimise code during the run time.
Ultimately performance will depend on what your application does, and how you code it. In the absence of further info, I think it's not possible to give any more pointers in this area.
I've been amazed at how clean, straightforward, and problem free the Python/Django SDK is. However I started running into situations where I needed to start doing more JavaScript and thought I might want to take advantage of the GWT and other Java utilities. I've gotten just half way through the GAE Java tutorial, and have had one problem after another: Eclipse configuration issues, JRE versionitis, the mind-numbing complexity of Java, and a confusing and possibly broken tutorial. Checking out this site and others linked from here clinched it for me. I'm going back to Python, and I'll look into Pyjamas to help with my JavaScript challenges.
I'm a little late to the conversation, but here are my two cents. I really had a hard time choosing between Python and Java, since I am well versed in both languages. As we all know, there are advantages and disadvantages for both, and you have to take in account your requirements and the frameworks that work best for your project.
As I usually do in this type of dilemmas, I look for numbers to support my decision. I decided to go with Python for many reasons, but in my case, there was one plot that was the tipping point. If you search "Google App Engine" in GitHub as of September 2014, you will find the following figure:
There could be many biases in these numbers, but overall, there are three times more GAE Python repositories than GAE Java repositories. Not only that, but if you list the projects by the "number of stars" you will see that a majority of the Python projects appear at the top (you have to take in account that Python has been around longer). To me, this makes a strong case for Python because I take in account community adoption & support, documentation, and availability of open-source projects.
It's a good question, and I think many of the responses have given good view points of pros and cons on both sides of the fence. I've tried both Python and JVM-based AppEngine (in my case I was using Gaelyk which is a Groovy application framework built for AppEngine). When it comes to performance on the platform, one thing I hadn't considered until it was staring me in the face is the implication of "Loading Requests" that occur on the Java side of the fence. When using Groovy these loading requests are a killer.
I put a post together on the topic (http://distractable.net/coding/google-appengine-java-vs-python-performance-comparison/) and I'm hoping to find a way of working around the problem, but if not I think I'll be going back to a Python + Django combination until cold starting java requests has less of an impact.
Based on how much I hear Java people complain about AppEngine compared to Python users, I would say Python is much less stressful to use.
There's also project Unladen Swallow, which is apparently Google-funded if not Google-owned. They're trying to implement a LLVM-based backend for Python 2.6.1 bytecode, so they can use a JIT and various nice native code/GC/multi-core optimisations. (Nice quote: "We aspire to do no original work, instead using as much of the last 30 years of research as possible.") They're looking for a 5x speed-up to CPython.
Of course this doesn't answer your immediate question, but points towards a "closing of the gap" (if any) in the future (hopefully).
The beauty of python nowdays is how well it communicates with other languages. For instance you can have both python and java on the same table with Jython. Of course jython even though it fully supports java libraries it does not support fully python libraries. But its an ideal solution if you want to mess with Java Libraries. It even allows you to mix it with Java code with no extra coding.
But even python itself has made some steps forwared. See ctypes for example, near C speed , direct accees to C libraries all of this without leaving the comfort of python coding. Cython goes one step further , allowing to mix c code with python code with ease, or even if you dont want to mess with c or c++ , you can still code in python but use statically type variables making your python programms as fast as C apps. Cython is both used and supported by google by the way.
Yesterday I even found tools for python to inline C or even Assembly (see CorePy) , you cant get any more powerful than that.
Python is surely a very mature language, not only standing on itself , but able to coooperate with any other language with easy. I think that is what makes python an ideal solution even in a very advanced and demanding scenarios.
With python you can have acess to C/C++ ,Java , .NET and many other libraries with almost zero additional coding giving you also a language that minimises, simplifies and beautifies coding. Its a very tempting language.
Gone with Python even though GWT seems a perfect match for the kind of an app I'm developing. JPA is pretty messed up on GAE (e.g. no #Embeddable and other obscure non-documented limitations). Having spent a week, I can tell that Java just doesn't feel right on GAE at the moment.
One think to take into account are the frameworks you intend yo use. Not all frameworks on Java side are well suited for applications running on App Engine, which is somewhat different than traditional Java app servers.
One thing to consider is the application startup time. With traditional Java web apps you don't really need to think about this. The application starts and then it just runs. Doesn't really matter if the startup takes 5 seconds or couple of minutes. With App Engine you might end up in a situation where the application is only started when a request comes in. This means the user is waiting while your application boots up. New GAE features like reserved instances help here, but check first.
Another thing are the different limitations GAE psoes on Java. Not all frameworks are happy with the limitations on what classes you can use or the fact that threads are not allowed or that you can't access local filesystem. These issues are probably easy to find out by just googling about GAE compatibility.
I've also seen some people complaining about issues with session size on modern UI frameworks (Wicket, namely). In general these frameworks tend to do certain trade-offs in order to make development fun, fast and easy. Sometimes this may lead to conflicts with the App Engine limitations.
I initially started developing working on GAE with Java, but then switched to Python because of these reasons. My personal feeling is that Python is a better choice for App Engine development. I think Java is more "at home" for example on Amazon's Elastic Beanstalk.
BUT with App Engine things are changing very rapidly. GAE is changing itself and as it becomes more popular, the frameworks are also changing to work around its limitations.
Related
Python egg that makes Java calls to a running Java application
I am making a proposal for a Python adapter to the Oracle NoSQL Database. The Oracle NoSQL Database runs as a stand alone java application, and at least in a Java program, you interface with it by telling your program the hostname and port to connect to, and some configuration settings. Then you make java calls off of the "kvstore" object that contains that configuration. I'd like to make a Python library that essentially exposes Python versions of the java methods Oracle NoSQL has, and converts those to Java to speak with the running Oracle NoSQL application, but I'm not sure what technologies would be best to be able to do that. Does anyone know what technology I would want to use? I'd rather not use Jython (so the application could run in a standard Python environment) or JNI (as it seems to have some nasty caveats.) EDIT: The only potentially technology I've found so far is: Jpype Would it work for me? Also, here are the ideal requirements the library would have. I would consider using Jython or JNI if one of them really did best match these requirements. Performance. The main benefits of Oracle NoSQL are performance and scalability, so that would be the most important component for the adapter. Easy to implement for the Python users. In order for the library to actually be used by Python programmers, it would have to relatively easy for them to use in a natural sort of way. Reliability. It would need to be possible for it to be trustworthy and bug free, while working on the platforms you naturally expect Python to work on. (This is what made me concerned about JNI. It sounds like it is platform dependent for its implementation, and can be error-prone.) Development speed. The last point of importance is that it be relatively fast to develop. The team of developers would enjoy learning Python or C, but we know Java better than any other programming langauge right now.
I've tried to answer each point in order, with it's own related notes. Performance: My opinion is that JNI would be the winner here, but I could be wrong, because Jython could be JITed as well. Easy to Implement: I am taking this as you mean easy to consume the library? That would depend entirely on how you build the API, 1 to 1 method calls, object handles, etc. Reliability: Jython is the clear winner here, because there is no room for error when you merely instantiate POJOs/ directly access the API right in the client code. Development Speed: JNI can be very tedious. You are essentially learning CPython modules, C, Python extensions, JNI and then referencing an existing API built in Java. All in all, if you can make the jump, I think you'd get more benefit in the short term embedding Jython, mostly because there you can directly manipulate the API. I have personally embedded IronPython in a .NET codebase with good success. Yes you lose native speed, but the tradeoffs are hard to justify with the amount of C coding needed for a working JNI bridge. That said, you may well find projects like the one you listed (Jpype) that can do much of the legwork for you. I would be asking what features of a native CPython runtime I need that you lose when going to Jython. Is your existing codebase in CPython heavily reliant on CPython native features? Anyway, there's my attempt at an answer.
An apt database (and/or) framework suggestion needed
Well, I've taken help of Google, Stackoverflow and whatever else I could find, did as much as I could, but it seems that I am unable to find out an exact answer! I have multiple queries, and I would love to have answers from the database-people as well as from the programmers and framework users. From the programming languages, I know C/C++, Java and Python. I have undertaken a CMS project that would require frequent C's & R's of the CRUD. The project would have 50k users atleast. The head-to-toe of the project has been all figured out, and now I need to code it and make it live online. Well, I want to use Neo4j as my database as its data representation model (nodes and relationships) is closest to the real project model. Now, neo4j has bindings for various languages, and one of them is Python (whose python bindings are very oldish, the jpype hasn't been updated since ages). I am thinking of going for some Java based framework, but then I leave this idea as I personally haven't heard much of java frameworks. But one of my partner tells me to go for Zend (PHP) as it has some kind of functionality that lets us execute Java code. Won't this slow the code? I mean executing one language's code in another language... So, it all comes to this: 1) Database: I would want to go for Neo4j. But does it goes well off when the scalability factor kicks in? (From what I could gather from google, there are no scalability issues). 2) What framework to use in case of Neo4j? I would require a framework that is able to handle tonnes of requests and large data as the users of the project would be Creating and Reading data a lot. P.S.: I know it is a long question, but couldn't jot it down in lesser words!
I can't speak about the scalability or suitability of Neo4J for your particular project. However, I'd strongly advise you against trying to mix and match languages like Java and PHP. It's so much easier to stick to the best one for your particular task. I'd also strongly advise you against using JNI for anything unless you have no other option. Java is fast enough that you should almost never need JNI for performance. That said, it's OK to run Neo4j in its "full server" mode and then have your PHP or Python application access it using some driver over the network. I just wouldn't recommend making an ugly hybrid of PHP and Java at your application layer. Some decent Java frameworks you could check out include: Spring Google Guice with Sitebricks Apache Struts 2 They're pretty standard in the industry and there are tons of good resources available on all of them.
In regards to the mini-question about language interoperability, Java provides the JNI interface, which allows the JVM and user code to make calls into other languages and vice versa. When the native code (e.g. C code called by Java, or Java called from C) runs, it is actually running in its natural environment, so there's no performance loss in terms of actual execution.
Neo4j as a standalone server has also REST API: http://docs.neo4j.org/chunked/milestone/rest-api.html, if you can embedded your requests in single REST queries, there is no need to use native embedded neo4j. If there is no need to use the embedded neo4j, you can take any language of your choice. Regarding the scalability, recently neo4j can be used on Azure, so it must be quite easy to scale. To learn more how to scale neo4j, go to this page on neo4j.org. UPDATE: in the newest version of Neo4j, there is added the support for a new query language - http://blog.neo4j.org/2011/06/kiruna-stol-14-milestone-4.html.
what is faster flex and Java or flex and php?
We are designing a major webapplication for the www. It a social community site. And I would like to know witch direction I need to take. What works faster, flex and php or java and flex? I've read that flex and php with amfphp is very fast (with AMFEXT). But I have seen that 90% of the major companies here in Europe are hiring java / flex developers to develop major webapplications. Our application needs to handle a lot of users at the same time. Our application will be hosted in a datacenter later it will be hosted by a major cdn provider. Our application has a video (streaming and progressive streaming) a shoppingmall and a community area. Due to the nature of our business model we think that our application will attract a lot of users a day. So we must have a webapplication that works very fast. With a strong technology on the backend. Java or PHP (amf support) for the Database: We will start with mySql and make the switch to oracle and then to sas. What is the right direction for our application? flex and java or flex and php?
I have no idea which provides "faster" execution - however, I do know that "faster" isn't the only reason to choose a language. Here's a general comparison of Java and PHP and here's another that compares Java, PHP and Ruby on Rails - neither one focuses on the language executing "faster". Especially with Flex - you will most likely spend more time executing in Flex rather than in the backing server side language. Also, since the application is Flex - it should be possible to provide similar test implementations in PHP and Java and compare the results for your specific application. The biggest part of the choice would be whatever language and platform your developers are familiar with.
This is a pretty subjective question. I believe that PHP tends to be a little bit faster but it really sort of depends on your applications requirements. From personal experience, I have been able to get more done with less code with PHP. Java has a much more strictly enforced object oriented approach which is actually quite nice whereas PHP is still lacking a bit in this area. For the most part, you will be able to accomplish the same things with both languages. I also feel that PHP has much better community driven support then Java which could be a factor. It really all depends on what you guys are most comfortable with. Both languages play well with Flash/Flex.
Java is faster than PHP in terms of pure execution time. Here is an interesting algorithm performance comparison that ranks a number of languages, showing Java to be approximately 300 times faster than PHP: http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-python-ruby-jython-jruby-groovy/ With that said, this is NOT a good approximation of the speed differences for real-world applications. A major bottleneck will typically be your database. However if your application requires a lot of processing that doesn't occur in the database, you may see performance improvement with Java. One advantage in terms of remoting is that Adobe offers Blaze DS which is a standard implementation of AMF for Flex. They also include some messaging capabilities ("data push") which I don't believe are implemented in AMFPHP.
Language choice is largely (though not entirely) irrelevant in terms of speed. Very large deployments have been built on both, and the speed factor comes from good architecture and code. So whether you go with php or java, hopefully there are good architects/designers/developers versed in the ways of writing for performance involved.
Java is always going to be faster than PHP, unless you have done something very wrong! BUT... The speed of the server side script won't really be noticed by the user, because so many other things add to the time it takes to get a response from the server (network delay, propagation delay, etc). To the user PHP and Java will seem equally fast. To the server, however, there is a difference. According to your post you plan to have many concurrent users. If each user takes 20% longer to complete a request with PHP, then PHP can handle 20% fewer concurrent users. So if you worry that the server will fill up and run at maximum capacity, then I would pick Java. If you don't expect that to happen for quite a while, then I would pick PHP, based solely on performance. Of course there are other things to take into account, like what you can do with each language, libraries available, developers available to/how well you know each one. I would also strongly advice against changing anything backend once the system is up and running. If you start out with MySQL, don't change to Oracle half way. Either stick to MySQL, unless it becomes impossible, or start using Oracle from the beginning.
I would say, try both by doing a prototype ( e.g 3-4 pages ) for each language, and run a few performance test , overall should not take more than one week to do these. Each language has its own pros / cons.
Simple Programming Theory Question
Hi guys does anyone know why the programming language C++ is used more widely in biometric security applications compared to the programming language Java? The answers that I have collected so far are 1) Virtual Compilers 2) OpenCV Library provided by C++. Can anyone help with this question??
Maybe it's the hardware support: I wrote an app that uses a fingerprint sensor. The library support for the device is C++, so I wrote the app in C++. Now they have a .NET version, so my next app will be C#.
I don't know specifically about biometric applications, but in general when security is important Java can be a stumbling block. Depending on how the security requirements are written, they can cover things that one must do manually in C++, but which are done automatically by Java. This poses a problem because one would need to demonstrate that Java properly (and in a timely manner!) satisfies the requirement. It is a lot easier to show that these requirements are met in C++ code, because the code the meets the requirement is part of the program in question. If the security person/requirements/customer make it clear that relying on Java for some security features is acceptable, then this is no big deal. We could go round-and-round about whether or not it is reasonable to rely on/trust Java to satisfy security requirements, it really just depends on the specific security needs.
I am willing to put money on the reason being simply that the access api's for the hardware are written in c++. Most of the modern/higher-level languages are not going to easily communicate with hardware originaly exposed through a C/C++ api. On a somewhat related note, Vala has all the languages features expected of a modern\high-level language(and then some), but compiles to C binary and source, and can easily make use of any library written in C (not sure about c++). Check it out, I havnt used it much, but its pretty cool.
Implementing a library in C++ provide a lot over java. Once written, C++ library can run on almost any platform (including embedded ones), and can be made available as a native import to a variety of other languages through tools like SWIG. Java can only run on something with enough speed and memory to run a JVM, and the only other Java programs can include the code as a native import. For biometric applications especially I think running on embedded systems would be a large concern, since you could build this into a small sensor. The more glib answer would be no one wants to wait for your garbage collection cycle to launch the friggen missiles.
You could replace Java with any other language there. Probably it has more to do with the APIs and hardware. Also, Java is more suited for Web Applications. Its not the best choice for desktop applications.
For some biometric applications, execution speed is crucial. For instance, let's say you're doing facial recognition for a checkpoint, and Java takes twice the time to run the algorithm that a compiled language like C++ does. That means if you go with Java, either: The checkpoint lines will be twice as long, You'll have to pay to staff twice as many checkpoints, or Your system will do half as good a job at recognizing faces None of those are usually acceptable options, which makes using Java a non-starter.
Is .NET/Mono or Java the better choice for cross-platform development? [closed]
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago. How much less libraries are there for Mono than for 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) real world portability (it's both meant to be portable, what's Catch-22 for each?) tool availability (CI, build automation, debugging, 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. 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"? 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.
Mono does a better job at targeting the platforms I want to support. Other than that, it is all subjective. I share C# code across the following platforms: - iOS (iPhone/iPad) - Android - The Web (HTML5) - Mac (OS X) - Linux - Windows I could share it even more places: - Windows Phone 7 - Wii - XBox - PS3 - etc. 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. 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. 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. 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. Both .NET/Mono and the JVM are great choices, although I would personally use some other language than Java on the JVM. 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). 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. Issue: Java has a larger ecosystem of libraries available. 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. Issue: Java has better (broader) tools support Answer: Not on Windows. Otherwise I agree. MonoDevelop is nice though. 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. Issue: Compatibility across platforms. Answer: Mono is a single code-base across all platforms, including 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... Issue: Mono lags .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) ). 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. 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 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. 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. Issue: Microsoft is evil. Answer: True. So what. Many people offer the following reasons to avoid using Mono: 1) You should not use Mono because Microsoft tech should be avoided 2) Mono sucks because it does not let you use every technology that Microsoft offers 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. 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.
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). 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. Update for 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. Update for 2018 My view on this is starting to go the other way. I think .NET, broadly, particularly with .NET Core, has started to achieve "portability parity" with Java. There are efforts underway to bring WPF to .NET Core for some platforms, and .NET Core itself runs on a great many platforms now. Mono (owned by Xamarin, which is now owned by Microsoft) is a more mature and polished product than ever, and writing applications that work on multiple platforms is no longer the domain of deep gnosis of .NET hackery, but is a relatively straightforward endeavor. There are, of course, libraries and services and applications that are Windows-only or can only target specific platforms - but the same can be said of Java (broadly). If I were in the OP's shoes at this point, I can think of no reason inherent in the languages or tech stacks themselves that would prevent me from choosing .NET for any application going forward from this point.
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. 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. 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. .NET is definitely very cross platform due to Mono based on my experiences so far.
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. 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.
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.
Java is a better choice for Cross-Platform development. 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. 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. 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. 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. 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.
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.
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. In contrast, Mono is definitely a second class citizen in the .NET ecosystem. 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? 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.
Java was designed to be cross-platform; C#/.Net wasn't. When in doubt, use the tool that was designed for your purpose. 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.
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.
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 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).
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/). 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.
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.
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. 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.
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. 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). 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. 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.