The Artima Developer Community
Sponsored Link

Java Community News
Groovy, JRuby, or Scala: Which JVM Language to Learn Next?

45 replies on 4 pages. Most recent reply: Nov 10, 2007 11:38 AM by Jamie Lawson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 45 replies on 4 pages [ « | 1 2 3 4 | » ]
Berco Beute

Posts: 72
Nickname: berco
Registered: Jan, 2002

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 13, 2007 12:26 PM
Reply to this message Reply
Advertisement
I'm suprised the original author left out Jython in his comparison. The Jython version of the code, as shown in another reply, is remarkably short, clean and readable. Although I would prefer any of the alternative languages over Java, Jython/Python would be my choice. No doubt.

Jayce Vaidyan

Posts: 8
Nickname: finite42
Registered: Mar, 2007

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 13, 2007 5:16 PM
Reply to this message Reply
> > Hoe about Jython (Python). If I'm not mistaken here's
> the Python version....
>
> Jython 2.2 supports enumerate(). So one can omit the line
> counting boilerplate:...

To make it even more terse (very un-Pythonic and would only run in CPython 2.5 and later):

MAXLENGTH=4

for filename in sys.argv[1:]:
for l in ("%s line=%d chars=%d" % (filename, n, len(line))
for n, line in enumerate(file(filename))
if len(line) > MAXLENGTH):
print l


Also, the question is whether this example is a good one for comparison?

One that involves some basic error handling and resource management would be more appropriate.

The following C++ code provides equivalent functionality including automatic resource management (in this case files). It isn't as horrible as I would have expected it to be.

const int MAXLENGTH = 4;

int main(int argc, char* argv[]) {
for (int i=1; i<argc; i++) {
std::ifstream ifs(argv[i]);
std::string l;
int n = 1;
while (std::getline(ifs, l)) {
if (l.size()>MAXLENGTH)
std::cout << filename << " line=" << n << " chars=" << l.size() << std::endl;
n++;
}
}
return 0;
}


Now, what would happen if we add some simple error testing and recovery to the above? How would the code complexity and ugliness increase?

Comparison of the rate of growth of ugliness/verbosity with functionality might be a better way to compare terseness.

I think I am straying too far from the Java platform centric nature of this discussion. So I'll stop now.

That said, I think I will go with Scala, because it is the only one that gives me the good things from both the OO and functional worlds without weird syntax, and has slightly better integration with the Java platform.

Zeev B

Posts: 1
Nickname: verybz
Registered: May, 2006

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 14, 2007 6:11 AM
Reply to this message Reply
Jython is my choice.
Learning Python is easy and you can be productive very fast since you can start using it as a simple scripting language and gradually pickup the more complex and powerful features as you continue.
You can do a lot with Python in and out of the JVM, there are lots of useful open source libraries to choose from and a very friendly community.

Harrison Ainsworth

Posts: 57
Nickname: hxa7241
Registered: Apr, 2005

Scala Posted: Oct 14, 2007 8:27 AM
Reply to this message Reply
Scala is strictly typed, so it doesn't have Ruby's dynamism and introspection. But it is more strongly functional (that being good).

I would compare it to OCaml. Scala's OO is more familiar, and the packaging/namespace support is significantly better (and the JVM context adds much too).

Overall it seems to have something of everything, while remaining elegant.
Noteworthy, perhaps, are:
* smooth functional-OO blend
* good concurrency support (including Erlang-style actors)
* type inference
* pattern-matching
* embedded XML support
* generics, operator overloading, and many other small features...

(I think Scala needs better documentation 'between' introduction and specification, though.)

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 14, 2007 1:16 PM
Reply to this message Reply
With a little more work on adopting JRuby, Java has been successfully adopted as an alternative for my server-side work. That is, by now I have WEBrick and Mongrel with Ruby and WEBrick and Grizzly with JRuby. For some reason there's an issue with the way I use Mongrel with JRuby so I can't fully count on it just yet. On the other hand, Grizzly seems to be a good alternative to it anyway.

That is, I have been working on a framework for Ruby which includes Web programming. To exercise it I have about ten different applications working simultaneously in the same space. For the most part, all of this can be run with Java or with Ruby now, which is way cool. There's still more work ahead, but I am confident that JRuby has matured a good deal already, because it has been able to run a lot of Ruby code with a good deal of compatibility.

