"Groovy 2.0 and beyond" presentation given at the Groovy/Grails eXchange conference.
Video can be seen here:
http://skillsmatter.com/podcast/groovy-grails/keynote-speech
This document provides an overview of Groovy, a dynamic language for the Java Virtual Machine. It discusses Groovy's features like properties, closures, and integration with Java. The document outlines what's new in Groovy 1.5, including Java 5 features like annotations and generics. It also covers how to integrate Groovy in applications using mechanisms like the GroovyShell and GroovyClassLoader. The presentation aims to help attendees learn about Groovy and how they can use it in their projects.
This summary provides an overview of the key points about Groovy 2.0 discussed in the document:
1. Groovy 2.0 features a more modular architecture with smaller JAR files for individual features, as well as the ability to create custom extension modules.
2. It includes support for Java 7 features like binary literals, underscores in literals, and multicatch exceptions.
3. The new static type checking functionality in Groovy 2.0 aims to catch errors like typos, missing methods, and wrong assignments at compile time rather than runtime.
The document discusses new features and enhancements in Groovy 2, including modularity improvements, extension modules, Java 7 support like invoke dynamic and binary literals, and static type checking. Modularity changes allow Groovy to be split into a smaller core JAR and optional modules. Extension modules allow contributing new methods. Static type checking adds compile-time checks for errors.
This document summarizes Hamlet D'Arcy's presentation on AST transformations using tools like Lombok, Groovy, CodeNarc, and Mirah. It discusses how these tools allow manipulating abstract syntax trees to add functionality like automatic property generation, static analysis, and embedded domain-specific languages. Local AST transformations are performed without changing bytecode or requiring new semantics. Type checking can also be added through transformations. Mirah compiles to pure Java classes without additional syntax.
This document contains a summary of topics covered in a C# programming course, including const and readonly keywords, casting, the is keyword, enums, exception handling, unsafe code, nullable types, the using keyword, and files. The agenda covers direct casting vs casting with the "as" keyword, checking types with "is", defining enums, trying/catching exceptions, creating custom exceptions, using unsafe code, declaring nullable types, using directives vs statements, and opening/closing files.
The document provides an overview of key object-oriented programming concepts in C#, including:
- Classes and objects - Examples are given of defining a Player class with properties and constructors.
- Inheritance - Examples demonstrate how a ChildClass inherits from a ParentClass, including calling parent constructors.
- Polymorphism - Abstract DrawingObject class and derived classes like Line demonstrate polymorphism through overriding the Draw() method.
- Versioning - Examples show how to override and hide inherited methods using the override and new keywords respectively.
- Interfaces are also briefly mentioned as a topic to be covered.
1. Swift includes features like subscripts, optional chaining, and error handling that improve safety and flexibility compared to earlier languages.
2. The document discusses Swift concepts like extensions, protocols, and generics that allow code reuse and abstraction. Protocols define requirements that types can conform to through extensions.
3. Generics allow algorithms to work with different types through type parameters like Stack<Element>, avoiding duplicate non-generic code. This makes code cleaner, safer, and more reusable.
PHP 8 introduces several new features and backward compatibility breaks. It includes a just-in-time compiler, match expression, constructor property promotion, union types, static return type, attributes, named arguments, and improved type handling. Notable BC breaks are stricter error handling by default, locale independence for float conversions, and warning promotion to type errors. The changes aim to improve performance, type safety, and consistency.
The document discusses code generation and abstract syntax tree (AST) transformations. It provides an overview of Project Lombok, a Java library that generates boilerplate code through annotation processing and AST transformations. It also discusses how to analyze and transform code by visiting and rewriting AST nodes, giving examples of checking for null checks and instanceof expressions.
Groovy is a dynamic language for the Java Virtual Machine that aims to bring dynamic capabilities like Python and Ruby to Java developers. It has many features inspired by dynamic languages like closures, duck typing and metaprogramming, but also maintains compatibility with Java by having a Java-like syntax and the ability to interoperate with Java code. Groovy code can either be run directly from scripts or compiled into Java bytecode to be used within Java applications.
Club of anonimous developers "Refactoring: Legacy code"Victor_Cr
The document discusses various approaches to refactoring legacy code, including:
1. Migrating from an older build system (TOM) to a newer one (POM) by updating XML configuration files.
2. Introducing inversion of control (IoC) and dependency injection (DI) to reduce tight coupling in the code.
3. Implementing aspect-oriented programming (AOP) to separate cross-cutting concerns like transaction management and exception handling.
4. Updating older libraries to newer versions for performance improvements and richer APIs.
5. Cleaning up messy and difficult to read code through techniques like extracting methods and using regular expressions.
This document provides an overview of the Dart programming language created by Google. It discusses Dart's structure as a new programming language with its own runtime environment and tools. Key features covered include Dart's static yet dynamic typing, use of classes and objects, namespaces, isolates for concurrency, and snapshots for faster startups. The document also provides code examples demonstrating Dart's syntax and how it handles concepts like generics differently than other languages like Java.
In recent years we have seen explosion of languages which run on Java Virtual Machine. We also have seen existing languages getting their implementations being rewritten to JVM. With all of the above we have seen rapid development of tools like parsers, bytecode generators and such, even inside JVM we saw initiatives like Da Vinci Machine Project, which led to invoke dynamic in JDK 7 and recent development of Graal and Truffle projects.
Is it really hard to write new programming language running on JVM? Even if you are not going to write your own I think it is worth to understand how your favorite language runs undercover, how early decisions can impact language extensibility and performance, what JVM itself and JVM ecosystem has to offer to language implementors.
During session I will try to get you familiar with options you have when choosing parsers and byte code manipulation libraries. which language implementation to consider, how to test and tune your "new baby". Will you be able after this session to develop new and shiny language, packed with killer features language? No. But for sure you will understand difference between lexers and parsers, how bytecode works, why invoke dynamic and Graal and Truffle are so important to the future of JVM platform. Will we have time to write simple, compiled language?
Yes, we will, just to show you that even person who didn't studied computer science, compilers theory, and for majority of his life didn't know what AST is, can do it :)
clean code book summary - uncle bob - English versionsaber tabatabaee
The document provides guidance on writing clean code based on the book "Clean Code" by Robert Cecil Martin. Some of the key points discussed include:
- Functions should do one thing and do it well, with a single level of abstraction and no side effects. They should fit on a screen.
- Names should be meaningful, avoid abbreviations, and use consistent vocabulary. Class names should be nouns and method names should be verbs.
- Code formatting is important for readability. Classes should not exceed 200 lines, functions a single screen. Variables should be declared near use.
- Comments should only explain why unusual decisions were made, not what the code does. Avoid commented out code or redundant comments
This document provides a summary of a presentation on object-oriented programming (OOP) and clean code given at IPB Computer Science on March 28, 2017. It introduces the speaker, Ifnu Bima, and his background working at Deutsche Bank and blibli.com. The presentation covers topics like code quality metrics, meaningful naming conventions, high-quality functions, comments, and unit testing. It emphasizes writing code that is easy to maintain and modify over time to prevent issues like bugs and technical debt.
The document discusses code generation on the JVM using various tools and frameworks. It provides an overview of Lombok for generating Java boilerplate code, Groovy AST transformations, CodeNarc for static analysis, and Spock, GContracts, and Groovy++ for framework-oriented code generation. It also discusses generating code at compile time using abstract syntax trees.
The document discusses abstract syntax tree (AST) transformations in Groovy and Java. It covers several tools and techniques for AST transformations including Lombok, Groovy, CodeNarc, IntelliJ IDEA, Mirah macros, and how they allow generating code, performing static analysis, and rewriting code at compile time through analyzing and modifying the AST. The key topics are how these tools work by compiling code to an AST, analyzing and modifying the AST nodes, and sometimes generating source code from the transformed AST.
Latest C++ Interview Questions and AnswersDaisyWatson5
Q: Is it possible to have Virtual Constructor? If yes, how? If not, Why not possible?
A: There is nothing like Virtual Constructor. The Constructor can‟t be virtual as the constructor is a code which is responsible for creating an instance of a class and it can‟t be delegated to any other object by virtual keyword means.
Q: What is constructor or ctor?
A: Constructor creates an object and initializes it. It also creates vtable for virtual functions. It is different from other methods in a class.
Q: What about Virtual Destructor?
A: Yes there is a Virtual Destructor. A destructor can be virtual as it is possible as at runtime depending on the type of object caller is calling to, proper destructor will be called.
Q: What is the difference between a copy constructor and an overloaded assignment operator?
A: A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class.
Q: Can a constructor throws an exception? How to handle the error when the constructor fails? A:The constructor never throws an error.
Q: What is default constructor?
A: Constructor with no arguments or all the arguments has default values.
This document summarizes a presentation given by Colin Gemmell, a developer who transitioned from .NET to Ruby on Rails. It discusses his motivations for the switch, compares the development environments and practices between the two platforms, and touches on some of the benefits and challenges of Rails development.
The document discusses principles and best practices for writing clean code, including using meaningful names, separating commands and queries, avoiding repetition, using exceptions instead of return codes, and following object-oriented principles like polymorphism instead of switch statements on objects. It provides examples of good and bad code for concepts like single responsibility, primitive obsession, and refused bequest. The overall goal is to write code that is readable, maintainable, and extendable.
The document contains questions and multiple choice answers about C# programming concepts.
Question 6 identifies a problem in a code snippet where a delegate is declared to accept a string parameter, but the methods passed to it do not. The correct code fixes this by removing the string parameter from the methods.
Question 20 asks which code snippet would correctly overload the unary minus operator to negate the values of two integer properties. The correct code negates the property values directly rather than using decrement operators.
Building native Android applications with Mirah and PindahNick Plante
Mirah is a Ruby-like language that compiles to Java bytecode, allowing Ruby developers to write Android apps without using Java. The document introduces Mirah and Pindah, a framework that makes it easier to develop Android apps in Mirah. It provides an example "Up or Down?" app that checks the status of websites and displays results. While Mirah offers a more Ruby-like syntax, it is still immature and tooling support needs improvement, making large Android app development challenging.
This document discusses principles of clean code based on the book "Clean Code" by Robert C. Martin. It provides examples of good and bad practices for naming variables and functions, structuring functions, using comments, and other topics. Key points include using meaningful names, keeping functions small and focused on a single task, avoiding deeply nested code and long argument lists, commenting to explain intent rather than state the obvious, and other guidelines for writing clean, readable code.
The document provides an overview of the Objective-C runtime and how it can be used in practice. It begins with introductions and then covers key topics like what the runtime is, how it supports object-oriented features in Objective-C, and how Foundation provides a simpler interface to interact with the runtime. It then demonstrates various runtime capabilities like dealing with classes, protocols, messages, and dynamic messaging. It also covers more advanced techniques like lazy method resolution, forwarding, swizzling, dynamic class generation, and property generation. Code examples are provided to demonstrate many of these runtime features in practice.
The document discusses collections in C# programming. It shows examples of using List and Dictionary collections to store and retrieve data. A List is used to store integer values and later iterate through them. A Dictionary is used to store Customer objects mapped by ID. The document also demonstrates converting between collection types using ConvertAll and a custom converter.
The document discusses various techniques for unit testing concurrent code, including using JUnit, TestNG, and a custom ThreadWeaver framework to test for threading issues in a FlawedList implementation. It also covers using jcstress for concurrency stress testing and notes that jcstress results may vary between runs and depend on processor architecture memory access semantics.
Apache Groovy's Metaprogramming Options and YouAndres Almiray
This document discusses various metaprogramming techniques in Groovy including:
- Meta Object Protocol (MOP) which allows modifying classes at runtime.
- Categories and mixins for adding methods to existing classes.
- Traits for reusable pieces of code with state.
- Extension modules for globally available extensions that can modify classes.
- AST transformations for compile-time modifications by transforming the AST.
- Over 70 built-in AST transformations like @ToString and @Immutable.
The document discusses using Groovy to improve Java testing. Groovy allows writing tests more concisely using features like closures, native list/map syntax, and dynamic proxies. It also enables mocking collaborators without external libraries. Groovy integrates fully with JUnit and TestNG and helps test exceptions, databases using DbUnit, and drive functional UI tests more easily.
The document discusses code generation and abstract syntax tree (AST) transformations. It provides an overview of Project Lombok, a Java library that generates boilerplate code through annotation processing and AST transformations. It also discusses how to analyze and transform code by visiting and rewriting AST nodes, giving examples of checking for null checks and instanceof expressions.
Groovy is a dynamic language for the Java Virtual Machine that aims to bring dynamic capabilities like Python and Ruby to Java developers. It has many features inspired by dynamic languages like closures, duck typing and metaprogramming, but also maintains compatibility with Java by having a Java-like syntax and the ability to interoperate with Java code. Groovy code can either be run directly from scripts or compiled into Java bytecode to be used within Java applications.
Club of anonimous developers "Refactoring: Legacy code"Victor_Cr
The document discusses various approaches to refactoring legacy code, including:
1. Migrating from an older build system (TOM) to a newer one (POM) by updating XML configuration files.
2. Introducing inversion of control (IoC) and dependency injection (DI) to reduce tight coupling in the code.
3. Implementing aspect-oriented programming (AOP) to separate cross-cutting concerns like transaction management and exception handling.
4. Updating older libraries to newer versions for performance improvements and richer APIs.
5. Cleaning up messy and difficult to read code through techniques like extracting methods and using regular expressions.
This document provides an overview of the Dart programming language created by Google. It discusses Dart's structure as a new programming language with its own runtime environment and tools. Key features covered include Dart's static yet dynamic typing, use of classes and objects, namespaces, isolates for concurrency, and snapshots for faster startups. The document also provides code examples demonstrating Dart's syntax and how it handles concepts like generics differently than other languages like Java.
In recent years we have seen explosion of languages which run on Java Virtual Machine. We also have seen existing languages getting their implementations being rewritten to JVM. With all of the above we have seen rapid development of tools like parsers, bytecode generators and such, even inside JVM we saw initiatives like Da Vinci Machine Project, which led to invoke dynamic in JDK 7 and recent development of Graal and Truffle projects.
Is it really hard to write new programming language running on JVM? Even if you are not going to write your own I think it is worth to understand how your favorite language runs undercover, how early decisions can impact language extensibility and performance, what JVM itself and JVM ecosystem has to offer to language implementors.
During session I will try to get you familiar with options you have when choosing parsers and byte code manipulation libraries. which language implementation to consider, how to test and tune your "new baby". Will you be able after this session to develop new and shiny language, packed with killer features language? No. But for sure you will understand difference between lexers and parsers, how bytecode works, why invoke dynamic and Graal and Truffle are so important to the future of JVM platform. Will we have time to write simple, compiled language?
Yes, we will, just to show you that even person who didn't studied computer science, compilers theory, and for majority of his life didn't know what AST is, can do it :)
clean code book summary - uncle bob - English versionsaber tabatabaee
The document provides guidance on writing clean code based on the book "Clean Code" by Robert Cecil Martin. Some of the key points discussed include:
- Functions should do one thing and do it well, with a single level of abstraction and no side effects. They should fit on a screen.
- Names should be meaningful, avoid abbreviations, and use consistent vocabulary. Class names should be nouns and method names should be verbs.
- Code formatting is important for readability. Classes should not exceed 200 lines, functions a single screen. Variables should be declared near use.
- Comments should only explain why unusual decisions were made, not what the code does. Avoid commented out code or redundant comments
This document provides a summary of a presentation on object-oriented programming (OOP) and clean code given at IPB Computer Science on March 28, 2017. It introduces the speaker, Ifnu Bima, and his background working at Deutsche Bank and blibli.com. The presentation covers topics like code quality metrics, meaningful naming conventions, high-quality functions, comments, and unit testing. It emphasizes writing code that is easy to maintain and modify over time to prevent issues like bugs and technical debt.
The document discusses code generation on the JVM using various tools and frameworks. It provides an overview of Lombok for generating Java boilerplate code, Groovy AST transformations, CodeNarc for static analysis, and Spock, GContracts, and Groovy++ for framework-oriented code generation. It also discusses generating code at compile time using abstract syntax trees.
The document discusses abstract syntax tree (AST) transformations in Groovy and Java. It covers several tools and techniques for AST transformations including Lombok, Groovy, CodeNarc, IntelliJ IDEA, Mirah macros, and how they allow generating code, performing static analysis, and rewriting code at compile time through analyzing and modifying the AST. The key topics are how these tools work by compiling code to an AST, analyzing and modifying the AST nodes, and sometimes generating source code from the transformed AST.
Latest C++ Interview Questions and AnswersDaisyWatson5
Q: Is it possible to have Virtual Constructor? If yes, how? If not, Why not possible?
A: There is nothing like Virtual Constructor. The Constructor can‟t be virtual as the constructor is a code which is responsible for creating an instance of a class and it can‟t be delegated to any other object by virtual keyword means.
Q: What is constructor or ctor?
A: Constructor creates an object and initializes it. It also creates vtable for virtual functions. It is different from other methods in a class.
Q: What about Virtual Destructor?
A: Yes there is a Virtual Destructor. A destructor can be virtual as it is possible as at runtime depending on the type of object caller is calling to, proper destructor will be called.
Q: What is the difference between a copy constructor and an overloaded assignment operator?
A: A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class.
Q: Can a constructor throws an exception? How to handle the error when the constructor fails? A:The constructor never throws an error.
Q: What is default constructor?
A: Constructor with no arguments or all the arguments has default values.
This document summarizes a presentation given by Colin Gemmell, a developer who transitioned from .NET to Ruby on Rails. It discusses his motivations for the switch, compares the development environments and practices between the two platforms, and touches on some of the benefits and challenges of Rails development.
The document discusses principles and best practices for writing clean code, including using meaningful names, separating commands and queries, avoiding repetition, using exceptions instead of return codes, and following object-oriented principles like polymorphism instead of switch statements on objects. It provides examples of good and bad code for concepts like single responsibility, primitive obsession, and refused bequest. The overall goal is to write code that is readable, maintainable, and extendable.
The document contains questions and multiple choice answers about C# programming concepts.
Question 6 identifies a problem in a code snippet where a delegate is declared to accept a string parameter, but the methods passed to it do not. The correct code fixes this by removing the string parameter from the methods.
Question 20 asks which code snippet would correctly overload the unary minus operator to negate the values of two integer properties. The correct code negates the property values directly rather than using decrement operators.
Building native Android applications with Mirah and PindahNick Plante
Mirah is a Ruby-like language that compiles to Java bytecode, allowing Ruby developers to write Android apps without using Java. The document introduces Mirah and Pindah, a framework that makes it easier to develop Android apps in Mirah. It provides an example "Up or Down?" app that checks the status of websites and displays results. While Mirah offers a more Ruby-like syntax, it is still immature and tooling support needs improvement, making large Android app development challenging.
This document discusses principles of clean code based on the book "Clean Code" by Robert C. Martin. It provides examples of good and bad practices for naming variables and functions, structuring functions, using comments, and other topics. Key points include using meaningful names, keeping functions small and focused on a single task, avoiding deeply nested code and long argument lists, commenting to explain intent rather than state the obvious, and other guidelines for writing clean, readable code.
The document provides an overview of the Objective-C runtime and how it can be used in practice. It begins with introductions and then covers key topics like what the runtime is, how it supports object-oriented features in Objective-C, and how Foundation provides a simpler interface to interact with the runtime. It then demonstrates various runtime capabilities like dealing with classes, protocols, messages, and dynamic messaging. It also covers more advanced techniques like lazy method resolution, forwarding, swizzling, dynamic class generation, and property generation. Code examples are provided to demonstrate many of these runtime features in practice.
The document discusses collections in C# programming. It shows examples of using List and Dictionary collections to store and retrieve data. A List is used to store integer values and later iterate through them. A Dictionary is used to store Customer objects mapped by ID. The document also demonstrates converting between collection types using ConvertAll and a custom converter.
The document discusses various techniques for unit testing concurrent code, including using JUnit, TestNG, and a custom ThreadWeaver framework to test for threading issues in a FlawedList implementation. It also covers using jcstress for concurrency stress testing and notes that jcstress results may vary between runs and depend on processor architecture memory access semantics.
Apache Groovy's Metaprogramming Options and YouAndres Almiray
This document discusses various metaprogramming techniques in Groovy including:
- Meta Object Protocol (MOP) which allows modifying classes at runtime.
- Categories and mixins for adding methods to existing classes.
- Traits for reusable pieces of code with state.
- Extension modules for globally available extensions that can modify classes.
- AST transformations for compile-time modifications by transforming the AST.
- Over 70 built-in AST transformations like @ToString and @Immutable.
The document discusses using Groovy to improve Java testing. Groovy allows writing tests more concisely using features like closures, native list/map syntax, and dynamic proxies. It also enables mocking collaborators without external libraries. Groovy integrates fully with JUnit and TestNG and helps test exceptions, databases using DbUnit, and drive functional UI tests more easily.
Metaprogramming Techniques In Groovy And GrailszenMonkey
The document discusses metaprogramming techniques in Groovy and Grails. It defines key concepts like dynamic typing, late binding, and metaprogramming. It then explains various dynamic features in Groovy like intercepting methods/properties, creating classes/methods at runtime, and evaluating code strings. It covers Groovy's meta object protocol and how it exposes runtime structures. Examples are provided for method dispatching, AST transformations, and using builders to generate hierarchical structures.
This document provides an overview of JavaScript and jQuery. It discusses DOM scripting with plain JavaScript, which can be verbose and inconsistent across browsers. jQuery simplifies DOM scripting by reducing browser inconsistencies and providing a simpler and more consistent API. The document reviews jQuery basics like selectors and traversing, and developer tools for testing and debugging code. It also covers basic JavaScript concepts like variables, loops, functions, and objects.
Introduction to Groovy runtime metaprogramming and AST transformsMarcin Grzejszczak
Introduction to Groovy runtime metaprogramming and AST transforms - by Marcin Grzejszczak author of the http://toomuchcoding.blogspot.com blog.
The sources can be found here
Mercurial Bitbucket - https://bitbucket.org/gregorin1987/too-much-coding/src/e5ab7c69ab7b2796075fd6f087fbf31346aa2d2b/Groovy/ast/?at=default
Git Github - https://github.com/marcingrzejszczak/too-much-coding/tree/master/Groovy/ast
This document summarizes a workshop on test-driven development in Groovy. The workshop introduces Groovy features that help with Java testing, and tools like Cucumber and cuke4duke for acceptance and behavior-driven testing. The goals are to demonstrate unit, integration and acceptance testing with Groovy, Cucumber and a sample Java web application. Attendees will get hands-on experience with these technologies. Prerequisites are a Java JDK and Maven. The presentation materials and sample code are available online.
Groovy is a dynamic language for the Java Virtual Machine that aims to provide an alternative to Java for those seeking a more concise and expressive syntax. It is compatible with Java and allows Java code to be called from Groovy and vice versa. Groovy reduces boilerplate code through features like optional typing, closures/lambdas, operator overloading, and dynamic method dispatch. It also provides concise syntax for lists, maps, ranges, and other common data structures.
Practical tips for dealing with projects involving legacy code. Covers investigating past projects, static analysis of existing code, and methods for changing legacy code.
Presented at PHP Benelux '10
Infinum android talks_10_getting groovy on androidInfinum
Groovy is a dynamic language similar to Python, Ruby, Pearl and Smalltalk. Since it compiles to Java bytecode it can be used to write Android applications as well. We’ll demonstrate how to setup a Groovy Android application project, show the advantages, disadvantages and provide some code examples.
https://www.youtube.com/watch?v=9yxj9bxQ9H4
AMC Squarelearning Bangalore is the best training institute for a career development. it had students from various parts of the country and even few were from West African countries.
PHP 8.0 is expected to be released by the end of the year, so it’s time to take a first look at the next major version of PHP. Attributes, union types, and a just-in-time compiler are likely the flagship features of this release, but there are many more improvements to be excited about. As PHP 8.0 is a major version, this release also includes backwards-incompatible changes, many of which are centered around stricter error handling and more type safety.
Presentation from phpfwdays 2020.
PHP 8.0 is expected to be released by the end of the year, so it’s time to take a first look at the next major version of PHP. Attributes, union types, and a just-in-time compiler are likely the flagship features of this release, but there are many more improvements to be excited about. As PHP 8.0 is a major version, this release also includes backwards-incompatible changes, many of which are centered around stricter error handling and more type safety.
This talk will discuss new features already implemented in PHP 8, backwards-compatibility breaks to watch out for, as well as some features that are still under discussion.
The document describes GrooScript, a library and tool that converts Groovy code to JavaScript code. Some key points:
- GrooScript is an Apache 2 licensed Java library and command line tool that converts Groovy to equivalent JavaScript code.
- It supports many Groovy features like classes, closures, collections, and basic Groovy syntax but does not support all Java features or complex Groovy features.
- The converted code works with the grooscript.js library and can be used in JavaScript projects or environments like Grails and Gradle.
Groovy is a dynamic language for the Java Virtual Machine that aims to provide productivity features like closures, builders, and metaprogramming while leveraging Java's capabilities. The document discusses why developers should use Groovy to build Atlassian plugins, noting features like closures, domain specific languages, and builders that improve productivity. It addresses myths that dynamic typing reduces IDE support and that scripting languages are unprofessional. Code examples demonstrate how Groovy code can be more concise and readable than equivalent Java code.
Metaprogramming is the writing of computer programs that write or manipulate other programs (or themselves) as their data. - Wikipedia
The Groovy language supports two flavors of metaprogramming:
# Runtime metaprogramming, and
# Compile-time metaprogramming.
The first one allows altering the class model and the behavior of a program at runtime, while the second only occurs at compile-time.
This document introduces GrooScript, an open source library that converts Groovy code to JavaScript. It provides examples of Groovy code and the corresponding JavaScript output. Key points covered include:
- GrooScript allows continued development in Groovy while outputting JavaScript that can be used in browsers.
- It supports common Groovy features like closures, meta programming and types while making the code more JavaScript friendly.
- The library can be used directly, or with Gradle and Grails plugins to facilitate conversion of Groovy code to JavaScript.
- While not a perfect translation, GrooScript enables continued use of the Groovy development experience for client-side code. The author provides several
This document discusses several core Java concepts including comments, classes, objects, scopes, static methods and fields, arrays, and constructors. It provides examples of Java code for classes, methods, and constructors. Key points covered include: javadoc comments generate API documentation; classes describe data and operations on objects; scopes are determined by curly braces; static methods and fields belong to the class not instances; arrays are objects that can be dynamically allocated; and constructors create class instances and invoke superclass constructors.
Method Shelters : Another Way to Resolve Class Extension Conflicts S Akai
This document discusses method shelters, a new module system for Ruby that aims to resolve conflicts caused by open classes. Method shelters allow defining methods locally within a scope and importing other shelters while preventing conflicts. Key aspects include hidden chambers to protect internally used methods, and a lookup algorithm that prioritizes local shelters over global methods. The implementation adds method shelters as implicit arguments and uses caching to optimize performance. Method shelters can help optimize applications, mimic private variables, and resolve conflicts from open class extensions.
Learn Ruby Programming in Amc Square LearningASIT Education
AMC Squarelearning Bangalore is the best training institute for a career development. it had students from various parts of the country and even few were from West African countries.
Fort de ses 1.7 millions de téléchargements l'an passé, Groovy continue son bonhomme de chemin en tête parmi les langages de programmation alternatifs pour la JVM.
Groovy 2.0, sorti l'an passé, introduisait dans son offre de la modularité, le support de JDK 7 au niveau syntaxique avec "Project Coin" autant qu'au niveau JVM avec l'utilisation d'"invoke dynamic", et proposait des fonctionnalités de typage et de compilation statique.
Groovy 2.1, quant à lui, s'appuie sur ces bases pour compléter le support d'"invoke dynamic" pour plus de performances. Il propose des améliorations permettant de documenter, d'aider les IDEs, et de vérifier statiquement les Domain-Specific Languages construits avec Groovy. Vous pourrez créer des méta-annotations regroupant d'autres annotations, pour éviter l'annotation "hell". Et enfin, vous irez encore plus loin dans la customisation du compilateur !
Accrochez votre ceinture, paré au décollage !
Groovy 2.0 includes alignments with JDK 7, support for invoke dynamic, continued runtime performance improvements, static type checking, static compilation, and modularity. Some key features include command chains for more readable DSL code, closure enhancements, and bundled support for multicore programming with GPars.
Groovy Domain Specific Languages - SpringOne2GX 2012Guillaume Laforge
Paul King, Andrew Eisenberg and Guillaume Laforge present about implementation of Domain-Specific Languages in Groovy, while at the SpringOne2GX 2012 conference in Washington DC.
The document discusses new features in Groovy 2.0, including alignments with JDK 7 like Project Coin changes and invoke dynamic support, as well as static type checking, compilation, and modularity. It also covers improvements to Groovy 1.8 like command chains which allow dropping dots and parentheses when chaining method calls to write more readable code.
The document summarizes new features and enhancements in Groovy 2.0, including:
1) Command chains allow dropping dots and parentheses when chaining method calls to write more readable business rules.
2) Closure enhancements include annotation parameters, composition, trampolining, and improved memoization.
3) Builtin JSON support allows consuming, producing, and pretty-printing JSON.
Groovy 2.0 introduces several new features including command chains that allow dropping dots and parentheses when chaining method calls to write more readable DSL-style code. Other improvements include performance enhancements, built-in JSON support, and continued work on static type checking and static compilation.
The document discusses new features in Groovy 2.0 including alignments with JDK 7 such as Project Coin language changes and invoke dynamic support. It also discusses continued runtime performance improvements, static type checking, static compilation, and modularity. Additionally, the document provides an overview of improvements and enhancements to command chains, closures, and parallel programming support in Groovy 1.8.
Groovy 2.0 update - Cloud Foundry Open Tour Moscow - Guillaume LaforgeGuillaume Laforge
The document discusses new features in Groovy 1.8 and upcoming changes in Groovy 2.0. Key points include:
- Groovy 1.8 introduced "command chains" allowing method calls to be written without dots or parentheses for improved readability.
- Other Groovy 1.8 features included performance improvements, GPars for concurrency, and built-in JSON support.
- Groovy 2.0 will align more with JDK 7, add static type checking and compilation, and improve modularity.
The document discusses new features in Groovy 1.8 and upcoming features in Groovy 2.0, as presented by Guillaume Laforge, Groovy project manager. It introduces "command chains", which allow dropping dots and parentheses when chaining method calls to write more readable DSLs. It provides examples of command chains for medication instructions and making coffee. Upcoming features discussed for Groovy 2.0 include alignments with JDK 7, continued runtime performance improvements, static type checking, static compilation, and modularity.
Groovy Update, new in 1.8 and beyond - Guillaume Laforge - Devoxx 2011Guillaume Laforge
The document discusses new features in Groovy 1.8 including command chains that allow dropping dots and parentheses when chaining method calls, runtime performance improvements, and bundling of GPars for parallel programming. It also outlines plans for Groovy 2.0 such as alignments with JDK 7 including Project Coin and invokedynamic for continued runtime optimizations and static type checking.
The document discusses new features in Groovy 1.8 and beyond, including command chains expressions that allow dropping dots and parentheses when chaining method calls to write more readable domain-specific languages resembling plain English. It provides examples of medical instructions and coffee preparation written using this new syntax without punctuation. The author also outlines further syntax optimizations and control structures possible with command chains.
The document discusses Gaelyk, a lightweight Groovy toolkit for developing applications on Google App Engine Java. Gaelyk builds on Groovy's servlet support by allowing developers to write Groovlets instead of raw servlets and use Groovy templates. It provides enhancements to the GAE Java SDK by leveraging Groovy's dynamic nature. The document demonstrates how Gaelyk simplifies common tasks like sending emails, accessing and querying the datastore, and implementing MVC patterns using Groovlets and templates.
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...Guillaume Laforge
The document discusses Domain Specific Languages (DSLs) and their use in Groovy. It provides an introduction to DSLs, their goals, examples of technical and business DSLs, and pros and cons of using DSLs. The document also discusses various Groovy features that are useful for creating DSLs, such as optional typing, native syntax constructs, command chain expressions, and adding properties to numbers. Paul King and Guillaume Laforge are identified as presenters on DSLs in Groovy.
Groovy update - S2GForum London 2011 - Guillaume LaforgeGuillaume Laforge
Groovy Update: what's new in 1.8 and what's coming in 1.9
The Groovy Development team is releasing Groovy 1.8, and this session will cover the new features including improved support for advanced and readable Domain-Specific Languages thanks to Groovy 1.8's "Extended Command Expressions", new performance improvements in the area of integer arithmetics, built-in support for parsing and producing JSON payloads, new AST transformations and now GPars come already bundled.
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Aqusag Technologies
In late April 2025, a significant portion of Europe, particularly Spain, Portugal, and parts of southern France, experienced widespread, rolling power outages that continue to affect millions of residents, businesses, and infrastructure systems.
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxJustin Reock
Building 10x Organizations with Modern Productivity Metrics
10x developers may be a myth, but 10x organizations are very real, as proven by the influential study performed in the 1980s, ‘The Coding War Games.’
Right now, here in early 2025, we seem to be experiencing YAPP (Yet Another Productivity Philosophy), and that philosophy is converging on developer experience. It seems that with every new method we invent for the delivery of products, whether physical or virtual, we reinvent productivity philosophies to go alongside them.
But which of these approaches actually work? DORA? SPACE? DevEx? What should we invest in and create urgency behind today, so that we don’t find ourselves having the same discussion again in a decade?
Big Data Analytics Quick Research Guide by Arthur MorganArthur Morgan
This is a Quick Research Guide (QRG).
QRGs include the following:
- A brief, high-level overview of the QRG topic.
- A milestone timeline for the QRG topic.
- Links to various free online resource materials to provide a deeper dive into the QRG topic.
- Conclusion and a recommendation for at least two books available in the SJPL system on the QRG topic.
QRGs planned for the series:
- Artificial Intelligence QRG
- Quantum Computing QRG
- Big Data Analytics QRG
- Spacecraft Guidance, Navigation & Control QRG (coming 2026)
- UK Home Computing & The Birth of ARM QRG (coming 2027)
Any questions or comments?
- Please contact Arthur Morgan at [email protected].
100% human made.
Spark is a powerhouse for large datasets, but when it comes to smaller data workloads, its overhead can sometimes slow things down. What if you could achieve high performance and efficiency without the need for Spark?
At S&P Global Commodity Insights, having a complete view of global energy and commodities markets enables customers to make data-driven decisions with confidence and create long-term, sustainable value. 🌍
Explore delta-rs + CDC and how these open-source innovations power lightweight, high-performance data applications beyond Spark! 🚀
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell
With expertise in data architecture, performance tracking, and revenue forecasting, Andrew Marnell plays a vital role in aligning business strategies with data insights. Andrew Marnell’s ability to lead cross-functional teams ensures businesses achieve sustainable growth and operational excellence.
Book industry standards are evolving rapidly. In the first part of this session, we’ll share an overview of key developments from 2024 and the early months of 2025. Then, BookNet’s resident standards expert, Tom Richardson, and CEO, Lauren Stewart, have a forward-looking conversation about what’s next.
Link to recording, presentation slides, and accompanying resource: https://bnctechforum.ca/sessions/standardsgoals-for-2025-standards-certification-roundup/
Presented by BookNet Canada on May 6, 2025 with support from the Department of Canadian Heritage.
This is the keynote of the Into the Box conference, highlighting the release of the BoxLang JVM language, its key enhancements, and its vision for the future.
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Impelsys Inc.
Impelsys provided a robust testing solution, leveraging a risk-based and requirement-mapped approach to validate ICU Connect and CritiXpert. A well-defined test suite was developed to assess data communication, clinical data collection, transformation, and visualization across integrated devices.
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfAbi john
Analyze the growth of meme coins from mere online jokes to potential assets in the digital economy. Explore the community, culture, and utility as they elevate themselves to a new era in cryptocurrency.
Quantum Computing Quick Research Guide by Arthur MorganArthur Morgan
This is a Quick Research Guide (QRG).
QRGs include the following:
- A brief, high-level overview of the QRG topic.
- A milestone timeline for the QRG topic.
- Links to various free online resource materials to provide a deeper dive into the QRG topic.
- Conclusion and a recommendation for at least two books available in the SJPL system on the QRG topic.
QRGs planned for the series:
- Artificial Intelligence QRG
- Quantum Computing QRG
- Big Data Analytics QRG
- Spacecraft Guidance, Navigation & Control QRG (coming 2026)
- UK Home Computing & The Birth of ARM QRG (coming 2027)
Any questions or comments?
- Please contact Arthur Morgan at [email protected].
100% human made.
Generative Artificial Intelligence (GenAI) in BusinessDr. Tathagat Varma
My talk for the Indian School of Business (ISB) Emerging Leaders Program Cohort 9. In this talk, I discussed key issues around adoption of GenAI in business - benefits, opportunities and limitations. I also discussed how my research on Theory of Cognitive Chasms helps address some of these issues
Dev Dives: Automate and orchestrate your processes with UiPath MaestroUiPathCommunity
This session is designed to equip developers with the skills needed to build mission-critical, end-to-end processes that seamlessly orchestrate agents, people, and robots.
📕 Here's what you can expect:
- Modeling: Build end-to-end processes using BPMN.
- Implementing: Integrate agentic tasks, RPA, APIs, and advanced decisioning into processes.
- Operating: Control process instances with rewind, replay, pause, and stop functions.
- Monitoring: Use dashboards and embedded analytics for real-time insights into process instances.
This webinar is a must-attend for developers looking to enhance their agentic automation skills and orchestrate robust, mission-critical processes.
👨🏫 Speaker:
Andrei Vintila, Principal Product Manager @UiPath
This session streamed live on April 29, 2025, 16:00 CET.
Check out all our upcoming Dev Dives sessions at https://community.uipath.com/dev-dives-automation-developer-2025/.
How Can I use the AI Hype in my Business Context?Daniel Lehner
𝙄𝙨 𝘼𝙄 𝙟𝙪𝙨𝙩 𝙝𝙮𝙥𝙚? 𝙊𝙧 𝙞𝙨 𝙞𝙩 𝙩𝙝𝙚 𝙜𝙖𝙢𝙚 𝙘𝙝𝙖𝙣𝙜𝙚𝙧 𝙮𝙤𝙪𝙧 𝙗𝙪𝙨𝙞𝙣𝙚𝙨𝙨 𝙣𝙚𝙚𝙙𝙨?
Everyone’s talking about AI but is anyone really using it to create real value?
Most companies want to leverage AI. Few know 𝗵𝗼𝘄.
✅ What exactly should you ask to find real AI opportunities?
✅ Which AI techniques actually fit your business?
✅ Is your data even ready for AI?
If you’re not sure, you’re not alone. This is a condensed version of the slides I presented at a Linkedin webinar for Tecnovy on 28.04.2025.
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul
Artificial intelligence is changing how businesses operate. Companies are using AI agents to automate tasks, reduce time spent on repetitive work, and focus more on high-value activities. Noah Loul, an AI strategist and entrepreneur, has helped dozens of companies streamline their operations using smart automation. He believes AI agents aren't just tools—they're workers that take on repeatable tasks so your human team can focus on what matters. If you want to reduce time waste and increase output, AI agents are the next move.
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxshyamraj55
We’re bringing the TDX energy to our community with 2 power-packed sessions:
🛠️ Workshop: MuleSoft for Agentforce
Explore the new version of our hands-on workshop featuring the latest Topic Center and API Catalog updates.
📄 Talk: Power Up Document Processing
Dive into smart automation with MuleSoft IDP, NLP, and Einstein AI for intelligent document workflows.
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungenpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-nomad-web-best-practices-und-verwaltung-von-multiuser-umgebungen/
HCL Nomad Web wird als die nächste Generation des HCL Notes-Clients gefeiert und bietet zahlreiche Vorteile, wie die Beseitigung des Bedarfs an Paketierung, Verteilung und Installation. Nomad Web-Client-Updates werden “automatisch” im Hintergrund installiert, was den administrativen Aufwand im Vergleich zu traditionellen HCL Notes-Clients erheblich reduziert. Allerdings stellt die Fehlerbehebung in Nomad Web im Vergleich zum Notes-Client einzigartige Herausforderungen dar.
Begleiten Sie Christoph und Marc, während sie demonstrieren, wie der Fehlerbehebungsprozess in HCL Nomad Web vereinfacht werden kann, um eine reibungslose und effiziente Benutzererfahrung zu gewährleisten.
In diesem Webinar werden wir effektive Strategien zur Diagnose und Lösung häufiger Probleme in HCL Nomad Web untersuchen, einschließlich
- Zugriff auf die Konsole
- Auffinden und Interpretieren von Protokolldateien
- Zugriff auf den Datenordner im Cache des Browsers (unter Verwendung von OPFS)
- Verständnis der Unterschiede zwischen Einzel- und Mehrbenutzerszenarien
- Nutzung der Client Clocking-Funktion
HCL Nomad Web – Best Practices and Managing Multiuser Environmentspanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-nomad-web-best-practices-and-managing-multiuser-environments/
HCL Nomad Web is heralded as the next generation of the HCL Notes client, offering numerous advantages such as eliminating the need for packaging, distribution, and installation. Nomad Web client upgrades will be installed “automatically” in the background. This significantly reduces the administrative footprint compared to traditional HCL Notes clients. However, troubleshooting issues in Nomad Web present unique challenges compared to the Notes client.
Join Christoph and Marc as they demonstrate how to simplify the troubleshooting process in HCL Nomad Web, ensuring a smoother and more efficient user experience.
In this webinar, we will explore effective strategies for diagnosing and resolving common problems in HCL Nomad Web, including
- Accessing the console
- Locating and interpreting log files
- Accessing the data folder within the browser’s cache (using OPFS)
- Understand the difference between single- and multi-user scenarios
- Utilizing Client Clocking
2. Guillaume Laforge
• Groovy Project Manager at VMware
• Initiator of the Grails framework
• Creator of the Gaelyk
• Co-author of Groovy in Action
• Follow me on...
• My blog: http://glaforge.appspot.com
• Twitter: @glaforge
• Google+: http://gplus.to/glaforge
16. Groovy Modularity
• Groovy’s « all » JAR weighs in at 6 MB
• Nobody needs everything
• Template engine, Ant scripting, Swing UI building...
• Provide a smaller core
• and several smaller JARs per feature
• Provide hooks for setting up DGM methods,
17. The new JARs
• A smaller JAR: 3MB
• Modules
– console – jsr-223 – test
– docgenerator – jmx – testng
– groovydoc – sql – json
– groovysh – swing – xml
– ant – servlet
– bsf – templates
18. The new JARs
• A smaller JAR: 3MB
• Modules
– console – jsr-223 – test
– docgenerator – jmx – testng
– groovydoc – sql – json
– groovysh – swing – xml
– ant – servlet
– bsf – templates
25. Binary literals
• We had decimal, octal and hexadecimal
notations for number literals
• We can now use binary representations too
int
x
=
0b10101111
assert
x
==
175
byte
aByte
=
0b00100001
assert
aByte
==
33
int
anInt
=
0b1010000101000101
assert
anInt
==
41285
26. Underscore in literals
• Now we can also add underscores
in number literals for more readability
long
creditCardNumber
=
1234_5678_9012_3456L
long
socialSecurityNumbers
=
999_99_9999L
float
monetaryAmount
=
12_345_132.12
long
hexBytes
=
0xFF_EC_DE_5E
long
hexWords
=
0xFFEC_DE5E
long
maxLong
=
0x7fff_ffff_ffff_ffffL
long
alsoMaxLong
=
9_223_372_036_854_775_807L
long
bytes
=
0b11010010_01101001_10010100_10010010
27. Multicatch
• One block for multiple exception caught
• rather than duplicating the block
try
{
/*
...
*/
}
catch(IOException
|
NullPointerException
e)
{
/*
one
block
to
treat
2
exceptions
*/
}
28. InvokeDynamic
• Groovy 2.0 supports JDK 7’s
invokeDynamic
• compiler has a flag for compiling against JDK 7
• might use the invokeDynamic backport for < JDK 7
• Benefits
• more runtime performance!
• at least as fast as current « dynamic » Groovy
• in the long run, will allow us to get rid of code!
• call site caching, thanks to MethodHandles
• metaclass registry, thanks to ClassValues
• will let the JIT inline calls more easily
29. Groovy 2.0 bird’s eye view
Java 7 Static Type
A more Project
Checking
modular Coin
Groovy Invoke Static
Compilation
Dynamic
31. Static Type Checking
• Goal: make the Groovy compiler « grumpy »!
• and throw compilation errors (not at runtime)
• Not everybody needs dynamic features
all the time
• think Java libraries scripting
• Grumpy should...
• tell you about your method or variable typos
• complain if you call methods that don’t exist
• shout on assignments of wrong types
• infer the types of your variables
• figure out GDK methods
32. Typos in a variable or method
import
groovy.transform.TypeChecked
void
method()
{}
@TypeChecked
test()
{
//
Cannot
find
matching
method
metthhoood()
metthhoood()
def
name
=
"Guillaume"
//
variable
naamme
is
undeclared
println
naamme
}
33. Typos in a variable or method
import
groovy.transform.TypeChecked
void
method()
{}
@TypeChecked
test()
{
//
Cannot
find
matching
method
metthhoood()
metthhoood()
Compilation
errors!
def
name
=
"Guillaume"
//
variable
naamme
is
undeclared
println
naamme
}
34. Typos in a variable or method
Annotation can be at
class or method level
import
groovy.transform.TypeChecked
void
method()
{}
@TypeChecked
test()
{
//
Cannot
find
matching
method
metthhoood()
metthhoood()
Compilation
errors!
def
name
=
"Guillaume"
//
variable
naamme
is
undeclared
println
naamme
}
35. Wrong assignments
//
cannot
assign
value
of
type...
to
variable...
int
x
=
new
Object()
Set
set
=
new
Object()
def
o
=
new
Object()
int
x
=
o
String[]
strings
=
['a','b','c']
int
str
=
strings[0]
//
cannot
find
matching
method
plus()
int
i
=
0
i
+=
'1'
36. Wrong assignments
//
cannot
assign
value
of
type...
to
variable...
int
x
=
new
Object()
Set
set
=
new
Object() Compilation
def
o
=
new
Object() errors!
int
x
=
o
String[]
strings
=
['a','b','c']
int
str
=
strings[0]
//
cannot
find
matching
method
plus()
int
i
=
0
i
+=
'1'
37. Wrong return types
//
checks
if/else
branch
return
values
@TypeChecked
int
method()
{
if
(true)
{
'String'
}
else
{
42
}
}
//
works
for
switch/case
&
try/catch/finally
//
transparent
toString()
implied
@TypeChecked
String
greeting(String
name)
{
def
sb
=
new
StringBuilder()
sb
<<
"Hi
"
<<
name
}
38. Wrong return types
//
checks
if/else
branch
return
values
@TypeChecked
int
method()
{
Compilation
if
(true)
{
'String'
} error!
else
{
42
}
}
//
works
for
switch/case
&
try/catch/finally
//
transparent
toString()
implied
@TypeChecked
String
greeting(String
name)
{
def
sb
=
new
StringBuilder()
sb
<<
"Hi
"
<<
name
}
39. Type inference
@TypeChecked
test()
{
def
name
=
"
Guillaume
"
//
String
type
infered
(even
inside
GString)
println
"NAME
=
${name.toUpperCase()}"
//
Groovy
GDK
method
support
//
(GDK
operator
overloading
too)
println
name.trim()
int[]
numbers
=
[1,
2,
3]
//
Element
n
is
an
int
for
(int
n
in
numbers)
{
println
n
}
}
40. Statically checked & dynamic methods
@TypeChecked
String
greeting(String
name)
{
//
call
method
with
dynamic
behavior
//
but
with
proper
signature
generateMarkup(name.toUpperCase())
}
//
usual
dynamic
behavior
String
generateMarkup(String
name)
{
def
sw
=
new
StringWriter()
new
MarkupBuilder(sw).html
{
body
{
div
name
}
}
sw.toString()
}
41. Instanceof checks
@TypeChecked
void
test(Object
val)
{
if
(val
instanceof
String)
{
println
val.toUpperCase()
}
else
if
(val
instanceof
Number)
{
println
"X"
*
val.intValue()
}
}
42. Instanceof checks
@TypeChecked
void
test(Object
val)
{
No need
if
(val
instanceof
String)
{
println
val.toUpperCase() for casts
}
else
if
(val
instanceof
Number)
{
println
"X"
*
val.intValue()
}
}
43. Instanceof checks
@TypeChecked
void
test(Object
val)
{
No need
if
(val
instanceof
String)
{
println
val.toUpperCase() for casts
}
else
if
(val
instanceof
Number)
{
println
"X"
*
val.intValue()
}
}
Can call String#multiply(int)
from the Groovy Development Kit
44. Lowest Upper Bound
• Represents the lowest « super » type
classes have in common
• may be virtual (aka « non-denotable »)
@TypeChecked
test()
{
//
an
integer
and
a
BigDecimal
return
[1234,
3.14]
}
45. Lowest Upper Bound
• Represents the lowest « super » type
classes have in common
• may be virtual (aka « non-denotable »)
@TypeChecked
test()
{
//
an
integer
and
a
BigDecimal
return
[1234,
3.14]
}
Inferred return type:
List<Number & Comparable>
46. Lowest Upper Bound
• Represents the lowest « super » type
classes have in common
• may be virtual (aka « non-denotable »)
@TypeChecked
test()
{
//
an
integer
and
a
BigDecimal
return
[1234,
3.14]
}
Inferred return type:
List<Number & Comparable>
47. Flow typing
• Static type checking shouldn’t complain
even for bad coding practicies
which work without type checks
@TypeChecked
test()
{
def
var
=
123
//
inferred
type
is
int
int
x
=
var
//
var
is
an
int
var
=
"123"
//
assign
var
with
a
String
x
=
var.toInteger()
//
no
problem,
no
need
to
cast
var
=
123
x
=
var.toUpperCase()
//
error,
var
is
int!
}
48. Gotcha: static checking vs dynamic
• Type checking works at compile-time
• adding @TypeChecked doesn’t change behavior
• do not confuse with static compilation
• Most dynamic features cannot be type checked
• metaclass changes, categories
• dynamically bound variables (ex: script’s binding)
• But compile-time metaprogramming works
• as long as proper type information is defined
50. Gotcha: runtime metaprogramming
@TypeChecked
void
test()
{
Integer.metaClass.foo
=
{}
123.foo()
}
Not allowed:
metaClass property
is dynamic
51. Gotcha: runtime metaprogramming
@TypeChecked
void
test()
{
Integer.metaClass.foo
=
{}
123.foo()
}
Method not Not allowed:
recognized metaClass property
is dynamic
52. Gotcha: explicit type for closures
@TypeChecked
test()
{
["a",
"b",
"c"].collect
{
it.toUpperCase()
//
Not
OK
}
}
53. Gotcha: explicit type for closures
@TypeChecked
test()
{
["a",
"b",
"c"].collect
{
String
it
-‐>
it.toUpperCase()
//
OK,
it’s
a
String
}
}
54. Closure shared variables
@TypeChecked
test()
{
def
var
=
"abc"
def
cl
=
{
var
=
new
Date()
}
if
(random)
cl()
var.toUpperCase()
//
Not
OK!
}
55. Closure shared variables
var assigned in the closure:
« shared closure variable »
@TypeChecked
test()
{
def
var
=
"abc"
def
cl
=
{
var
=
new
Date()
}
if
(random)
cl()
var.toUpperCase()
//
Not
OK!
}
56. Closure shared variables
var assigned in the closure:
« shared closure variable »
@TypeChecked
test()
{
Impossible to
def
var
=
"abc"
ensure the
def
cl
=
{
var
=
new
Date()
}
assignment
if
(random)
cl()
really happens
var.toUpperCase()
//
Not
OK!
}
57. Closure shared variables
var assigned in the closure:
« shared closure variable »
@TypeChecked
test()
{
Impossible to
def
var
=
"abc"
ensure the
def
cl
=
{
var
=
new
Date()
}
assignment
if
(random)
cl()
really happens
var.toUpperCase()
//
Not
OK!
}
Only methods of the most specific compatible
type (LUB) are allowed by the type checker
58. Closure shared variables
class
A
{
void
foo()
{}
}
class
B
extends
A
{
void
bar()
{}
}
@TypeChecked
test()
{
def
var
=
new
A()
def
cl
=
{
var
=
new
B()
}
if
(random)
cl()
var.foo()
//
OK!
}
59. Closure shared variables
class
A
{
void
foo()
{}
}
class
B
extends
A
{
void
bar()
{}
}
@TypeChecked
test()
{
def
var
=
new
A()
def
cl
=
{
var
=
new
B()
}
if
(random)
cl()
var.foo()
//
OK!
}
var is at least an
instance of A
60. Static Compilation
• Given your Groovy code can be type checked...
we can as well compile it « statically »
• ie. generate the same byte code as javac
• Also interesting for those stuck in JDK < 7
to benefit from performance improvements
61. Static Compilation: advantages
• You gain:
• Type safety
• thanks to static type checking
• static compilation builds upon static type checking
• Faster code
• as close as possible to Java’s performance
• Code immune to « monkey patching »
• metaprogramming badly used can interfere with
framework code
• Smaller bytecode size
62. Static Compilation: disadvantages
• But you loose:
• Dynamic features
• metaclass changes, categories, etc.
• Dynamic method dispatch
• although as close as possible to « dynamic » Groovy
63. Statically compiled & dynamic methods
@CompileStatic
String
greeting(String
name)
{
//
call
method
with
dynamic
behavior
//
but
with
proper
signature
generateMarkup(name.toUpperCase())
}
//
usual
dynamic
behavior
String
generateMarkup(String
name)
{
def
sw
=
new
StringWriter()
new
MarkupBuilder(sw).html
{
body
{
div
name
}
}
sw.toString()
}
64. What about performance?
• Comparisons between:
• Java
• Groovy static compilation (Groovy 2.0)
• Groovy with primitive optimizations (Groovy 1.8+)
• Groovy without optimizations (Groovy 1.7)
65. What about performance?
Pi (π) Binary
Fibonacci
quadrature trees
Java 191 ms 97 ms 3.6 s
1.7 1.8 2.0
Static
compilation 197 ms 101 ms 4.3 s
Primitive
optimizations 360 ms 111 ms 23.7 s
No prim.
optimizations 2590 ms 3220 ms 50.0 s
68. Full invoke dynamic support Groovy
2.1
• In Groovy 2.0, not all call paths
were going through invoke dynamic calls
• essentially method calls only
• still used call site caching techniques
• On JDK 7 with the « indy » JAR,
Groovy 2.1 uses invoke dynamic
everywhere
• On JDK < 7, still uses call site caching
69. @DelegatesTo Groovy
2.1
• Static type checking works nicely
for certain Domain-Specific Languages
• command chains, extension methods, etc.
• But for changes of delegation within closures,
it’s not helping
• often used by DSLs like within Gradle
• Enters @DelegatesTo!
70. @DelegatesTo Groovy
2.1
class
ExecSpec
{
void
foo()
}
76. @DelegatesTo Groovy
2.1
• With a special delegation strategy
void
exec(ExecSpec
sp,
Closure
c)
{
c.delegate
=
sp
c.resolveStrategy
=
DELEGATE_FIRST
c()
}
77. @DelegatesTo Groovy
2.1
• With a special delegation strategy
Annotate with:
@DelegatesTo(value = ExecSpec,
strategy = DELEGATE_FIRST)
void
exec(ExecSpec
sp,
Closure
c)
{
c.delegate
=
sp
c.resolveStrategy
=
DELEGATE_FIRST
c()
}
78. @DelegatesTo Groovy
2.1
• Use Target to specify the precise
argument to delegate to
void
exec(ExecSpec
sp,
Closure
c)
{
c.delegate
=
sp
c()
}
79. @DelegatesTo Groovy
2.1
• Use Target to specify the precise
argument to delegate to
@DelegatesTo.Target("id")
void
exec(ExecSpec
sp,
Closure
c)
{
c.delegate
=
sp
c()
}
80. @DelegatesTo Groovy
2.1
• Use Target to specify the precise
argument to delegate to
@DelegatesTo.Target("id") @DelegatesTo(target = "id")
void
exec(ExecSpec
sp,
Closure
c)
{
c.delegate
=
sp
c()
}
81. @DelegatesTo Groovy
2.1
• For DSLs using Groovy closure delegation
• Great for...
• documenting APIs
• IDE integration
• code completion, code navigation...
• working nicely with static type checking
and static compilation
82. Custom type checking Groovy
2.1
• You can make Groovy’s static type checking
even smarter, with your own smarts!
• even smarter than Java’s :-)
• Create your own type checker extension
@TypeChecked(extensions
=
'MyExtension.groovy')
void
exec()
{
//
code
to
be
further
checked...
}
83. Custom type checking Groovy
2.1
• Your own extension has access
to an event-based API
• onMethodSelection • methodNotFound
• afterMethodCall • unresolvedVariable
• beforeMethodCall • unresolvedProperty
• unresolvedAttribute
• afterVisitMethod
• beforeVisitMethod • incompatibleAssignment
86. Custom type checking Groovy
2.1
Doesn’t need
MyExtension.groovy to be compiled
onMethodSelection
{
expr,
method
-‐>
...
}
afterMethodCall
{
mc
-‐>
...
}
unresolvedVariable
{
var
-‐>
...
}
methodNotFound
{
receiver,
name,
argList,
argTypes,
call
-‐>
...
}
methodNotFound
{
receiver,
name,
argList,
argTypes,
call
-‐>
...
}
incompatibleAssignment
{
lhsType,
rhsType,
expr
-‐>
...
}
Know your
Groovy AST
API well ;-)
87. Alias annotations Groovy
2.1
• Ability to create meta-annotations
combining and/or parameterizing
other annotations
• Works also for local AST transformations
and their annotations
89. Alias annotations Groovy
2.1
@Immutable
@ToString(excludes
=
["age"])
@AnnotationCollector
@interface
MyAlias
{} The « collector »
90. Alias annotations Groovy
2.1
Collected
@Immutable
@ToString(excludes
=
["age"]) annotations
@AnnotationCollector
@interface
MyAlias
{} The « collector »
91. Alias annotations Groovy
2.1
Collected
@Immutable
@ToString(excludes
=
["age"]) annotations
@AnnotationCollector
@interface
MyAlias
{} The « collector »
Your own custom
alias name
92. Alias annotations Groovy
2.1
Collected
@Immutable
@ToString(excludes
=
["age"]) annotations
@AnnotationCollector
@interface
MyAlias
{} The « collector »
Your own custom
alias name @MyAlias
class
Foo
{
String
name
int
age
}
93. Alias annotations Groovy
2.1
Collected
@Immutable
@ToString(excludes
=
["age"]) annotations
@AnnotationCollector
@interface
MyAlias
{} The « collector »
Your own custom
alias name @MyAlias
class
Foo
{
Use your
String
name
concise alias
int
age
}
94. Take control of your Groovy! Groovy
2.1
• Groovy 1.8 introduced compilation customizers
• add imports, AST xforms, secure the AST...
• With static type checking and static
compilation, we received feedback from people
wanting them applied « by default »
• Allow to instruct the groovyc compiler
with a configuration script
• groovyc -configurator compConf.groovy Foo.groovy
95. Take control of your Groovy! Groovy
2.1
• Add a default @ToString transform
import
groovy.transform.ToString
import
org.codehaus.groovy.control.customizers
•
.ASTTransformationCustomizer
config.addCompilationCustomizer(
new
ASTTransformationCustomizer(ToString)
)
96. Take control of your Groovy! Groovy
2.1
• Add a default @ToString transform
import
groovy.transform.ToString
import
org.codehaus.groovy.control.customizers
•
.ASTTransformationCustomizer
config.addCompilationCustomizer(
new
ASTTransformationCustomizer(ToString)
)
Implicit «config» variable representing
a CompilationConfiguration instance
97. Take control of your Groovy! Groovy
2.1
• You can use a builder syntax:
config.customizers
{
//
apply
to
MyBean.groovy
source(basename:
'MyBean')
{
ast(ToString)
}
}
98. Take control of your Groovy! Groovy
2.1
• You can use a builder syntax:
config.customizers
{
//
apply
to
MyBean.groovy
config.customizers
{
source(basename:
'MyBean')
{
//
apply
to
*.gbean
files
ast(ToString)
source(extension:
'.gbean')
{
}
ast(ToString)
}
}
}
99. Take control of your Groovy! Groovy
2.1
• You can use a builder syntax:
config.customizers
{
//
apply
to
MyBean.groovy
config.customizers
{
source(basename:
'MyBean')
{
//
apply
to
*.gbean
files
ast(ToString)
config.customizers
{
source(extension:
'.gbean')
{
}
//
custom
filter
logic
ast(ToString)
}
//
with
compilation
units
}
}
source(unitValidator:
{
unit
-‐>
...
})
{
ast(ToString)
}
}
124. Summary (1/2)
• As always, a rich and blossoming ecosystem
• Groovy 2.0
• more modularity
• static theme
• static type checking
• static compilation
• JDK 7 theme
• invoke dynamic support
• project coin syntax enhancements
125. Summary (2/2)
• Groovy 2.1
• complete indy support
• @DelegatesTo
• custom type checking for your DSLs
• alias annotation
• And beyond...
• a new MOP (Meta-Object Protocol)
• a new grammar with Antlr 4
• JDK 8 lambda support
126. Thank you!
ge
me Lafor lopment
Guillau roovy Deve
G
H ead of m
@g mail.co
laforge rge
Email: g @glafo /glaforg
e
: .to
Twitter : http://gplus spot.com
+ pp
Google p://glaforge.a
tt
Blog: h
127. Picture credits
• London
http://www.londonup.com/media/1251/Tower-Bridge-london-582331_1024_768.jpg
• cherry blossom
http://wallpaperswide.com/cherry_blossom_3-wallpapers.html
• NKOTB
http://images1.fanpop.com/images/photos/2300000/nkotb-new-kids-on-the-block-2314664-1280-960.jpg
• USA today
http://www.adams-pr.com/images/uploads/USA_Today_logo.jpg
• back to the future
http://davidhiggerson.files.wordpress.com/2012/02/back-to-the-future-delorean.jpg
• magnifying glass
http://www.renders-graphiques.fr/image/upload/normal/loupe.png
• Santa Claus
http://icons.iconarchive.com/icons/fasticon/santa-claus/256/Happy-SantaClaus-icon.png
• Champagne
http://reallife101blogs.files.wordpress.com/2010/11/champagne_glasses2.jpg
• that’s all folks
http://4.bp.blogspot.com/-wJxosualm48/T4M_spcUUjI/AAAAAAAAB8E/njfLjNZQdsc/s1600/thats-all-folks.jpg
• MOP
http://imagethumbnails.milo.com/024/913/894/trimmed/24913521_25989894_trimmed.jpg
• grammar
http://edudemic.com/wp-content/uploads/2012/11/connected-learner-grammar.jpg