views:

307

answers:

6

[This is an empirical question about the state-of-the-art: I am NOT asking if Java is cooler or less cool than the dynamic languages that work in the JVM.]

Aside from cases where performance is a main decision factor, do companies/developers still willingly chose Java over Groovy, JRuby or Jython?

Edit: If the answer is "yes," why?

Personal Note: The reason I am asking is that, while I do some subset of my professional work in Ruby (not JRuby, for now), in my personal projects I use Java. While I have written non-trivial apps in Groovy, I prefer Java, but I wonder if I should just get over it and do everything in Groovy. I like Java because I feel that static typing saves me time and aids refactoring. (No, I am not familiar with Scala.) However, I feel that this very empirical, on-topic programming question may inform my decision.

+1  A: 

Since you are asking an empirical question, and I assume looking for empirical answers:

Aside from cases where performance is a main decision factor, do companies/developers still willingly chose Java over Groovy, JRuby or JPython?

Yes.

I don't think there is anything else to say.

matt b
Good point, I'll adjust my question.
Yar
So why are they still choosing Java? Is it an inertia thing (which to me implies that it will change someday), or based on language features?
Yar
you'd have to ask each individual company and developer, this is really an unanswerable/subjective question. 1) familiarity 2) knowledge 3) comfort 4) etc
matt b
@matt b, it's not subjective, though the data needed to answer would involve knowing what developers and companies think. But if you had to speculate, based on experience and your knowledge, would you say that "inertia" (familiarity, knowledge, comfort) explains choosing Java where performance is not a concern most of the time in 2010?
Yar
Yes, but I don't think that is necessarily a bad thing either. Also, performance often is a concern.
matt b
+5  A: 

Aside from cases where performance is a main decision factor, do companies/developers still willingly chose Java over Groovy, JRuby or JPython?

Yes, and I believe the main reason is inertia, either on the part of the developer or the company:

  • Company: existing investment in Java (in terms of staff skills and infrastructure), the risks of change are perceived to outweigh the benefits
  • Developer: there are plenty of Java jobs available, so why bother learning another language?

Lack of available resources is probably another reason, though this is something of a chicken-and-egg problem (or a Mexican standoff, or a self-fulfilling prophecy, or something else). I imagine there are a lot of companies watching Groovy, Jython, etc. but waiting for them to become more widely adopted before taking the plunge. Obviously, by postponing adoption themselves, they're exacerbating this lack of resources problem.

Personal Aside

I spent the last year working as a Groovy/Grails developer. I recently changed jobs and am now working as a Java 1.4 developer and (compared to Groovy programming) it's about as pleasant as gouging your eyes out with a rusty spoon.