Thanks for JRuby Sun! Hopefully startups will be able to exploit the possibilities enabled by it.

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 14, 2007 1:27 PM
Reply to this message Reply
Oops. Mongrel was working so well for JRuby for me that I forgot that I had been testing it successfully by now. Yesterday was a full day with a lot of JRuby related work that I had forgotten about this progress. Some of the problems I was having had to do with compatibility with JDBC which once fixed helped fix other problems elsewhere.

BTW, it feels nice to use Java on the server-side. Besides the potential need for more memory and occasional "OutOfMemory" errors, I hope it will continue to be a painless thing to do, even from JRuby. ;-)

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 15, 2007 6:17 AM
Reply to this message Reply
> I support Scala, because it's a great language, because
> it's fast, and because it's not "just" the
> reimplementation of an existing language (JRuby/Jython) or
> a "me too" (Groovy).
>
> Also, it has a nice type system.
>
> Basically, I support scala because I think scala is (or
> tends to be) what Java should have been or should have
> become.
>
> Plus it has pattern matching, none of the others have it,
> to my knowledge.

I think Scala is a good candidate for replacing Java but JRuby, Jython, and Groovy are complimentary languages.

Nemanja Trifunovic

Posts: 172
Nickname: ntrif
Registered: Jun, 2004

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 15, 2007 4:28 PM
Reply to this message Reply
> I think Scala is a good candidate for replacing Java

Technically yes, but is there a marketing support for it? Unlike Groovy, I don't see Scala being pushed by Sun.

Dave Webb

Posts: 55
Nickname: lazydaze
Registered: Feb, 2006

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 16, 2007 4:14 AM
Reply to this message Reply
> > I think Scala is a good candidate for replacing Java
>
> Technically yes, but is there a marketing support for it?
> Unlike Groovy, I don't see Scala being pushed by Sun.

You cant blame Sun for wanting to milk their Java cash cow for as long as they can, and JRuby and Groovy complement Java so there's no problem for Sun with those languages.

But Scala represents a direction that is ultimately irresistable for the market that is currently dominated by Java. At some point there will be a critical mass of coders who grok what Scala's about, and Java will start looking like Cobol, and marketing people aint stupid.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 16, 2007 6:19 AM
Reply to this message Reply
> > I think Scala is a good candidate for replacing Java
>
> Technically yes, but is there a marketing support for it?
> Unlike Groovy, I don't see Scala being pushed by Sun.

That's the big question about Scala. I think it's gotten a lot of visibility without much marketing which is pretty impressive. There are many other languages for the JVM that are going nowhere fast like Pnuts and Pizza. Maybe it's just because Scala sounds more serious. Who wants to put Pizza on their resume? But I think it's more than that.

The question is whether Scala will break out into a more general usage and be taken seriously by 'the suits'. I think in addition to the lack of a corporate sponsor, Scala is a little inaccessible and has a very academic feel to it and it's community.

Bill Pyne

Posts: 165
Nickname: billpyne
Registered: Jan, 2007

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 16, 2007 8:55 AM
Reply to this message Reply
> The question is whether Scala will break out into a more
> general usage and be taken seriously by 'the suits'. I
> think in addition to the lack of a corporate sponsor,
> Scala is a little inaccessible and has a very academic
> feel to it and it's community.

I don't think either C or C++ had corporate sponsors. Certainly Bell Labs, as part of AT&T at the time, had a "big daddy" but I don't remember a marketing campaign. Yet they are both well established in the industry. There's a larger historical context at work here so I don't want to claim their rise to fame was purely meritorious.

Please indulge my statement of the obvious but Scala will be adopted if it can provide something that Java doesn't. If it has nothing to offer other than a prettier syntax then it'll be little more than an historical note. Only time will tell as developers try to write new applications using it and discover what Scala has to offer.

I wouldn't write Scala off yet. If someone like myself, who learned development on the job, is curious about it, then it has a fighting chance outside of academic circles.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 16, 2007 10:32 AM
Reply to this message Reply
> Please indulge my statement of the obvious but Scala will
> be adopted if it can provide something that Java doesn't.
> If it has nothing to offer other than a prettier syntax
> then it'll be little more than an historical note. Only
> time will tell as developers try to write new applications
> using it and discover what Scala has to offer.

