• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which is better Groovy or Scala?

 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently started reading Groovy.
At some website it is mentioned that scala is better than groovy. http://twittch.com/27/
Does it means that Groovy will be not used so much because of scala.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At some website it is mentioned that scala is better than groovy. http://twittch.com/27/

You're not seriously considering making decisions about which language to use based on a comic strip, are you?

I often find language comparisons unhelpful, like comparing apples and oranges (or hammers and screw drivers, if you want to stay in the tool domain).
 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right Ulf. I just wanted to know that is it really true?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you missed the point, which is that statements like "language A is better than language B" simply make no sense without knowing a whole lot of context. Also, languages, their ecosystems, and the people/teams using them evolve over time, so even if some statement like that was true for a particular set of circumstances in the past, if may no longer be true at some later time.
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf hit it right on the nail on this one (pun intended).

Try reading this article from James Strachan himself (creator of Groovy) regarding his thoughts on Scala....
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does Scala run on JVM ?
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. http://www.infoq.com/presentations/jaoo-spoon-scala
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul. Does Scala allow and match of Java code ?
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if I understood what you mean but you can call Java code from Scala and vice versa. Pretty much like Groovy.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to ask if Scala allows mix and match of Java code with Scala. Thank you.
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No more new languages. I really believe new languages are created to confuse developers. What can I not achieve with Java :-)
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I wanted to ask if Scala allows mix and match of Java code with Scala. Thank you.

Yes, you can.
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Does it means that Groovy will be not used so much because of scala.

I think both of them are in two different leagues. Scala is more of a threat to Java, rather than Groovy. And Groovy's intention isn't to replace Java, but rather to enhance it. So probably the competition will be between Groovy+Java versus Scala

To me, Scala seems to be a more complex language compare to Java, but it surely has a lot of nice features. I think that's gonna be the language that I'm gonna learn in next
 
Leandro Coutinho
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
groovy developers must have felt sad about the article. :/

So it looks like for whom yet has some doubt which to choose, go with Scala, right?


edited: Fredd already made a good point
 
Peter Ledbrook
author
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Groovy is a dynamic language. Scala is a static language. Scala is more of an evolution of Java, whereas Groovy complements Java (although it is sometimes sold as a replacement). There is more than enough room in one's toolkit for both.

Take Grails for example: about 70% of it is probably still written in Java. The rest is Groovy. It's all about using the right tool for the job. Of course, you need a fair bit of experience to determine which is the right tool!

Cheers,

Peter
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well said Peter
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vyas Sanzgiri wrote:No more new languages. I really believe new languages are created to confuse developers. What can I not achieve with Java :-)


Right, when I was a young programmer, we used macro assembly language. Great work was done with that.

Its interesting to watch Groovy, Scala and other new languages. Java's design was strongly influenced by the need to make it accessible to C programmers. So it didn't follow the Smalltalk model, where everything was an object. While I understand why they did that, the whole int vs Integer thing is a hack and doesn't help anyone execept some C developers back in 1997.

So far, I don't grok closures, but I'm just starting to look into Groovy and Scala. But I'll get it one of these days. What I really fear is that they will add closures to Java. Either they will break tons of code written over the past 13+ years, or they will use some bizzare syntax like they did for generics.

When I was writing Fortran for a living, we talked about "dusty decks" which were old Fortran programs that were written on punched cards. The programs were needed, and no one dared touch them to change anything.

There are times when I wish that were were all now talking about Kava and Mava.... which I guess we are, they are just called Scala and Groovy

Personally, I'm a big fan of static type checking in languages, I think they help make for better engineering. But I could be wrong, and I sure did like writing in Smalltalk.
 
Trilochan Bharadwaj
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pat me too, I think statically typed language systems are much better in long run; you get your errors then and there and everything follows, you can "expect" certain things to happen, just paves way for better and consistent and "safe" code. But on the other hand, dynamic languages do have their place ... After being a fanatic of strong type systems, I started doing some dynamic stuff and i was a bit addicted; still am, so yes they both do complement each other (as one of the posters said), they CANNOT replace each other completely (some people would like to dream that way ...)

I prefer Scala over Groovy (i have been involved with at least 3 different endeavors professionally with Groovy), its just a matter of taste, for me Scala is very stable and sound language to work on ... What was Java like I guess 10-11 years back.

Trilochan

Addendum:

On closures:

WE NEED CLOSURES IN JAVA! I don't understand why are we making such a fuss about closures being added to Java? Java is killing itself by being circumspect about those features that are present in almost EVERY modern language! Function type system can improve Java and will possibly eliminate and condense lot of our code into few lines!

OK, On generics, I agree, basically I think that we should have inferred typing in the first place, instead of the whole garbage of expanding parameter types, like this:

crazy way ... also inferred typing would solve lot of our DRY principle violations!

