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 12 years ago.
OK, this should really be asked to someone from Google, but I just want other opinions.
Even though Android supports Native code applications, the main development tool is still Java. But why? I mean, isn't it too slow to interpret code on a mobile device? When introducing Froyo, Google said that new JIT compiler can achieve 2-5 times faster applications. This means, that using Java over native code is 2-x times slower.
Yes, I know that using managed code applications is safer in terms of system stability, since virtual machines have better control over program execution, but still, this performance drop is huge, and I don't see any point why to use it.
Some points:
Java is a known language, developers know it and don't have to learn it
it's harder to shoot yourself with Java than with C/C++ code since it has no pointer arithmetic
it runs in a VM, so no need to recompile it for every phone out there and easy to secure
large number of development tools for Java (see point 1)
several mobile phones already used Java ME, so Java was known in the industry
the speed difference is not an issue for most applications; if it was you should code in low-level language
On the byte-code level, Android doesn't use Java. The source is Java, but it doesn't use a JVM.
The improvement to system stability is very important on a device like a cell phone.
Security is even more important. The Android environment lets users run semi-trusted apps which could exploit the phone in truly unpleasant ways without excellent security. By running all apps in a virtual machine, you guarantee that no app can exploit the OS kernel unless there is a flaw in the VM implementation. The VM implementation, in turn, is presumably small and has a small, well-defined security surface.
Perhaps most important, when programs are compiled to code for a virtual machine, they do not have to be recompiled for new hardware. The market for phone chips is diverse and rapidly-changing, so that's a big deal.
Also, using Java makes it less likely that the apps people write will be exploitable themselves. No buffer-overruns, mistakes with pointers, etc...
Native code is not necessarily any faster than Java code. Where is your profile data showing that native code could run faster?
Why Java?
Android runs on many different hardware platforms. You would need to compile and optimize your native code for each of these different platforms to see any real benefits.
There are a large number of developers already proficient in Java.
Java has huge open source support, with many libraries and tools available to make developers life easier.
Java protects you from many of the problems inherent in native code, like memory leaks, bad pointer usage, etc.
Java allows them to create sandbox applications, and create a better security model so that one bad App can't take down your entire OS.
First of all, according to Google, Android doesn't use Java. That's why Oracle is suing Google. Oracle claims that Android infringes on some Java technology, but Google says it's Dalvik.
Secondly, I haven't seen a Java byte code interpreter since 1995.
Can you back up your performance conjecture with some actual benchmarks? The scope of your presumptions don't seem justified given the inaccurate background information you provide.
Java has a pretty compelling argument for Google using it in Android: it has a huge base of developers. All these developers are (kind of) ready to develop for their mobile platform.
Keep in mind that, technically speaking, Android does not use pure Java.
As touched on elsewhere, the main issue is that Android is designed as a portable OS, to run on a wide variety of hardware.
It's also building on a framework and language familiar to many existing mobile developers.
Finally, I would say it is a bet against the future - whatever performance issues exist will become irrelevant as hardware improves - equally by getting developers to code against an abstraction, Google can rip-out and change the underlying OS far more easily, than if developers were coding to the POSIX/Unix APIs.
For most applications the overhead of using a VM-based language over native is not significant (the bottleneck for apps consuming web services, like Twitter, is mostly networking). The Palm WebOS also demonstrates this - and that uses JavaScript rather than Java as the main language.
Given that almost all VMs JIT compile down to native code, raw code speed is often comparable with native speed. A lot of delays attributed to higher-level languages are less to do with the VM overhead than other factors (a complex object runtime, 'safety' checking memory access by doing bounds checking, etc).
Also remember that regardless of the language used to write an application, a lot of the actual work is done in lower level APIs. The top level language is often just chaining API calls together.
There are, of course, many exceptions to this rule - games, audio and graphics apps that push the limits of phone hardware. Even on the iOS, developers often drop down to C/C++ to get speed in these areas.
The new JIT is running the applications 2 - 5 times faster than the old dalvikVM (both JAVA). So comparison is not C over JAVA, but JIT over dalvikVM.
First of all it's about the same thing will windows mobile or the iPhone, the .net framework needs its own VM as well as cocoa.
And even if the performance is not at the best, because it's an interpretation of byte code, android brings the entire java community as potential developers. More applications, more clients, etc.
To finish, no performance is not that bad, that's why java is used even on smaller devices (see JavaMe).
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Are there any tests that compare Javascript's performance with Java's?
UPDATE: Since everyone is asking why the hell this question, here is some context :)
As you all know - I hope - Javascript nowadays doesn't only reside in the web client but also in the web server with node.js.
It could also be run in mobile phones and dekstops with appcelerator and phonegap.
It could also be used substantially in the web browser to make the user experience first class like with desktop applications.
But Java could do these things too, running applets on the web client, and on mobile phones. It's also a language for the backend with many frameworks to choose between.
Since each one of them could almost/entirely replace each other in the mentioned area, I want to know the performance difference between them, for every case I described:
Client: Java Applets vs Javascript
Server: Java EE vs Javascript with Node.js + Express
Mobile phones: Java ME vs Javascript with Phonegap / Appcelerator
Desktop: Java SE vs Javascript with Phonegap / Appcelerator
I hope the context is more clear now.
Java and JavaScript are both programming languages. Programming languages are just a bunch of abstract mathematical rules. Programming languages aren't fast. Or slow. They just are.
The performance of an application has nothing to do with the language. The most important factor is the application architecture. Then comes algorithmic efficiency. Then micro-optimizations. Then comes the quality of the compiler/interpreter. Then the CPU. Maybe a couple of other steps in between. The language, however, doesn't directly play a role. (And of course if you're talking about benchmarks, then also the particular benchmark plays a role, as well as how well implemented the benchmark is, how well run it is, whether the guy who performs the benchmark actually knows something about benchmarking, and even more importantly statistics. Also, the precise definition of what you actually mean by "fast" is pretty important, since it can also have significant influence on the benchmark.)
However, the language might indirectly play a role: it is much easier to find and fix performance bottlenecks in 10 lines of highly expressive, clear, concise, readable, well-factored, isolated, high-level Lisp code, than in 100 lines of tangled, low-level C. (Note that those two languages are only examples. I don't mean to single any one language out.) Twitter, for example, have said that with a less expressive language than Ruby, they wouldn't have been able to make such radical changes to their architecture in such a short amount of time, to fix their scalability problems. And the reason why Node.js is able to provide such good evented I/O performance is because JavaScript's standard library is so crappy. (That way, Node.js has to provide all I/O itself, so they can optimize it for evented I/O from the ground up. Ruby and Python, for example, have evented I/O libraries that work just as well as Node.js and are much more mature ... but, Ruby and Python already have large standard libraries, including I/O libraries, all of which are synchronous and don't play well with evented libraries. JavaScript doesn't have the problem of I/O libraries that don't play well with evented I/O, because JavaScript doesn't have I/O libraries at all.)
But if you really want to compare the two, here's an interesting datapoint for you: HotSpot, which is one of the more popular, and also more performant JVM implementations out there, was created by a team of guys which included, among other people, a guy named Lars Bak. But actually, HotSpot didn't appear out of thin air, it was based on the sourcecode of the Anamorphic Smalltalk VM, which was created by a team of guys which included, among other people, a guy named Lars Bak.
V8, which is one of the more popular, and also more performant JavaScript implementations out there, was created by a team of guys which included, among other people, a guy named Lars Bak. But actually, V8 didn't appear out of thin air, it was based on the sourcecode of the Anamorphic Smalltalk VM, which was created by a team of guys which included, among other people, a guy named Lars Bak.
Given that the two are more or less the same, we can expect similar performance. The only difference is that HotSpot has over a hundred engineers working on it for 15 years, whereas V8 has a dozen engineers working for less than 5 years. That is the only difference in performance. It's not about static vs. dynamic typing (Java is statically typed, but most JVMs and certainly HotSpot make no static optimizations whatsoever, all optimizations are purely dynamic), compilation vs. interpretation (HotSpot is actually interpreted with an additional JIT compiler, whereas V8 is purely compiled), high-level vs. low-level. It is purely about money.
But I am going to bet that for every pair of Java and JavaScript implementations where the Java implementation is faster, I can find another pair where the JavaScript implementation is faster. Also, I can probably keep the pair and just use a different benchmark. There's a reason the call the Computer Languages Benchmark Game a "game": they even encourage you right on their own page to play around with the benchmarks to make any arbitrary language rise to the top.
I only have an anecdote to add: I've recently reimplemented a Java calc server (finance) in Javascript (nodejs v0.6.8). WRT development time, the Javascript implementation was a breeze compared to the original Java implementation with far fewer lines of code. It was a breath of fresh air, really.
The Javascript-based server is able to calc through 2.4k trades/sec whereas the Java server handles 400+/sec on the same hardware using less memory. I wouldn't attribute the speed increase to raw V8 vs. Java 7 performance but rather to the implementation. The Javascript implementation uses far fewer data structures, does an order of magnitude fewer method calls and takes a more straight-forward and terse approach.
Needless to say, I'm very happy with the performance of node.js. And this, coming from someone who was Java only for many (9) years.
Here are some tests comparing Javascript (V8) and compiled Java:
32 bit
64 bit
They indicate that Java is generally faster1. However, if you dig around with those pages and the linked resources, you will notice that it is very difficult to compare like with like.
Interestingly, Javascript does significantly better than Java (under certain conditions) for the "regex-dna" benchmark. My guess is that this is because the Javascript regex engine is faster than the Java regex engine. This is not entirely unsurprising, given the importance of regexes in typical Javascript applications.
1 - Strictly speaking, you cannot say that language X is faster than language Y. You can only compare specific implementations of the respective languages. And the site I linked to is clear about that ... if you care to go in via the front page. However it is not entirely unreasonable to generalize from specific datapoints ... and the apparent of absence of contradictory datapoints ... that Java is typically faster than Javascript in computationally intensive tasks. But the flip side is that that kind of performance is often not an objectively important criterion.
Java, obviously.
Programmers love to compare execution speed like some sort of pissing content. It is just one metric, and the majority of the time, not the most important one by a long shot. Java is a language that has a mix of being fast enough for almost anything, but high enough level that you get stuff like GC, which you don't usually get in similar languages. Javascript is a dynamic closure language that is great for getting stuff done quickly (and for FP programmers stuck in an OO world ;-) ). There isn't much in the way of intersection in the spaces where either would be appropriate.
I'll stop pontificating now
EDIT: to address the edit in the post
Due to the way one writes idiomatic javascript (functions composed of functions), it lends itself surprisingly well to asynchronous programming, probably better then any other language of similar popularity. Node.js shines when it comes to a huge amount of short connections, so javascript is a really great fit for that sort of thing.
While node.js is absolutely drenched in awesome, being the new hotness really doesn't mean it is the best at everything, no matter what the hype says. If a java app is replaceable by node, chances are java wasn't really appropriate in the first place.
Probably not, but it doesn't really matter.
Prior to Google Chrome's JavaScript JIT, Java would win over JavaScript as soon as the problem got big enough to overcome the load time.
Java should still roundly trounce JavaScript due to integer vs. float math. No matter how good the JIT it can't really make up for this.
WebAssembly will turn this on its head anyway.
http://benchmarksgame.alioth.debian.org/u64q/javascript.html
(Remember to look at the cpu column as-well-as elapsed secs).
According to the above link JavaScript as reality stands now is much slower for almost everything.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have deliberated endlessly over which language/framework best suits the following. I need to develop a HPC framework. All processing will be completely OO. It will pass objects between instances (external) and internally between threads & engines. The Objects will be an extension of Active Messages.
These instances could run on mobile, Windows, Mac, Linux, etc.
The system needs to be able to perform highly parallel computing with speed & efficiency, ideally take advantage of SSE, and ideally support CUDA/OpenCL.
I have considered the following:
Java - it is memory hungry and doesn't run on Mac (not officially, anyway)
.Net - memory hungry; limited in platform scope; no native SSE
Delphi - not 64 bit; limited platform scope
C/C++ - not directly supported by Mac; complex to code; however it is ubiquitous
Objective-C - supported by Mac; appears to be supported elsewhere; works by passing messages, which is per my design requirements; don't know much about it
Any suggestions?
Here is my run down of some options (in no particular order):
C/C++
If all you care about is performance (and nothing else), these will provide. Direct access to system level constructs, such as processor affinity and inline assembly can certainly have an impact on performance. However there a 2 main drawbacks to the C/C++ option. Firstly neither have a well defined memory model, so the memory model you are developing against is that of the CPU you are running the system on (if you don't know what a memory model is how it applies to concurrent programming, then you shouldn't be doing it). This ties you very tightly to a single platform. The second is the lack of a garbage collector, manual memory management is tricky (but doable) in the simple cases, with C++ a number of supporting utilities simplify the problem (e.g. auto pointers/smart pointers). When writing concurrent code it is an order of magnitude harder as the rules for should release a certain piece of memory become very hard to define. E.g. when a object is passed onto a different thread, who's responsible for releasing it? If using C++ it's important to ensure that you are using thread safe versions of the classes used to help manage memory. E.g. the boost smart pointer only supports the use of methods declared as "const" across different threads (e.g. dereferencing is OK), however non-const methods (e.g. assignment) are not thread safe.
Java
Java would be my recommendation, it has support on all of the platforms you mentioned (including mobile, e.g JavaME and Android) as well as CUDA support. Java has a well defined memory model that is consistent across platforms, a robust and mature JIT and optimiser, and number of good and improving garbage collectors. Most general purpose applications written in Java will run just as fast as their C/C++ counterparts. While it is a bit of memory hog, if you are doing HPC work you are most likely going to throw some decent hardware at the problem. Given that you can address 100s of GB on commodity hardware, the memory problem is less of an issue than it used to be. Mobile is the only real area where memory usage is constrained and the specialist runtime environments perform better in this respect (see above). The only main drawback for Java (from an HPC perspective) is the lack of pass by copy complex types (i.e. structs in C#) so all complex objects have to be heap allocated putting pressure on the GC. Escape analysis is supposed to help with this somewhat, however it is difficult to get it do work well in very general cases (note that it has jumped in and out of various revisions of the JDK recently).
Worth mentioning the broad language support (Scala and Groovy++ have pretty good performance profiles) and there are a number of message passing concurrent frameworks (actors, akka, kilim).
C#/.Net
Probably the most complete from a language perspective, especially if you include things like F# for approaching things in a functional manner. However you are generally pushed toward an MS platform if you want the best performance (and the mobile story here is not great either). Mono produces a pretty good platform feature wise (caveat: I'm a contributor) however they are still playing catch up with performance, e.g. an accurate, compacting collector has recently been added and is still a bit experimental.
Google Go
Very new, but interesting from the perspective that it is natively compiled (no jit overhead), but still has a strong runtime, memory model, garbage collector and direct support for CSP (concurrent sequential processing) features in the languages (channels). Probably has some ways to go, the development of a new GC has gotten under way but not surfaced yet and there is probably a lot more they can get out of the compiler.
Haskell and other functional languages
Not a lot of experience here, but some of the functional constructs such as immutability and persistent collections can be quite useful for building robust concurrent applications.
The system needs to be able to perform highly parallel computing with speed & efficiency, ideally take advantage of SSE, and ideally support CUDA/OpenCL.
This narrows it down to C or C++. And since you want OO, it's narrowed down to just C++.
Seriously though, pick what you or your developers are best in.
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.
I know it's a hot question that need anwsers ^^
From my viewpoint, using Java vs PHP, is nowadays a problem of system resources (Hardware, Software, etc.).
For Java, you have to deploy J2EE Stack (JDK, AppServer, etc.) (~200M) on your server, for PHP you need to deploy a LAMP system (~100M).
Using Java was in my opinion due to object oriented programming in web application, but today we have a lot of Object Oriented Web Language (Ruby, Python, PHP).
So the question when to choose between Java or PHP for new projects ? Maybe the community difference ?
I know that stackoverflow is not made for discussion, but it's a (good?) question that need answers (for me and for others maybe) ^^.
What are you guys talking about....
Okay JAVA has some pros, but it also has some cons. Now with PHP it is exactly the same, it has some pros, but it also has some cons.
People who say PHP doesn't have a good OO environment, well either does javascript! And really that is the heart of all web 2.0 projects; javascript. The back end today is becoming more of a resource for the front end. What you can do in JAVA now days you can do in PHP 5.3 - to some degree. If you are a good developer you will be clever enough to abstract your design to make it maintainable and if you are brillant you can match and even improve object sharing in PHP, which majority of web "designers" don't know about - or dare I say, comprehend. Check this article out by O'Reilly ON JAVA!.
I develop both in Java and PHP. I'll always use PHP for my server side and I'll use Java for Android Development, and desktop development. (By the way I have developed in java for backend development, but it take twice as long to do something in JAVA then to do it in PHP. That is why I stick to PHP.
I hear this spagetti code problem with PHP all the time. Yeah. Maybe 5 years ago! If you project ends up like this then the person, or you, is a poor programer, and you should stick to drawing pretty pictures. It is easy to separate your logic from presentation, and it is also simple to separate your business logic from you data layer. Think before you code. Don't just open up a note pad and start typing. Plan! People who fail to plan, plan to fail! Jacco you're on the money!
I see uni students all the time building code where I think, "The person who is going to end up with this guy is going to regret it". If the student just planed and documented what he was going to do then every thing would be organised and ready for scaling - again if he was good enough.
Both technologies are great and you should use what is more comfortable to you or your developers. If you go down the road where you think one is better than the other and you know nothing about that technology, well guess what? No matter what you do your projects outcome will be missed, and you'll end up having to do it again.
Other constraints are usually taken into account. Things like
development time,
maintainance cost of the codebase
availability of qualified programmers
salary cost for available qualified programmers
to name a few.
Hardware and software are cheap if you compare them to the above so they tend to be less important.
I did a non-scientific performance comparison of J2EE and PHP. The comparision was to see the user experience of each system under various load conditions.
I found that PHP's response time was very slow and CPU maxed out very quickly. I understand there are some compilers that will probably help, but I wanted to make an out of the box comparison of performance of rapid development systems.
You can read the full details here: PHP vs J2EE: a Practical Approach
It depends on what you're doing. Choosing a language/framework without analyzing your project requirements is a bad idea.
Choosing a language depends on what you want to do, But I am very sure that the different hard disk space requirement will be the least important aspect of your decision.
Here is a possible hint: If you want to reuse your work (or parts of it) in a desktop application, Use Java. PHP is virtually non-existent for everything except web programming.
I really don't think that it is a question that can objectively be answered. In the end it is about people and what they feel more comfortable with. That is why e.g. Facebook developed a PHP to C++ compiler (with which the performance benefit that Java has might become smaller, too) instead of just hiring C++ developers for doing the Job.
On the other hand, the Java platform offers some interesting new approaches like Grails (which is basically a Groovy Wrapper around Spring) and Lift, as well. That makes Frontend development faster and easier (I still find that this is a real pain with plain Java) and you can combine the benefits that other languages have with your existing Java codebase and expertise (btw. most of the Frameworks mentioned don't need a J2EE runtime environment a simple Tomcat installation with around 5M and an installed JRE should be enough). So it is not really about the Java programming language alone anymore.
And if you really can't decide at all you just run PHP in Java (works as well for Ruby, Python, Javascript ...).
PHP wins in front end in web development. Because it has much smaller development time which make things cheaper and cheaper.
PHP will lose in mobile app development. There is no way to develop a mobile app front end with PHP. And Because its performance gap with java and other static languages, PHP will lose the back end battle. Java is old, but it has a pretty young and professional community. Check out those names: lucene, weka, hadoop,scala,cassandra, hbase, what does php provide us in back end service???????
I do not really agree on the fact that the choice of a language is related to system resources.
Hardware is cheap and we are not in a time where we need to closely look at the system resources as we used to have. Don't misunderstand me: we still do need to pay attention, but the time where people were xoring their pointers to save some space is over (luckilly).
And if your main concern is performance, then either running a JVM or an interpreted language is probably not the best option.
I do not think it is related to the orientation of the language per se either. Ok, I know, PHP is not object oriented but still, you can now code OO with it. You will find descent web frameworks for almost any language.
I agree with Jacco on his list.
Another aspect is indeed the culture the language refers to.
PHP is for script kiddies. Java is for serious, wearing suits business developers. Of course, we all have many counter examples but still. Java was largely adopted by big companies, now competited by .Net. There are good reasons for this, among which the fact that it a lot easier to write poor code in PHP than in Java (and almost any other language). On the other hand, Java is not exactly freedom oriented.
If your project is strictly personal, you can choose whatever suits your tastes better. If you plan to develop as a team, the choice of the language will impact its general mood/way of thinking.
I would finally add some important parameters to me: fun and elegance
This may be a matter of taste here again, but I have much more fun coding in python than in C# for instance.
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.
I've been doing some research into taking my programming experience and moving into the java programming marketplace, due to a combination of personal interest and local market forces. As you can gather from the title, the vast majority of my experience has been in building web-based sites and applications, and I'd like to move as much of my previous experience as possible.
One thing that I've been unable to find a concrete answer for when should a website or web-based application designer look to going with a Java based solution, over other options currently on the market. What options would Java provide that would have a designer select Java as the basic coding language to base a project upon?
Thank you for any constructive replies that may arrive from this inquiry.
EDIT: I should have included the caveat of if other factors are equal, for example if hardware, software, developer skill in java is up to where they should be for such projects, and so forth.
The main factor is what your developers are adept in. If you've got a bunch of Java developers, go with Java.
Consider this also: Java tends to run on app servers where there is a persistent global program running, and separate threads/processes spawn off to service individual requests. However, if the main global VM croaks for some reason, your whole app can go down. The benefit of course is that you get application/system level resources that you can initialize and use continuously across all requests
Other environments like PHP basically tear down and rebuild the entire environment for each request. You can code in application level data persistence using a database, but you don't get it for free. On the other hand, if one php process croaks while processing app data, it won't kill the whole system , as the entire environment is just torn down/rebuilt for the next request.
Agreed with many of the previous posters, but one possible consideration is runtime speed.
If you are using a very basic LAMP stack server, running PHP4 or lower, Python or Perl, if you do not set pre-compilation, all of your scripts will have to be re-compiled at runtime. This can cause immense stress on the server for high intensity applications. If you're in the situation where you cannot enable pre-compiling for LAMP, but you can for Java (most Java servers require this), then this should be of concern. The disadvantage is that you may have to re-compile large chunks of your web application every time you edit it. I realize this is becoming less and less of an issue nowadays, but its something to check.
Be sure to include a learning curve in the development time if developers aren't familiar with the chosen language.
For the most part, the best technology is the one you are already using.
If you have coders that know java, have system administrators that can configure java apps and know what to do when a java app stops working, and project managers who know how to accurately schedule and plan a java deployment, you would need a very, very compelling reason to pick something else like .NET for a new project, even if .NET is "better" (whatever that means).
There are, of course, exceptions; if you're using something obsolete and/or is not going to be supported in the future (like classic ASP), or you have no legacy systems, then it's time to use something new.
I believe that the conventional wisdom on this subject is that Java is better suited to very large systems that need the discipline of static typing. Also, on very busy sites, Java can use less memory and run faster than most interpreters.
(Right out of the box, Java wants lots of memory. But on a busy system Java has only one copy of all running code.)
There are also certain prosaic reasons to stick with Java, for specific sites. They might need back-office integration or some other big piece of existing code.
I would use Java if there was a library or framework that provided specific features that no other language did (or not as well).
For example, if I had an in-house-built java library for running our Gruntmaster rock crusher, then it naturally would make sense to use Java to build an app that needed to control the Gruntmaster.
Some might say that whatever one's shop's official language is the language one should use--I disagree with that rule, as in my experience a good developer can learn any language.
There is no hard and fast rule otherwise; each language has its own strengths and weaknesses. The fact that you are asking this question about Java tells me that you are not as familiar with it.
I'd suggest you go ahead and build an app or three in Java -- then you'll know. :)
There is very little separation between the capabilities of the various technologies available today for web programming.
Java at one time was the default choice since it far surpassed the abilities of the competing technologies, but that is no longer true.
The Microsoft answer has matured rapidly; the days of classic ASP are far gone with .Net now providing all the abilities and ease of programming that Java has offered.
New languages such as PHP and Ruby have arrived or become much more mainstream, and are also valid choices based on your programming needs.
So as many others are saying it boils down to what language you or your developers are familiar with.
Another aspect to consider, is the ability to use a vast eco-system of open source libraries.
Languages like PHP, Perl or Ruby have such lib market places (almost) built in. .Net is rather closed in that sense. Java on the other hand has a a very large, enterprise grade eco-system of libraries to choose from and communities to learn from as well.
Practically I agree with the guys about leveraging existing human infrastructure.
Technologically, Java is quite good for non-standard web things - like heavy use of AJAX (GWT, DWR, Comet spring to mind), Mobile (where you generally need lots of session data and less front-end bling), really simple things that are going to be put under immense load (it will definitely trounce Apache mod_XXX every time, the only thing faster in wide-spread use is native code).
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.
As a Java newbie I'm wondering: of all the languages in the world, why is Java frequently used for enterprise applications? What makes it that way compared to the other languages? Will it continue to be this way in the upcoming years?
I'd appreciate your insights. Thanks in advance :)
One word: libraries. Java has an vast array of excellent libraries for solving most of the common problems one needs to solve when developing enterprise applications. In many cases, there is more than one good choice for addressing a particular need, and oftentimes those libraries are free and open source under a business-friendly license.
Some have argued that there are, in fact, too many choices in the Java ecosystem, and that developing enterprise software in Java requires developers to make a large number of decisions that can have far-reaching impact on the end product for better or worse. This has probably helped propel the popularity of alternatives like .NET, which has a reputation of offering fewer choices, but with the benefits of a more well-integrated application stack and tools set. What direction you choose depends, I guess, on whether you place more value on "freedom of choice" or "freedom from choice".
There are lots of reasons a large company (the type to go for enterprise solutions) would pick Java. Note I'm not saying all these reasons are correct or valid. But the relevant point is that they appear valid to a CTO at MegaCorp.
Learning Curve
Java is a simple language without much of the flexibility of other members of the C family, this cuts both ways, but it is seen as a straightforward language for use by an army of programmers. Enterprise projects tend to involve large numbers of developers (rightly or wrongly) and it is much easier to get a developer to a minimum level of competence in Java than C++. You also have a whole generation of graduates who have probably been largely schooled in Java.
Choice
Java has a vast array of libraries, frameworks, tools and IDEs, and server providers. To an enterprise its good to have choice, even if that's just for use as a bargaining chip when negotiating price. The language lends itself to code quality tools that allow enforcement of corporate standards (and as mentioned there are a lot of those tools).
Platform Independence
Java is write once, run (well, debug) everywhere. Sun has actively encouraged open standards that allow multiple vendors to implement their solutions. These standards give the customer the comfort that they can migrate from one vendor to another if a given vendor goes under or starts charging more. Of course the reality is that each vendor does their best to provide some "added value" features that tie the customer to them quite nicely.
Maturity
Its been around a long time, running a lot of servers. If your web application needs to be "6 sigma" or similar and you are the MegaCorp CTO, you are not going to look that kindly on Joe the developer wanting to do it in RoR.
Timing/Marketing
Java came out when programming was moving towards the web. It was positioned cleverly and got a strong position early in web development. Because of the open standards, there are some very big companies producing these platforms and they market Java pretty hard to sell those platforms.
Inertia
Large corporations move forward at a glacial pace (a lot are still using Java 1.4 five years after 5 was released), so once they've picked Java, it takes a massive investment to move to another platform. With each day that goes by they're cranking out more Java that would need to be migrated. Most of these companies are not primarily coding shops, so it is a very hard sell to convince the business to spend a few tens of millions rewriting their entire code base for no immediate business benefit.
Another reason might be the care Sun has taken to keep Java backwards compatible. The vast majority of Java code can be run on the latest version of the JVM without a problem. That is quite an achievement, given the age of Java. On the other hand you might argue Java has not changed all that much in all these years.
Enterprises like stability in a platform.
Sun targeted Java to speak to the needs of enterprises early on. It pushes standards that promote vendor independance at every level. Platform independant, database independant, application server independant, etc.
In addition they promoted enterprise level tools for it, in terms of messaging, transaction management and other things that the enterpise worries about.
Before Java, enterprise level stuff tended to be done in C++ (there were plenty of exceptions (does anyone remember PowerBuilder?) but that was the rule) and Java fits well as a successor to C++ for business applications, where that kind of memory management isn't something worth paying for.
In addition to all of that the language itself speaks to enterprises in terms of avoiding hard-to-get-right constructs that can really mess up a code base, such as operator overloading. Enterprise level applications tend to get handled by many different hands, not all of which are the top of the line programmers, and having safty nets to prevent shooting themselves in the foot is a desirable thing.
It also came along at the right time. A new paradigm (this was well before .NET existed) that promissed to combine multiple vendors into an ability to compete with Microsoft, which got the likes of IBM and Oracle on board, that happened to fill a new hole, which was the emerging requirement to develop web applications, where C++ was no longer an obvious choice.
I shouldn't be saying this, but...
The real reason is because it's named after coffee!
Business is about time, money and opportunity.
Using Java means that your number of errors in the code goes down, simply because pointers are hard. You use a GC and you instantly remove an entire class of errors from your code.
Secondly, Java was one of the first languages to ship with a pre written library of functions, which really did cover a lot of the development phase. This restricted the way things were done but it meant that people could learn faster, had more tools at their disposal and had a great set of libraries to do things like network, GUI, web, encryption etc. Java on its own as a language really wasn't that special, but Java plus the Java API was.
So if you've got a language that has less errors and more infrastructure for free, then you end up with more code in less time. Sure the code doesn't cure cancer, it's not as fast as C++ code to achieve the same task, but it will achieve the business' goal of getting an application.
If you make more code, for less money, you can pursue more opportunities. You then bring inertia to the table in terms of code that's already been implemented in Java and you start seeing why the business doesn't want to move away from their comfort zone.
Personally I believe one major reason is the cross-platform issue.
Java programs written "correctly" (without assumptions of the underlying operating system) can run on any JVM. This means that you are not tied to a particular platform, unlike .NET which marries you to Windows.
I have seen Java code run on mainframes, Linux routers, inside Oracle database, and naturally on PC's.
It's cheap, RAD, cross-platform, and developers abound.
Developing in C++ is too slow and expensive and .NET has not been around for long enough. Business inertia is huge, remember.
Businesses want languages that are backed by a professional provider (ie. a company like Sun) and often stay away from Open Source languages for the simple reason that it was not written by a company.
Also for client-server applications, you have an abundance of choices for production-quality app servers that have the same J2EE interface (IBM WebSphere, BEA Weblogic, JBoss). Alternatively, you could use the Spring Framework on any server like Apache Tomcat the complies to the Servlet API if you're convinced you don't need EJBs. In contrast to .NET, it's hard to find choices with respect to app servers.
There are an abundance of choices with regards to frameworks for a given task be it an ORM tool, logging, collections, caching, web UIs, etc. There is no hardly any need to reinvent the wheel.
Finally, while it's fashionable these days to lament the very real shortcomings of Java the language, it's a language where folks know how to get things done and how to avoid certain anti-patterns.
The other answers are all good. Two things need to be added, corporate standards and the bandwagon effect. If you want to build an enterprise system you need to have pretty strong case for not using your company's entrenched standards and this is mostly JavaEE. And if you need to resource a project it is a lot easier to recruit a Java programmer than it is, say, Erlang.