What comes to mind now first of all if we start talking about dynamically typed languages (CED). I bet you call it Ruby, Python, or floating on the waters of Styx Perl. What about baby Groovy ?! His name occasionally pops up in various disputes, but he has not yet gained wide popularity. And in my opinion for nothing!
Go a little distance. I think most readers agree that a professional should have one of the childrens in his toolbox. The pros and cons of dynamically typed languages are generally well covered in other sources, so I will not waste my time and yours on this.
So let's say you recognized the usefulness of dynamic typing. But which language is preferable? In this area, the aforementioned Python and Ruby are undoubtedly mainstream and if you know them well, then you are very respectful. ;) However, with all due respect to them, there is a language, which is much easier to start using (especially if you know Java). Welcome Groovy!
At once I will say that I am not a supporter of the long and boring tutorial articles on Habré, therefore, for a detailed description of the Groovy syntax, I refer you to the
original sources . As a self-taught evangelist, I just note some of his charms.
')
Groovy syntax is an extension of Java syntax, its base types are fully consistent with those of the JDK and it integrates seamlessly with any Java libraries. In fact, a Java program is often completely valid from the point of view of Groovy. What does this mean? The minimum threshold of entry, of course! This is, in my opinion, the main advantage of Groovy, since it does not require breaking the “syntactic reflexes” and extensive manuals for new libraries. Just write as you can, using the usual techniques, eventually discovering more and more efficient designs that abound.
By the way, Groovy, due to its dynamic capabilities, “out of the box” adds dozens of useful methods to familiar classes from the JDK. For example:
"123".isInteger()
or
new File("myFile.txt").getText()
No one bothers you add your own methods.
Groovy contains many other goodies that bring it at least to the Ruby / Python level: closures, support for lists and maps at the language level, built-in support for regular expressions, support for expressions inside strings ("Value = $ value"), automatic creation of properties, safe navigation with the operator "?." (neverNullExceptionHere? .a? .b? .c), metaclasses, builders, my favorite Groovy Templates, and more.
So that all this does not remain for you with empty words, I’ll give you short examples of Groovy code that you can think about (I use goodies, therefore, not Java-style;):
new File(".").eachFileRecurse { file ->
if (file.isFile() && file.readLines().find { line -> line ==~ /Delete\s*this\s*file/ }) {
println "Deleting file: $file"
file.delete()
}
}
So, Groovy is not inferior to Ruby and Python in terms of the richness of the language, but noticeably surpasses them in terms of ease of integration with Java and the minimum threshold for entry. Try it out!
PS If there is interest, then I can preach about Grails / GORM.