Static typing is great in that it facilitates compile-time checking and code analysis tools like FindBugs, but no way does it compensate for the massive amounts of (boilerplate) code it takes to accomplish the simplest of tasks when writing Java (particularly if you're using a version earlier than 1.5).

Don
@Don, thanks for that, +1. Interesting, but it doesn't bode well for Java moving forward: is anyone choosing Java due to language features?
Yar
Regarding Groovy vs. Java 1.4: I feel your pain, but it's kind of unfair to compare such an old version as Java 1.4 (which is already at its end-of-life for quite some time) to such a young language as Groovy.
Joachim Sauer
+1 for pointing out inertia. That's a huge driver in decision, change is unsafe and using new technology makes managers nervous. While a few companies thrive on real innovation, most prefer copying a formula (language, platform) that worked elsewhere and feel much more comfortable with lagging behind.
Etienne
@Yar - The only way I could see Java being chosen based on it's features is if a lack of features is considered a good thing. Some might call this lack of features "simplicity", but I call it "frustration".
Don
+5  A: 

Static typing still is a big thing.

While it has been argued over and over again and proponents of the dynamic approach say that the problems that dynamic typing bring can be reduced (or even eliminated) with sufficient unit tests.

I don't want to argue whether or not this argument is correct, so I'll assume that it is, for this answer.

In that case there is still one problem, which is that many shops don't have the procedures/know-how/rules/management to produce a sufficient number of high-quality unit tests.

And if I have to choose between dynamically typed code without unit tests and statically typed code without unit tests, I'll choose the statically typed one every day.

A similar issue exists with double dispatch:

In Groovy method calls are dispatched based on the actual types of the arguments at runtime (which is almost required, because the static type is unknown and/or Object most of the time). This means that there is no reliable way to know which method is called at any given point at the code, when faced with extensible class hierarchies.

Any code that calls a method with the signature foo(String) most of the time may suddenly call foo(Integer) or foo(SomethingElseEntirely) depending only on the actual type of the argument at runtime. In the Java language that can never happen, because the exact signature of the method to be called is decided at compile time.

Much like other "dynamic" language features, double dispatch is occasionally a very useful tool and the lack of it can produce some ugly constructs in Java, but it has its cost in that it makes it even harder to read, understand and reason about code.

Joachim Sauer
That's true, but isn't code with unit tests the inevitable future for everybody, even in Java? For usage example for the Java Collections code, the standard answer is, "see the unit tests."
Yar
@yar: in an ideal world: true enough. In the real world: I'm afraid that we won't ever reach that utopia. Also: there's still the question if unit tests actually negate all the problems of dynamic binding, which isn't definitely answered yet, in my opinion.
Joachim Sauer
Writing unit tests should be mandatory regardless of the programming language used, but why throw away the extra safety that the compiler provides? The idea "we don't need type safety, we just write unit tests!" sounds foolish to me...
Jesper
@Jesper: I don't agree with the argument that unit tests can replace static type checks, but I heard it a lot. I just wanted to avoid the discussion and show why unit tests are not a sufficient solution even if we assume that the argument is correct.
Joachim Sauer
@Joachim - I think you're overstating the significance of double dispatch. This is only an issue when you have overloaded methods in the same class that take the same number of args, and the args in equivalent positions have a parent-child relationship. It's a fairly rare occurence. Moreover, polymorphism has exactly the same "problem", i.e. you don't know until runtime which implementation of a method will be called
Don
@Don: true, it's not a common problem. Which makes the problem worse, because people don't tend to think of that difference. Also, with single dispatch the problem is quite different: When a method overrides another one, then it's well-known that it must be drop-in compatible.
Joachim Sauer
@Joachim Sauer, while double dispatch problem is just another example of moving problems from compile-time to run-time (and therefore not going to change anybody's mind who thinks Groovy is groovy), it's also the price you pay for wanting to do "Dynamic Java." In Ruby, there's just no operator overloading, and I think it makes no sense in dynamic languages. Poor Groovy, like any language, suffers from non-language factors (wanting to interoperate with Java). Sorry that I have no point in this long comment :)
Yar
@yar: personally I find Groovy to be a very groovy language, and I love writing code in it. I just think that Groovy is just one more tool in my toolbox and it won't displace Java completely, because for many things I prefer (or even need) the more explicit, more verbose approach of Java.
Joachim Sauer
+1  A: 

I can tell you what is going on in my company. Our current application is done in java, but we have started a transition to grails/groovy and this will most probably be the platform for the next generation of our products.

Dan
anecdotal evidence isn't that fascinating, but +1 anyway, since it does help, thanks.
Yar
+2  A: 

Yes, obviously.

Why are companies still "willingly" using Java?

Because companies are inherently conservative. They don't change technologies because they're cool, or even groovy. They change, reluctantly, when there's a prudent reason to do so. Early adopters pay very heavy penalties for being early adopters.

Edit: this is not "inertia" in the pejorative sense, as in "no reason to avoid change except resistance to change", but in the sense of prudence. It is right for companies to not abandon what's working, until there's something that's provably better.

And not in the "makes developers happy because it's cool" sense of better, but in terms of more quickly and reliably meeting whatever business requirements drive development in the organization.

Java offers:

  1. Large base of trained, experienced developers. It's hard enough finding people who are able to do software development well, without picking a language which hasn't been around as long. And training people in a new language is expensive, in both time and money.

  2. Brand-name recognition and an easily proven track record of successfully completed projects. This is nothing to scoff at: if I tell upper management I'm beginning a project in some groovy new language they've never heard of, I have to educate them on it, and they'll rate that as a risk. With any "established" language, I can skip that step.

  3. Well-established, mature support tools, and third-party support.

These advantages accrue to any comparison between a long-established language and a new one, not just Java and your list. I expect that one day, Groovy, et al, will be the established language, and there'll be people asking the same question about some newer, shinier language. This is the cycle. It's how it's been for longer than I've been in the business.

CPerkins
Awesome, +1. Thanks for contemplating and thinking about this objective and empirical programming question. So if you had to take a completely wild, speculative guess, would you say that dynamic languages will replace static languages in the long haul?
Yar
@yar I would expect my guesses to be even less value in an objective discussion than anecdotal evidence, but my not-entirely speculative guess is that **no, dynamic languages won't replace static ones**. My reason for thinking this is that languages don't get replaced. They become less used, less cool, even "legacy", but they don't get replaced. Consider: **people are still writing Cobol**.
CPerkins
Very true, @CPerkins. Personally, I'm waiting for my train to come in, to find a language that can refactor/autocomplete as well as Java, but is dynamic and fun like Ruby. SmallTalk and Scala keep coming up in conversations recently. I might be forced to check out Obj-C soon, since it's the iPad language of choice, which is a relative. But yeah, a pluralistic universe, that sounds about right given what we've seen so far.
Yar
@Daniel 'yar' Rosenstark Sorry I missed this comment somehow. I'm waiting for my airship too, at least for the next evolution.
CPerkins
+3  A: 

non-statically typed languages don't "scale" well in the maintenance sense. Up to a few tens of thousands of lines of code they are maintainable. Past that they just take more effort to maintain, re-factor or update. This is true of any of the non-static typed languages, Perl, Python, Groovy, Ruby etc. The tools for working with half a million lines of Python code vs the same number of lines of code in C/C++/Java just aren't there. Now it is true that Python is about 1/3 to 1/5 the number of lines of code as an equivalent Java program. So this is never going to be apples and oranges, but there is a cut off point where the number of lines of code in a non-static language will have diminishing returns on maintenance. And everyone knows that maintenance is where the true cost of a software project has always been.

fuzzy lollipop
+1 what kind of tools are there for Java that allow you to work with half a million lines of code (that are not there for Python)?
Yar
why would anyone create 50 KLoC + projects any more?
Dan
any refactoring IDE like Intellij IDEA that can refactor across an entire code base based on Type, which no Python tool can, because there is no type information at non-runtime. And 50lk LOC is not a lot of code in a carrier grade solutions, most people don't have to work at the problem domain where they have millions of users and millions of concurrent users, so most people don't see the need for the scale of code I am used to using as an example.
fuzzy lollipop
@fuzzy lollipop, it's interesting, but I don't know what proportion of projects that would be. On the other hand, you're making a point that's actually deeper: refactoring might NEVER be possible without type information. I wonder whether that's true. I asked that once -- http://stackoverflow.com/questions/2317579 -- but the question got taken over by SmallTalk answers and never really took off :)
Yar
the majority of projects I work on are well into the 100'sk SLOC, so proportion isn't an issue for me, everything I work on is large scale and I have to be able to architect for maintenance of solutions of that size.
fuzzy lollipop
I don't doubt there are still people writing monolithic apps, I just wonder why?
Dan
nothing monolithic about anything, I am working on. I have over a dozen different services that run in stateless clusters, they just have lots of business logic in them. Lots of GUI logic in them, lots of GUI code period. Vertical integration projects are especially complex because of the logic mapping systems to one another. Just because there are lots of SLOC doesn't imply anything about the architecture.
fuzzy lollipop
multitier apps can also be monolithic, for example 100s of entities (or services) in a single app. As a sidenote, grails makes creating modular web apps a breeze with their plugin architecture. In standard J2EE you need a lot of plumbing to pack few wars into one.
Dan
but he said other than performance reasons and Groovy preforms TERRIBLY compared to straight up Java.
fuzzy lollipop
@fuzzy lollipop, regarding performance check out this article: http://www.ibm.com/developerworks/library/j-jtp12214/groovy is compiled into bytecode and on modern vms measuring performance is not that simple.
Dan
you say that groovy is compiled to bytecode like that means something, it doesn't, groovy has many levels of indirection to enable the syntactic sugar that it uses and they all add up to many extra cycles to do all the indirection to do the same thing in straight Java. Groovy __is__ slower than Java for most things, that's just a fact. That article you link to is about Java, a lot of those JIT optimizations can't be done with groovy because of all the intermediate classes and indirection and reflection that is done by groovy. groovy bytecode != java bytecode.
fuzzy lollipop
groovy is slower than java, no doubt about that, but the difference is generally exaggerated. Check out another article:http://wiki.jvmlangsummit.com/images/8/8c/Theodorou_Groovy.pdf"Hotspot need much longer for groovy"
Dan