By Venkat Subramaniam
Groovy brings you the simplest of either worlds: a versatile, hugely efficient, agile, dynamic language that runs at the wealthy framework of the Java Platform. Groovy preserves the Java semantics and extends the JDK to provide you actual dynamic language features. Programming Groovy 2 may help you, the skilled Java developer, study and make the most of the most recent model of this wealthy dynamic language. you will cross from the fundamentals of Groovy to the newest advances within the language, together with ideas for kind checking, tail-call and memoization optimizations, bring together time metaprogramming, and fluent interfaces to create DSLs.
You should not have to depart the wealthy Java Platform to use Groovy. Groovy preserves Java's semantics and extends the JDK, so programming in Groovy sounds like the Java language has been augmented; it is like operating with a lighter, extra dependent Java. in case you are an skilled Java developer who desires to learn the way Groovy works, you can find precisely what you wish during this book.
You'll commence with the basics of programming in Groovy and the way it really works with Java, after which you will discover complex suggestions equivalent to unit trying out with mock items, utilizing developers, operating with databases and XML, and developing DSLs. you are going to grasp Groovy's strong but advanced run-time and compile-time metaprogramming features.
Much has advanced within the Groovy language because the booklet of the 1st variation of Programming Groovy. Programming Groovy 2 can help you research and observe Groovy's new good points. growing DSLs is simpler now, and Groovy's already-powerful metaprogramming amenities have superior much more. you will see the best way to paintings with closures, together with tail name optimization and memoization. The e-book additionally covers Groovy's new static compilation feature.
Whether you are studying the fundamentals of the language or attracted to getting informed with the recent gains, Programming Groovy 2 has you covered.
What You Need
To paintings at the examples within the publication you wish Groovy 2.0.5 and Java JDK five or higher.
Quick preview of Programming Groovy 2: Dynamic Productivity for the Java Developer (Pragmatic Programmers) PDF
Best Java books
Mastering Lambdas: Java Programming in a Multicore World (Oracle Press)
The Definitive consultant to Lambda Expressions learning Lambdas: Java Programming in a Multicore global describes how the lambda-related positive factors of Java SE eight will permit Java to satisfy the demanding situations of next-generation parallel architectures. The e-book explains the best way to write lambdas, and the way to exploit them in streams and in assortment processing, offering code examples all through.
Mastering JavaFX 8 Controls (Oracle Press)
Layout and installation High-Performance JavaFX Controls bring state of the art functions with visually attractive UIs. gaining knowledge of JavaFX eight Controls offers transparent directions, specific examples, and ready-to-use code samples. tips on how to paintings with the most recent JavaFX APIs, configure UI elements, instantly generate FXML, construct state of the art controls, and successfully practice CSS styling.
Data Abstraction and Problem Solving with Java: Walls and Mirrors (3rd Edition)
The 3rd variation of info Abstraction and challenge fixing with Java: partitions and Mirrors employs the analogies of partitions (data abstraction) and Mirrors (recursion) to coach Java programming layout strategies, in a manner that starting scholars locate available. The ebook has a student-friendly pedagogical procedure that rigorously debts for the strengths and weaknesses of the Java language.
Java Software Solutions: Foundations of Program Design (7th Edition)
Java software program recommendations teaches a origin of programming strategies to foster well-designed object-oriented software program. Heralded for its integration of small and big sensible examples, this around the world best-selling textual content emphasizes development sturdy problem-solving and layout abilities to jot down top quality courses.
- Compiler Construction Using Java, JavaCC, and Yacc
- Absolute Java (5th Edition)
- Data Structures and Algorithms in Java (6th Edition)
- Java Cryptography
Additional info for Programming Groovy 2: Dynamic Productivity for the Java Developer (Pragmatic Programmers)
Com> document erratum • speak about Chapter five. operating with Strings • 102 sooner than we repair the matter, let’s take a second to appreciate how GString expressions are evaluated. while comparing a GString, if we have now a variable, its price is just published to a author, as a rule a StringWriter. although, if we've a closure rather than a variable, the closure is invoked. If our closure takes a parameter, then GString sends the author item as a controversy to the closure. If our closure takes no parameters in any respect, then GString easily calls our closure and prints the end result we go back to the author. If our closure takes multiple parameter, then the decision fails with an exception; let’s now not pass there. Let’s positioned that wisdom to exploit to resolve our expression-evaluation challenge. Here’s the 1st try: WorkingWithStrings/LazyEval. groovy companyClosure = { it. write(company) } priceClosure = { it. write("$price") } quote = "Today ${companyClosure} inventory closed at ${priceClosure}" shares. each one { key, worth -> corporation = key expense = worth println quote } Let’s run the code to work out the output: this present day Apple inventory closed at 663. 01 this day Microsoft inventory closed at 30. ninety five We obtained the output we wish, however the code doesn't glance very groovy. although we don’t are looking to enforce our ultimate code this fashion, seeing this instance might help in methods. First, we will be able to see what’s particularly going on—the GString is looking our closure on the time whilst the expression should be evaluated/printed. moment, if we have to do a little computations which are greater than only exhibiting a property’s price, we all know tips to do this. Let’s eliminate that it parameter. Like we mentioned previous, if our closure has no parameters, then GString makes use of what we go back. we all know the way to create a closure without parameters—define it with the syntax {-> . So, let’s refactor the former code: WorkingWithStrings/LazyEval. groovy companyClosure = {-> corporation } priceClosure = {-> expense } quote = "Today ${companyClosure} inventory closed at ${priceClosure}" shares. every one { key, price -> corporation = key expense = worth println quote } obtain from Wow! booklet