text.skipToContent text.skipToNavigation

Groovy and Grails Recipes von Jawad, Bashar A. (eBook)

  • Erscheinungsdatum: 29.01.2009
  • Verlag: Apress
eBook (PDF)
41,64 €
inkl. gesetzl. MwSt.
Sofort per Download lieferbar

Online verfügbar

Groovy and Grails Recipes

Groovy and Grails Recipes is the busy developer's guide to developing applications in Groovy and Grails. Rather than boring you with theoretical knowledge of 'yet another language/framework,' this book delves straight into solving real-life problems in Groovy and Grails using easy-to-understand, well-explained code snippets. Through learning by example, you will be able to pick up on Groovy and Grails quickly and use the book as an essential reference when developing applications. Bashar Abdul Jawad is a senior software engineer at Video Monitoring Services, Inc., as well as a practicing Java, Groovy, and Grails expert, and he has a number of web sites in operation today based on Groovy and Grails.


    Format: PDF
    Kopierschutz: AdobeDRM
    Seitenzahl: 424
    Erscheinungsdatum: 29.01.2009
    Sprache: Englisch
    ISBN: 9781430216018
    Verlag: Apress
    Größe: 2846 kBytes
Weiterlesen weniger lesen

Groovy and Grails Recipes

CHAPTER 2 From Java to Groovy (S. 17-18)

If you are reading this book, you probably have some experience working with Java. As I explained in the introduction, this book assumes an intermediate- level knowledge of Java. This is because I have noticed that most people learning Groovy have some Java background, and-impatient with the shortcomings and limitations of Java-have decided to give Groovy a try.

They couldn't be more right! This chapter focuses mainly on explaining the similarities and differences between Java and Groovy and how to integrate Groovy with Java. Thanks to the similarity between Groovy's syntax and Java's, the transition from Java to Groovy is a smooth one with an almost flat learning curve. As a matter of fact, Java developers can learn and start programming with Groovy in less than a day. It doesn't get much easier than that!

2-1. What Are the Similarities Between Java and Groovy?

Most of Groovy's code should look instantly familiar to Java developers. As a matter of fact, Java developers can start up the Groovy console and start playing with Groovy before even reading a word about Groovy's syntax. Almost all Java code can be compiled as is with no errors by using the command. Both Java and Groovy are compiled languages. They compile to the same intermediate binary format (bytecode), which runs on the same virtual machine (JVM). As mentioned in Chapter 1, this model guarantees perfect interoperability between Groovy code and Java code and enables Java developers to use Groovy with all of their favorite Java- based frameworks and libraries.

Almost all of Java's syntax is part of Groovy, therefore, Groovy can be considered a near superset of Java. The only Java elements that Groovy doesn't support at the moment are nested and anonymous inner classes. Groovy replaces them with closures, which are much more powerful. However, future versions of Groovy might add support to Java's inner and anonymous classes, thus completing the superset. The decision to make Groovy support almost all of Java's syntax was a deliberate one on the part of the Groovy developers.

They wanted to provide seamless integration with Java, and to make the transition from Java to Groovy as smooth and easy as possible. Even though Groovy's syntax can be considered a near superset of Java, you should be aware of the few semantic differences. For example, I showed in Chapter 1 that Groovy performs floating- point division by default when both operands are integers. In contrast, Java performs integer division. Another example is the operator, which in Groovy, unlike Java, denotes equality rather than identity.

Weiterlesen weniger lesen