I don't think that it is obvious. There are many languages that have more to offer than Java and have not been accepted widely. Ask a Smalltalk or LISP person. You'll get an ear-full. One of the big lies that is sometimes stated but more often assumed about capitalism and evolution is that these processes always produce the best result or more clearly that the best product/company/life-form will always triumph. The reality is more like poker tournament. The better players are more likely to win but are not immune to a bad run of cards. Conversely, it's very possible that an average player can get a run of luck that puts them so far ahead of everyone else that they are almost surely going to win as long as they don't totally blow it.

The same is true for programming languages. Just because a language is great doesn't mean it's going to thrive. Java is where it is not because it was the best language. It's where it is because it was good enough, easy to learn, and in the right place at the right time.

I've said this again and again: if Scala is going to gain acceptance, it needs better documentation. And not just hello world and here are some cool features. An in-depth explanation of the language fundamentals through developing real applications is needed. I've read what is out there (unless something new came out in the last 6 months or so) and I don't feel it is adequate.

Cedric Beust

Posts: 140
Nickname: cbeust
Registered: Feb, 2004

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 16, 2007 12:35 PM
Reply to this message Reply
All very good points, James. I especially like the poker analogy.

Java's success was definitely not a complete fluke. It certainly came out at the right time and at the right place, but it also solved a few pain points that programmers were getting increasingly frustrated with (mostly because of C++), among which:

- Friendly syntax that is close enough to the C family but doesn't suffer the C++ extremes.
- Garbage collection

Also, don't underestimate the "instant gratification" aspect, which helped PHP so much as well: back then, Java applets were all the rage and it was very exciting to put life in our boring web pages.

Interestingly, Java ended up being very weak in this area and very strong in areas that nobody would have suspected, but this initial boost was enough to make it the success it is today.

--
Cedric
Author "Next Generation Testing in Java"

Bill Pyne

Posts: 165
Nickname: billpyne
Registered: Jan, 2007

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 16, 2007 12:51 PM
Reply to this message Reply
> One of the big lies that is
> sometimes stated but more often assumed about capitalism
> and evolution is that these processes always produce the
> best result or more clearly that the best
> product/company/life-form will always triumph. The
> reality is more like poker tournament. The better players
> are more likely to win but are not immune to a bad run of
> cards. Conversely, it's very possible that an average
> player can get a run of luck that puts them so far ahead
> of everyone else that they are almost surely going to win
> as long as they don't totally blow it.

True enough. Combinations of circumstance and choice seem to produce what survives. People like to believe in more determinism.

> The same is true for programming languages. Just because
> a language is great doesn't mean it's going to thrive.
> Java is where it is not because it was the best language.
> . It's where it is because it was good enough, easy to
> learn, and in the right place at the right time.

I think that Martin Odersky gave Scala a fighting chance by choosing to let it compile down to bytecodes for the JVM. Developers can use already developed libraries, in some cases ones that have been well-optimized, to produce applications. My assumption is that along the way the developers of Scala will give the option for libraries produced in Scala as an alternative to Java libraries.

He also chose two paradigms that bring together the academic and business communities: functional and object-oriented.

Basically, he's made intelligent choices to give Scala a chance in the wild.

> I've said this again and again: if Scala is going to gain
> acceptance, it needs better documentation. And not just
> hello world and here are some cool features. An in-depth
> explanation of the language fundamentals through
> developing real applications is needed. I've read what is
> out there (unless something new came out in the last 6
> months or so) and I don't feel it is adequate.

I agree it's necessary. At this point, I'm tired of looking at the same examples over and over again so I'm going to dust off some old app server code I wrote pre-2K and re-write using Scala features.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Groovy, JRuby, or Scala: Which JVM Language to Learn Next? Posted: Oct 16, 2007 1:55 PM
Reply to this message Reply
> All very good points, James. I especially like the poker
> analogy.

Well, poker isn't one of the classic game theory subjects for nothing. It's a good simulacrum for free-market competition.

> Java's success was definitely not a complete fluke. It
> certainly came out at the right time and at the right
> place, but it also solved a few pain points that
> programmers were getting increasingly frustrated with
> (mostly because of C++), among which:

I don't want to suggest that Java is a complete fluke. The point is that just being the best language out there won't make you popular.

I've seen people on the Scala email list claiming that Scala will drag the industry into functional programming. Personally, I think the Scala community should be worried more about getting industry to accept Scala as a 'real' development platform and worry about changing the industry later.

Flat View: This topic has 45 replies on 4 pages [ « | 1  2  3  4 | » ]
Topic: JCP Election Ballots to Close Today Previous Topic   Next Topic Topic: Douglas Crockford on The State of Ajax

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use