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 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.
Ten common mistakes made with Functional Java JBCNConf18Brian Vermeer
Slides from my talk "Ten common mistakes made with Functional Java" @ JBCNConf 2018 Barcelona.
Beware that the slides are just here as a reference to people who attended this particular version of the talk. Please do not make assumptions purely from the slides alone ... there is a story with it ...really ;)
Changing the wheels on the bus at 80 mph
Andrew Bloomgarden and Julian Giuca
RailsConf 2013
Long-running branches are painful, but upgrading to Rails 3 requires one if you can't stop development, right? Wrong! At New Relic, we worked on upgrading to Rails 3 on master while letting development continue in Rails 2. We patched Bundler, built a backwards-compatible boot sequence, and punched ActiveScaffold in the face. Other developers, meanwhile, released 1400 commits worth of work without noticing any changes. We talk about what we did, why we did it, and why we think this approach can help developers get over the hurdle into the Rails 3 promised land.
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 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.
Ten common mistakes made with Functional Java JBCNConf18Brian Vermeer
Slides from my talk "Ten common mistakes made with Functional Java" @ JBCNConf 2018 Barcelona.
Beware that the slides are just here as a reference to people who attended this particular version of the talk. Please do not make assumptions purely from the slides alone ... there is a story with it ...really ;)
Changing the wheels on the bus at 80 mph
Andrew Bloomgarden and Julian Giuca
RailsConf 2013
Long-running branches are painful, but upgrading to Rails 3 requires one if you can't stop development, right? Wrong! At New Relic, we worked on upgrading to Rails 3 on master while letting development continue in Rails 2. We patched Bundler, built a backwards-compatible boot sequence, and punched ActiveScaffold in the face. Other developers, meanwhile, released 1400 commits worth of work without noticing any changes. We talk about what we did, why we did it, and why we think this approach can help developers get over the hurdle into the Rails 3 promised land.
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 and beyond" presentation given at the Groovy/Grails eXchange conference.
Video can be seen here:
http://skillsmatter.com/podcast/groovy-grails/keynote-speech
Alter Way's digitalks - Docker : des conteneurs pour tout faire ? ALTER WAY
Docker est un projet Open Source qui automatise le déploiement d’applications dans des conteneurs logiciels virtuels. Déjà utilisé par Google, Red Hat, RackSpace, ebay, Microsoft, Amazon, Docker rencontre un succès mondial et est en passe de révolutionner le marché du cloud et de la virtualisation.
Serveur web / Base de donnees Langages de développementLudovic REUS
Une présentation des outils et technologies de l'information et de la communication.
Les serveurs webs et leur marché à ce jour
Les base de données relationnelles et NoSQL
Les langages de développements informatiques
"Apache JMeter, Java et Groovy sont sur un bateau" présentée au Paris JUGAntonio Gomes Rodrigues
Que ce soit d’évaluer le niveau de sécurité d’un captcha, chiffrer le coût en performance d’activation des logs GC d’une JVM ou d’activer/désactiver des fonctionnalités de notre application par JMX lors d’un test, l’outil de test de charge Apache JMeter offre un spectre de fonctionnalités avancées digne des meilleures solutions éditeurs. Venez découvrir les possibilités infinies qu’offre Apache JMeter associé à du Java et du Groovy
Déploiement et gestion d'un site web avec RancherAnthony Sigogne
Nous verrons comment déployer en quelques minutes un site web sur un serveur privé grâce à une infrastructure sous forme de containers Docker : du serveur HTTP (Nginx) à la certification SSL (LetsEncrypt) en passant par l'installation d'un outil analytics (Piwik). Pour créer et gérer notre stack de containers, nous utiliserons Rancher, un service d'orchestration basé sur une interface utilisateur ergonomique.
Présentation faite lors du Docker Meetup Nouméa du 24/11/2016 :
http://www.meetup.com/fr-FR/Docker-Noumea/events/234912937/?eventId=234912937
Spinnaker est un outil open source de déploiement continu multi-cloud développé par Netflix.
Vous savez déjà construire vos applications avec Jenkins, venez découvrir comment automatiser tous vos déploiements.
Nous verrons ensemble comment créer une plate forme complète de déploiement continu jusqu'en production, à base de canary, blue/green et rollback.
Introduction à Docker et utilisation en production /Digital apéro Besançon [1...Silicon Comté
Docker est une plateforme open source, pour les développeurs et les administrateurs systèmes, destinée à empaqueter une application et ses dépendances dans le but de l’exécuter sur n’importe quel serveur.
Il a pour objectif de faciliter le déploiement d’une application, d’avoir plusieurs versions de celle-ci et également d’automatiser son packaging tout en gardant un système de base propre.
Alexandre Di Pino nous présentera cette technologie et l’utilisation qu’il en fait dans un contexte de production.
A propos de l’intervenant
Titulaire d’un master en informatique à Epitech, Alexandre travaille au sein de la société InSimo, société développant un moteur physique temps réel pour la simulation médicale. Twitter : @a_dipino / LinkedIn : alexandredipino
Docker ! De la découverte à la mise en production / Digital apéro [19/03/2015]Silicon Comté
Docker est une plateforme open source, pour les développeurs et les administrateurs systèmes, destinée à empaqueter une application et ses dépendances dans le but de l’exécuter sur n’importe quel serveur.
Que ce soit pour un free-lance ou une équipe, que ce soit pour le développement et/ou la mise en production, Docker est la solution qui va simplifier la gestion de vos projets.
Durant cette session René Cotton vous propose de découvrir Docker et voir comment l’utiliser pour le développement et la production.
A propos de l’intervenant
CoFondateur et Directeur Technique de WiziShop.com, depuis plus de 10 ans je mets toute mon énergie dans la création d’outil simple et performant. Depuis maintenant 7 ans cette énergie est focalisé sur le domaine du e-commerce.
Site : http://www.wizishop.com/
Twitter : @_Re_
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.
Groovy DSLs - S2GForum London 2011 - Guillaume LaforgeGuillaume Laforge
Design Your Own Domain Specific Language
This talk examines how dynamic languages in general and Groovy in particular provide toos to help design programming languages that are closer of the natural language of the target subject matter expert. It offers many features that allow you to create embedded DSLs: Closures, compile-time and run-time metaprogramming, operator overloading, named arguments, a more concise and expressive syntax and more.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Groovy 2.0 update at Devoxx 2012
1. What’s new in
Groovy 2.0?
Guillaume Laforge
Groovy Project Manager
SpringSource / VMware
@glaforge
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
3. Agenda (1/2)
• What’s in Groovy 1.8?
• Nicer DSLs with command chains
• Runtime performance improvements
• GPars bundled for taming your multicores
• Closure enhancements
• Builtin JSON support
• New AST transformations
4. Agenda (2/2)
• What’s new in Groovy 2.0?
• Alignments with JDK 7
•Project Coin (small language changes)
•Invoke Dynamic support
•
Continued runtime performance improvements
• Static type checking
• Static compilation
• Modularity
5. Command chains
• A grammar improvement allowing you
to drop dots & parens when chaining method calls
• an extended version of top-level statements like println
• Less dots, less parens allow you to
• write more readable business rules
• in almost plain English sentences
• (or any language, of course)
12. Command chains
//
methods
with
multiple
arguments
(commas)
13. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
14. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
//
leverage
named-‐args
as
punctuation
15. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
//
leverage
named-‐args
as
punctuation
check
that:
margarita
tastes
good
16. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
//
leverage
named-‐args
as
punctuation
check
that:
margarita
tastes
good
//
closure
parameters
for
new
control
structures
17. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
//
leverage
named-‐args
as
punctuation
check
that:
margarita
tastes
good
//
closure
parameters
for
new
control
structures
given
{}
when
{}
then
{}
18. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
//
leverage
named-‐args
as
punctuation
check
that:
margarita
tastes
good
//
closure
parameters
for
new
control
structures
given
{}
when
{}
then
{}
//
zero-‐arg
methods
require
parens
19. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
//
leverage
named-‐args
as
punctuation
check
that:
margarita
tastes
good
//
closure
parameters
for
new
control
structures
given
{}
when
{}
then
{}
//
zero-‐arg
methods
require
parens
select
all
unique()
from
names
20. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
//
leverage
named-‐args
as
punctuation
check
that:
margarita
tastes
good
//
closure
parameters
for
new
control
structures
given
{}
when
{}
then
{}
//
zero-‐arg
methods
require
parens
select
all
unique()
from
names
//
possible
with
an
odd
number
of
terms
21. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
//
leverage
named-‐args
as
punctuation
check
that:
margarita
tastes
good
//
closure
parameters
for
new
control
structures
given
{}
when
{}
then
{}
//
zero-‐arg
methods
require
parens
select
all
unique()
from
names
//
possible
with
an
odd
number
of
terms
take
3
cookies
22. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
(
).
(
).
(
)
//
leverage
named-‐args
as
punctuation
check
that:
margarita
tastes
good
//
closure
parameters
for
new
control
structures
given
{}
when
{}
then
{}
//
zero-‐arg
methods
require
parens
select
all
unique()
from
names
//
possible
with
an
odd
number
of
terms
take
3
cookies
23. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
(
).
(
).
(
)
//
leverage
named-‐args
as
punctuation
check
that:
margarita
tastes
good
(
).
(
)
//
closure
parameters
for
new
control
structures
given
{}
when
{}
then
{}
//
zero-‐arg
methods
require
parens
select
all
unique()
from
names
//
possible
with
an
odd
number
of
terms
take
3
cookies
24. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
(
).
(
).
(
)
//
leverage
named-‐args
as
punctuation
check
that:
margarita
tastes
good
(
).
(
)
//
closure
parameters
for
new
control
structures
given
{}
when
{}
then
{}
(
).
(
).
(
)
//
zero-‐arg
methods
require
parens
select
all
unique()
from
names
//
possible
with
an
odd
number
of
terms
take
3
cookies
25. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
(
).
(
).
(
)
//
leverage
named-‐args
as
punctuation
check
that:
margarita
tastes
good
(
).
(
)
//
closure
parameters
for
new
control
structures
given
{}
when
{}
then
{}
(
).
(
).
(
)
//
zero-‐arg
methods
require
parens
select
all
unique()
from
names
(
).
.
(
)
//
possible
with
an
odd
number
of
terms
take
3
cookies
26. Command chains
//
methods
with
multiple
arguments
(commas)
take
coffee
with
sugar,
milk
and
liquor
(
).
(
).
(
)
//
leverage
named-‐args
as
punctuation
check
that:
margarita
tastes
good
(
).
(
)
//
closure
parameters
for
new
control
structures
given
{}
when
{}
then
{}
(
).
(
).
(
)
//
zero-‐arg
methods
require
parens
select
all
unique()
from
names
(
).
.
(
)
//
possible
with
an
odd
number
of
terms
take
3
cookies
(
).
27. GPars bundled
• GPars is bundled in the Groovy distribution
• GPars covers a wide range of parallel
and concurrent paradigms
• actors, fork/join, map/filter/reduce, dataflow, agents
• parallel arrays, executors, STM, and more...
• And you can use it from plain Java as well!
• http://gpars.codehaus.org/
28. Closure enhancements
• Closure annotation parameters
• Some more functional flavor
• composition
• compose several closures into one single closure
• trampoline
• avoid stack overflow errors for recursive algorithms
• memoization
• remember the outcome of previous closure invocations
• currying improvements
29. Closure annotation parameters
@Retention(RetentionPolicy.RUNTIME)
@interface
Invariant
{
Class
value()
//
a
closure
class
}
{ @Invariant({
number
>=
0
})
class
Distance
{
float
number
String
unit
}
def
d
=
new
Distance(number:
10,
unit:
"meters")
def
anno
=
Distance.getAnnotation(Invariant)
def
check
=
anno.value().newInstance(d,
d)
assert
check(d)
30. Closure annotation parameters
@Retention(RetentionPolicy.RUNTIME)
@interface
Invariant
{
Class
value()
//
a
closure
class
}
Contr acts
{ @Invariant({
number
>=
0
})
class
Distance
{
float
number
P oor-m an’s G
String
unit
}
def
d
=
new
Distance(number:
10,
unit:
"meters")
def
anno
=
Distance.getAnnotation(Invariant)
def
check
=
anno.value().newInstance(d,
d)
assert
check(d)
51. @Log
• Four different loggers can be injected
• @Log import
groovy.util.logging.*
• @Commons
• @Log4j @Log
class
Car
{
• @Slf4j
Car()
{
log.info
'Car
constructed'
}
• Possible to implement }
your own strategy def
c
=
new
Car()
52. @Log
• Four different loggers can be injected
• @Log import
groovy.util.logging.*
• @Commons
• @Log4j Guarded
@Log
class
Car
{
• @Slf4j w/ an if
Car()
{
log.info
'Car
constructed'
}
• Possible to implement }
your own strategy def
c
=
new
Car()
53. Controlling code execution
• Your application may run user’s code
• what if the code runs in infinite loops or for too long?
• what if the code consumes too many resources?
• 3 new transforms at your rescue
• @ThreadInterrupt: adds Thread#isInterrupted checks so your
executing thread stops when interrupted
• @TimedInterrupt: adds checks in method and closure bodies to
verify it’s run longer than expected
• @ConditionalInterrupt: adds checks with your own conditional
logic to break out from the user code
54. @ThreadInterrupt
@ThreadInterrupt
import
groovy.transform.ThreadInterrupt
while
(true)
{
//
eat
lots
of
CPU
}
55. @ThreadInterrupt
@ThreadInterrupt
import
groovy.transform.ThreadInterrupt
while
(true)
{
{
if
(Thread.currentThread().isInterrupted())
throw
new
InterruptedException()
//
eat
lots
of
CPU
}
56. @ToString
• Provides a default
toString() method import
groovy.transform.ToString
to your types @ToString
• Available options class
Person
{
• includeNames,
String
name
int
age
includeFields, }
includeSuper,
excludes println
new
Person(name:
'Pete',
age:
15)
//
=>
Person(Pete,
15)
57. @EqualsAndHashCode
• Provides default import
groovy.transform.EqualsAndHashCode
implementations
@EqualsAndHashCode
for equals() class
Coord
{
and hashCode()
int
x,
y
methods }
def
c1
=
new
Coord(x:
20,
y:
5)
def
c2
=
new
Coord(x:
20,
y:
5)
assert
c1
==
c2
assert
c1.hashCode()
==
c2.hashCode()
58. @TupleConstructor
• Provides a « classical » import
groovy.transform.TupleConstructor
constructor with all
@TupleConstructor
properties class
Person
{
• Several annotation
String
name
parameter options
int
age
}
available
def
m
=
new
Person('Marion',
4)
assert
m.name
==
'Marion'
assert
m.age
==
4
59. @InheritConstructors
• Classes like Exception are painful when extended,
as all the base constructors should be replicated
class
CustomException
extends
Exception
{
CustomException()
{
super()
}
CustomException(String
msg)
{
super(msg)
}
CustomException(String
msg,
Throwable
t)
{
super(msg,
t)
}
CustomException(Throwable
t)
{
super(t)
}
}
60. @InheritConstructors
• Classes like Exception are painful when extended,
as all the base constructors should be replicated
import
groovy.transform.*
@InheritConstructors
class
CustomException
extends
Exception
{
CustomException()
{
super()
}
CustomException(String
msg)
{
super(msg)
}
CustomException(String
msg,
Throwable
t)
{
super(msg,
t)
}
CustomException(Throwable
t)
{
super(t)
}
}
61. Compilation customizers
• Ability to apply some customization to the Groovy compilation
process
• Three available customizers
• ImportCustomizer
• ASTTransformationCustomizer
• SecureASTCustomizer
• But you can implement your own
62. Imports customizer
def
configuration
=
new
CompilerConfiguration()
def
custo
=
new
ImportCustomizer()
custo.addStaticStar(Math.name)
configuration.addCompilationCustomizers(custo)
def
result
=
new
GroovyShell(configuration)
//
import
static
java.lang.Math.*
.evaluate("
cos
PI/3
")
63. Miscellaneous
• Compilation customizers
• Java 7 diamond operator
• Slashy and dollar slashy strings
• New GDK methods
• (G)String to Enum coercion
• Customizing the Groovysh prompt
• Executing remote scripts
64. Groovy 2.0 bird’s eye view
A more Java 7 Static Type
Project Coin Checking
modular
Invoke Static
Groovy Dynamic Compilation
66. 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, etc.
67. 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
68. 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
75. Binary literals
• We had decimal, octal and hexadecimal
notations for number literals
• We can now use binary
int
x
=
0b10101111
representations too assert
x
==
175
byte
aByte
=
0b00100001
assert
aByte
==
33
int
anInt
=
0b1010000101000101
assert
anInt
==
41285
76. 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
77. Multicatch
• One block for multiple exception caught
• rather than duplicating the block
try
{
/*
...
*/
}
catch(IOException
|
NullPointerException
e)
{
/*
one
block
to
treat
2
exceptions
*/
}
78. 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
79. Groovy 2.0 bird’s eye view
A more Java 7 Static Type
Project Coin Checking
modular
Invoke Static
Groovy Dynamic Compilation
81. 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
82. 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
}
83. Typos in a variable or method
import
groovy.transform.TypeChecked
void
method()
{}
@TypeChecked
test()
{
//
Cannot
find
matching
method
metthhoood()
metthhoood()
def
name
=
"Guillaume"
Compilation
//
variable
naamme
is
undeclared
errors!
println
naamme
}
84. Typos in a variable or method
Annotation can be at import
groovy.transform.TypeChecked
class or method level
void
method()
{}
@TypeChecked
test()
{
//
Cannot
find
matching
method
metthhoood()
metthhoood()
def
name
=
"Guillaume"
Compilation
//
variable
naamme
is
undeclared
errors!
println
naamme
}
85. 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'
86. 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'
87. 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
}
88. Wrong return types
//
checks
if/else
branch
return
values
@TypeChecked
int
method()
{ Compilation
if
(true)
{
'String'
}
else
{
42
} error!
}
//
works
for
switch/case
&
try/catch/finally
//
transparent
toString()
implied
@TypeChecked
String
greeting(String
name)
{
def
sb
=
new
StringBuilder()
sb
<<
"Hi
"
<<
name
}
89. 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
}
}
90. 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()
}
91. Instanceof checks
@TypeChecked
void
test(Object
val)
{
if
(val
instanceof
String)
{
println
val.toUpperCase()
}
else
if
(val
instanceof
Number)
{
println
"X"
*
val.intValue()
}
}
92. Instanceof checks
@TypeChecked
void
test(Object
val)
{
if
(val
instanceof
String)
{ No need
println
val.toUpperCase() for casts
}
else
if
(val
instanceof
Number)
{
println
"X"
*
val.intValue()
}
}
93. Instanceof checks
@TypeChecked
void
test(Object
val)
{
if
(val
instanceof
String)
{ No need
println
val.toUpperCase() for casts
}
else
if
(val
instanceof
Number)
{
println
"X"
*
val.intValue()
}
}
Can call String#multiply(int)
from the Groovy Development Kit
94. 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]
}
95. 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>
96. 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>
97. 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!
}
98. 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)
• However, compile-time metaprogramming works
• as long as proper type information is defined
100. Gotcha: runtime metaprogramming
@TypeChecked
void
test()
{
Integer.metaClass.foo
=
{}
123.foo()
}
Not allowed:
metaClass property
is dynamic
101. Gotcha: runtime metaprogramming
@TypeChecked
void
test()
{
Integer.metaClass.foo
=
{}
123.foo()
}
Method not Not allowed:
recognized metaClass property
is dynamic
102. Gotcha: explicit type for closures
@TypeChecked
test()
{
["a",
"b",
"c"].collect
{
it.toUpperCase()
//
Not
OK
}
}
103. Gotcha: explicit type for closures
@TypeChecked
test()
{
["a",
"b",
"c"].collect
{
String
it
-‐>
it.toUpperCase()
//
OK,
it’s
a
String
}
}
104. Closure shared variables
@TypeChecked
test()
{
def
var
=
"abc"
def
cl
=
{
var
=
new
Date()
}
if
(random)
cl()
var.toUpperCase()
//
Not
OK!
}
105. 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!
}
106. Closure shared variables
var assigned in the closure:
« shared closure variable »
Impossible to @TypeChecked
test()
{
def
var
=
"abc"
ensure the
def
cl
=
{
var
=
new
Date()
}
assignment
if
(random)
cl()
really happens
var.toUpperCase()
//
Not
OK!
}
107. Closure shared variables
var assigned in the closure:
« shared closure variable »
Impossible to @TypeChecked
test()
{
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
108. Closure shared variables
class
A
{
void
foo()
{}
}
class
B
extends
A
{
void
bar()
{}
}
@TypeChecked
test()
{
def
var
=
new
A()
def
cl
=
{
var
=
new
B()
}
cl()
var.foo()
//
OK!
}
109. Closure shared variables
class
A
{
void
foo()
{}
}
class
B
extends
A
{
void
bar()
{}
}
@TypeChecked
test()
{
def
var
=
new
A()
def
cl
=
{
var
=
new
B()
}
cl()
var.foo()
//
OK!
}
var is at least an instance of A
110. 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
111. 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
112. Static Compilation: disadvantages
• But you loose:
• Dynamic features
•metaclass changes, categories, etc.
• Dynamic method dispatch
•although as close as possible to « dynamic » Groovy
113. 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()
}
114. 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)
115. What about performance?
Pi (π) Binary
Fibonacci
quadrature trees
Java 191 ms 97 ms 3.6 s
Static
1.7 1.8 2.0
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
117. Thank you!
ge
e Lafor lopment
Gu illaum ovy Deve
Gro
H ead of
om
ge@ gmail.c
: glafor forge
Email @gla orge
: .to/glaf om
Twitter : http://gplus spot.c
+ pp
Google p://glaforge.a
tt
Blog: h
119. Roadmap
• Groovy 2.1 — end of year • Groovy 3.0 — 2013
• @DelegatesTo annotation, for • new Meta-Object Protocol
better tooling & type checking
• Java 8 lambda support
• complete the invoke dynamic
support
• custom type checking for your
• Groovy 4.0 — 2014
Domain-Specific Languages
• meta-annotations for • moving to Antlr 4
combining AST • rewrite of the grammar
transformations