I was reading Groovy recently and it is more relates to Java.I don't have any experience in dynamic language.I have read that fo开发者_如何学编程under of Groovy want to add dynamic nature to existing Java language.My question is this.
Q1 what are the compelling reasons to come up with languages like Groovy running on JVM.It intrigued me.Please somebody can help me out.
Thanks, Nuwan Arambage
You're asking the question backwards. Given the idea for a language like Groovy or Clojure, a huge impediment to it's widespread adoption is eliminated if it can run on a widely deployed runtime such as JVM.
For me, its a plethora of enhancements not available in vanilla Java
syntax sugars, closures, inclusions of commonly-used math & i/o libraries, JavaBean features, duck typing are some - it may cost a little performance overhead and is the greatest blocker
basically it gives you what Ruby people enjoy (dramatically terse and expressive scripts) while complying with all aspects of the Java ecosystem, and re-using well-architected classes Java
in fact I've already stopped writing Java altogether now that Groovy 1.8 is imminent it is only a single jar drop into your classpath that easy...
As All know Java is very powerful language, but we can see "something" is missing. As all told java is an object oriented programming language. But is it so? Can you call the method on any integer like this "10.times. . " NO is the answer, you can't. But groovy makes Java as fully object Oriented language. And in java handling list,map are some tedious task, as the programmer need these to be very simple, groovy does that. And more importantly, groovy is simple to read, maintain, and your algorithm of the project becomes the exact code! That is "algorithm" = "groovy code"
I Love groovy!
I cannot tell you for why other languages exist, but I can tell you how I came to Groovy. For me two points where important back then: * Java sucks if you know some programming languages. It handles you like a little child and the compiler is your mother continuously telling you what to do, while failing when it comes to the more difficult areas. * I needed a scripting language. Jython and JRuby back then looked dead, Beanshell too much like Java. And since I mostly programed Java back then Groovy was the almost natural choice to me, as it allows to reuse my old code without bothering too much about conversions.
The question about use cases is a bit difficult to answer, since my personal history is more one of my preferences. Being able to write more code in less lines is not exactly a use case, but prototyping is related to me and a use cases. In Groovy you can then usually write an application more quickly and deliver your prototype. If the customer insists, you can usually easily migrate the existing code to Java again. The nice thing is, you can do this on a per class basis, since Java and Groovy interact well.
精彩评论