Good stuff, BTW never did SmallTalk but I hear people raving about it all the time (Martin Fowlers one of them), is it dynamic? anything closer to Scheme/ML/Haskell? (functional and static?) or is functional and dynamic or something else? just curious ...

Trilochan.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vyas Sanzgiri wrote:No more new languages. I really believe new languages are created to confuse developers. What can I not achieve with Java :-)

Cleaner code.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trilochan Bharadwaj wrote:WE NEED CLOSURES IN JAVA! I don't understand why are we making such a fuss about closures being added to Java?


Good stuff, BTW never did SmallTalk but I hear people raving about it all the time (Martin Fowlers one of them), is it dynamic? anything closer to Scheme/ML/Haskell? (functional and static?) or is functional and dynamic or something else? just curious ...


No, we do not need Closures in Java. If Java had been designed with them, sure, fine, I'd like them. But the way they implemented generics is a crock, and closures will break too much stuff. Just use Scala or groovy.

I can't comment of SmallTalk compared to Scheme/ML, since I never used them. But Smalltalk is pure OO, not a hack of OO onto C the way Java is. I think we'd almost be better off with a real hack, like Objective-C. Smalltalk was completely dymanic, there were really no such things as "type" rather everything is an object or a message. Even an "if" statement.

SmallTalk was fun to program in. But due to its ancient age, the runtime system was a minimal common subset of then current windowing systems, expect perhaps on the Xerox Star where SmallTalk was the windowing system. When I used it professionally, in about 1992, we ran it on Windows 3.1 and some on OS/2. But critical things that users expected, like fancy cut and paste, and later drag-n-drop, were simply not there. [Note: early Java didn't have drag-n-drop either]

The beauty of Java is really in the JVM, and both Scala and Groovy use the standard JVM. A smart choice.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Starting to get radically off-topic.)

I would ***love*** to have (better, depending on your definition) closures in Java. I have surprisingly few beefs with Java, but the ones I have are significant, and includes the lack of (better) closures. Java's lack of progress is disheartening. I really don't understand the resistance to closures; some of the suggested implementations seem reasonable.

The Smalltalk (small "t", please) I used had cut-n-paste. I was substantially more productive code-wise twenty years ago in Lisp and Smalltalk than I am today in Java--we're only now starting to catch up to what used to be commonplace. It'd be funnier if it wasn't so dumb.

Smalltalks generally used whatever windowing system it was implemented on--I don't recall having any significant GUI-related limitations when running on Windows, but back in those days I was also a low-level systems and Windows developer and had no issue creating libraries I could then use from Smalltalk.

(Back on topic)

Scala's lack of metaprogramming is a *real* issue for me, being used to languages with MOPs. I'm starting to use both Groovy and Scala more in day-to-day work (and have been using JRuby and Jython for years); they all seem to have their place. Neither is "better" in any useful objective sense.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Scala's lack of metaprogramming is a *real* issue for me, being used to languages with MOPs. I'm starting to use both Groovy and Scala more in day-to-day work (and have been using JRuby and Jython for years); they all seem to have their place. Neither is "better" in any useful objective sense.


Can you explain how you use metaprogramming? or why you miss it? I'm just learning groovy, and that is one of the topics that the book goes on and on about how great it is, and I'm completely missing why.

I also don't grok why closures are such a big deal. They sure look and smell like text substitution macros to me, yet the books and fans seem to love them. Perhaps the examples are too simplistic to break through my head
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It'd be quicker (and more accurate) for you to just start playing w/ closures and metaprogramming, really. It's been my experience that it *always* takes working with it, or exploring an elegant solution that would be uglier without it, to bring about the "A-ha!" moment. I don't know how many times I've tried to explain the power of Lisp macros to people, almost always unsuccessfully, without taking the time to work through a problem that's only solvable with them.

I'm not sure how to equate closures with text substitution macros, so I can't really address that. If you've done any significant JavaScript programming you've probably used them, perhaps without realizing it or understanding why it makes things work. It's puzzling to find a Smalltalk programmer that doesn't grok closures since Smalltalk uses them *everywhere*, but calls them "blocks" (like Ruby).

In Java, anonymous inner classes are sort-of closures, with some restrictions, and a lot of syntactic noise.

If you're in to Groovy, it has some neat metaprogramming stuff including compile-time metaprogramming via AST manipulation. There are tons of articles on the web that discuss metaprogramming Groovy, like this one and this one.

It could also just be a definitional issue, and you know more about it than you believe you do.
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:
Vyas Sanzgiri wrote:No more new languages. I really believe new languages are created to confuse developers. What can I not achieve with Java :-)

Cleaner code.


I do not think that is my focus. My focus is to get the job done asap I would rather get a piece of code that works or work in a framework that has been explored than solve the unknown issues with new framework. We are not allowing languages like Groovy to mature and reach a stable release with major issues being fixed...
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, but why awaking a zombie thread?
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got an email in my mailbox that there was a reply to this thread Sorry I didn't check the dates.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic