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 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.
Depuis FreeBSD 8.0, le SSP est activé automatique pour la compilation de l'OS. Cette option de GCC développée au départ par IBM, permet d'ajouter des mécanismes de protection face aux buffer overflows. La présentation sera accompagnée de sources C et d'étude de la mémoire via GDB. La présentation commencera par le fonctionnement du SSP (via 3 aspects), suivi de l'implémentation sous FreeBSD et son Linux pour finir par l'exploitation dans certains cas de figure.
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 ;)
Orchestrated Functional Testing with Puppet-spec and MspectatorRaphaël PINSON
As Infrastructure as Code gets more widely adopted and more heavily automated, the need for tests is on the rise. It has now become a common practice to ship Puppet modules with unit and functional tests. The Puppet-spec and Mspectator projects aim to validate Puppet catalogs and test your fleet on the fly, using the serverspec library.
RubyConf Portugal 2014 - Why ruby must go!Gautam Rege
In this talk, I take the audience through ha whirlwind tour of Golang for Rubyists. I also discuss things like "Programmer Awareness", what can Rubyists learn from Go and how they can co-exist.
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.
Depuis FreeBSD 8.0, le SSP est activé automatique pour la compilation de l'OS. Cette option de GCC développée au départ par IBM, permet d'ajouter des mécanismes de protection face aux buffer overflows. La présentation sera accompagnée de sources C et d'étude de la mémoire via GDB. La présentation commencera par le fonctionnement du SSP (via 3 aspects), suivi de l'implémentation sous FreeBSD et son Linux pour finir par l'exploitation dans certains cas de figure.
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 ;)
Orchestrated Functional Testing with Puppet-spec and MspectatorRaphaël PINSON
As Infrastructure as Code gets more widely adopted and more heavily automated, the need for tests is on the rise. It has now become a common practice to ship Puppet modules with unit and functional tests. The Puppet-spec and Mspectator projects aim to validate Puppet catalogs and test your fleet on the fly, using the serverspec library.
RubyConf Portugal 2014 - Why ruby must go!Gautam Rege
In this talk, I take the audience through ha whirlwind tour of Golang for Rubyists. I also discuss things like "Programmer Awareness", what can Rubyists learn from Go and how they can co-exist.
Дмитрий Щадей "Что помогает нам писать качественный JavaScript-код?"Yandex
Почему в Яндексе легче сказать, чем написать плохой код? Рассказ о том, как мы в больших проектах сохраняем высокий уровень владения кодом без домашних заданий по чтению чужих файлов, и о том, какие сторонние инструменты мы для этого используем. Возможно, наш опыт поможет и вам.
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...Innovecs
On Saturday, 12 of April, regular quarterly meeting of Tech Hangout Community took place in Creative Space 12, the cultural and educational center based in Kiev! The event was held under the motto «One day of inspiring talks on Web Back-End». This time Python, Ruby and PHP developers gathered to make peace and learn the Force.
*TECH HANGOUT COMMUNITY was found in 2012 by the developers for the developers for knowledge and experience sharing. Such meetings are the part of Innovecs Educational Project that actively develops sphere of internal trainings and knowledge exchange program among professionals. This Initiative was born within the walls of Innovecs and has proved to be extremely popular and high-demand. In a short period of time it gained its own Facebook group with more than 90 members, blog with more than 40 posts and constant quarterly external meeting of Tech hangout community with more than 80 participants. The concept of the event proposes a 30-minute report on the topic previously defined, and the discussion in a roundtable session format.
Join to discuss - https://www.facebook.com/groups/techhangout/
You believe in the power of JavaScript modules, but you have an existing app, stack or platform infrastructure to keep running. Between maintenance and new features, where do you carve out time to switch over? After a brief overview of modules and why they're great, we'll dig into how to actually migrate a code base, from plotting your approach to implementation tips.
Video: http://youtu.be/FbdcdC8mqwE?t=50m51s (watch the entire video from the beginning for other great talks about shadow DOM and competing task runners)
Talk from February 19, 2014 NYCHTML5 Meetup: http://www.meetup.com/nychtml5/events/160684962/
Learn how to write better code. Follow key software development principles like KISS, DRY, YAGNI, and SOLID. Know how to choose better names, structure your code, write methods, and design classes.
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQTanya Denisyuk
In this talk I am going to show how to build a system that can ingest data produced at separate geo located areas (think AWS and it’s many regions) and replicate it to a central cluster where it can be further processed and analysed. I will present an example of how to build a system like this one by using RabbitMQ Federation to replicate data across AWS Regions and RabbitMQ support for many protocols to produce/consume data.
To help with scalability I am going to show an interesting way to implement sharded queues with RabbitMQ by using the Consistent Hash Exchange.
Puppet Camp Duesseldorf 2014: Martin Alfke - Can you upgrade to puppet 4.x?NETWAYS
PuppetLabs takes care on the Puppet software stack and they provide regular updates of their software.
But how about your Puppet DSL code? How can you ensure that your code will also work fine on newer Puppet versions?
This talks shows basic steps and actions which should be done to ensure fully functional Puppet DSL code on newer Puppet versions.
I will show common old practices, which have been replaced by more modern ways in using Puppet and how to migrate to the new solution. Additionally I want you to learn how you can test your Puppet DSL code prior putting it onto a new Puppet master.
Similar to Groovy 1.8 and 2.0 at GR8Conf Europe 2012 (20)
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
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.
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.
UiPath Test Automation using UiPath Test Suite series, part 5DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 5. In this session, we will cover CI/CD with devops.
Topics covered:
CI/CD with in UiPath
End-to-end overview of CI/CD pipeline with Azure devops
Speaker:
Lyndsey Byblow, Test Suite Sales Engineer @ UiPath, Inc.
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
GridMate - End to end testing is a critical piece to ensure quality and avoid...ThomasParaiso2
End to end testing is a critical piece to ensure quality and avoid regressions. In this session, we share our journey building an E2E testing pipeline for GridMate components (LWC and Aura) using Cypress, JSForce, FakerJS…
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
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.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
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
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
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.
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.
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.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
3. Guillaume Laforge
• Groovy Project Manager at VMware
•Initiator of the Grails framework
•Creator of the Gaelyk
and Caelyf toolkits
• Co-author of Groovy in Action
• Follow me on...
•My blog: http://glaforge.appspot.com
•Twitter: @glaforge
•Google+: http://gplus.to/glaforge
2
4. Agenda (1/2)
• What’s new 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
3
5. Agenda (2/2)
• What’s cooking for 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
4
6. 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)
5
30. 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!
9
31. 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
10
54. @Log
• Four different loggers can be injected
•@Log
•@Commons import!groovy.util.logging.*!
•@Log4j !
@Log
•@Slf4j class!Car!{!!!!
!!!!Car()!{!!!!!!!!
!!!!!!!!log.info!'Car!constructed'!
!
• Possible to implement !!!!}
}!
your own strategy !
def!c!=!new!Car()
18
55. @Log
• Four different loggers can be injected
•@Log
•@Commons import!groovy.util.logging.*!
•@Log4j !
@Log
•@Slf4j
Guarded
w/ an if
class!Car!{!!!!
!!!!Car()!{!!!!!!!!
!!!!!!!!log.info!'Car!constructed'!
!
• Possible to implement !!!!}
}!
your own strategy !
def!c!=!new!Car()
18
56. 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
19
61. @TupleConstructor
• Provides a «classical» constructor with all properties
• Several annotation parameter options available
import!groovy.transform.TupleConstructor!
!
@TupleConstructor!
class!Person!{!!!!
!!!!String!name!!!!
!!!!int!age
}!
!
def!m!=!new!Person('Marion',!4)!!!!!!
!
assert!m.name!==!'Marion'
assert!m.age!!==!4
23
62. @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)!!!!!!}
}
24
63. @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)!!!!!!}
}
24
64. Miscelanous
• 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
25
65. Compilation customizers
• Ability to apply some customization to the Groovy
compilation process
• Three available customizers
•ImportCustomizer
•ASTTransformationCustomizer
•SecureASTCustomizer
• But you can implement your own
26
69. Groovy 2.0
• A more modular Groovy
• Java 7 alignements: Project Coin
• binary literals
• underscore in literals
• multicatch
• JDK 7: InvokeDynamic
• Static type checking
• Static compilation
30
70. 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.
31
71. The new JARs
• A smaller groovy.jar: 3MB
• Modules
•console • sql
•docgenerator • swing
•groovydoc • servlet
•groovysh • templates
•ant • test
•bsf • testng
•jsr-223 • json
•jmx • xml
32
72. Extension modules
• Create your own module
•contribute instance extension methods
package!foo
class!StringExtension!{
!!!!static.introduce(String!self,!String!name)!{
!!!!!!!!"Hi!${name),!I’m!${self}"
!!!!}
}
//!usage:!"Guillaume".introduce("Cédric")
33
73. Extension modules
• Create your own module
•contribute instance extension methods Same structure
as Categories
package!foo
class!StringExtension!{
!!!!static.introduce(String!self,!String!name)!{
!!!!!!!!"Hi!${name),!I’m!${self}"
!!!!}
}
//!usage:!"Guillaume".introduce("Cédric")
33
74. Extension modules
• Create your own module
•contribute class extension methods
package!foo
class!StaticStringExtension!{
!!!!static.hi(String!self)!{
!!!!!!!!"Hi!"
!!!!}
}
//!usage:!String.hi()
34
77. 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
37
78. 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
38
79. Multicatch
• One block for multiple exception caught
•rather than duplicating the block
try!{
!!!!/*!...!*/
}!catch(IOException!|!NullPointerException!e)!{
!!!!/*!one!block!to!treat!2!exceptions!*/
}
39
80. 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
40
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
• etc...
41
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
}
42
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
}
42
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
}
42
92. Instanceof checks
No need
@TypeChecked!
for casts
void.test(Object!val)!{
!!!!if!(val!instanceof.String)!{
!!!!!!!!println!val.toUpperCase()
!!!!}!else.if!(val!instanceof.Number)!{
!!!!!!!!println!"X"!*!val.intValue()
!!!!}
}
47
93. Instanceof checks
No need
@TypeChecked!
for casts
void.test(Object!val)!{
!!!!if!(val!instanceof.String)!{
!!!!!!!!println!val.toUpperCase()
!!!!}!else.if!(val!instanceof.Number)!{
!!!!!!!!println!"X"!*!val.intValue()
!!!!}
}
Can call String#multiply(int)
from the Groovy Development Kit
47
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]
}
48
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>
48
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>
48
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!
}
49
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
50
100. Gotcha: runtime metaprogramming
@TypeChecked!
void.test()!{
!!!!Integer.metaClass.foo!=!{}
!!!!123.foo()
}
Not allowed:
metaClass property
is dynamic
51
101. Gotcha: runtime metaprogramming
@TypeChecked!
void.test()!{
!!!!Integer.metaClass.foo!=!{}
!!!!123.foo()
}
Method not Not allowed:
recognized metaClass property
is dynamic
51
102. Gotcha: explicit type for closures
@TypeChecked!test()!{
!!!!["a",!"b",!"c"].collect!{
!!!!!!!!it.toUpperCase()!//!Not!OK
!!!!}
}
• A « Groovy Enhancement Proposal » to address the issue
52
103. Gotcha: explicit type for closures
@TypeChecked!test()!{
!!!!["a",!"b",!"c"].collect!{!String!it!>>
!!!!!!!!it.toUpperCase()!//!OK,!it’s!a!String
!!!!}
}
• A « Groovy Enhancement Proposal » to address the issue
52
105. Closure shared variables
var assigned in the closure:
«shared closure variable»
@TypeChecked!test()!{
!!!!def!var!=!"abc"!!!!!!!
!!!!def!cl!=!{!var!=!new!Date()!}
!!!!cl()
!!!!var.toUpperCase()!!//!Not!OK!
}
53
106. 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
!!!!cl()
really happens
!!!!var.toUpperCase()!!//!Not!OK!
}
53
107. 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
!!!!cl()
really happens
!!!!var.toUpperCase()!!//!Not!OK!
}
Only methods of the most specific
compatible type (LUB) are
allowed by the type checker
53
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
54
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
55
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
56
112. Static Compilation: disadvantages
• But you loose:
• Dynamic features
•metaclass changes, categories, etc.
• Dynamic method dispatch
•although as close as possible to «dynamic» Groovy
57
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)
59
115. What about performance?
Pi (π) Binary
Fibonacci
quadrature trees
Java 188 ms 97 ms 3.6 s
Static
1.7 1.8 2.0
compilation
202 ms 101 ms 4.4 s
Primitive
optimizations
360 ms 111 ms 23.7 s
No prim.
optimizations
2590 ms 3220 ms 50.0 s
60
116. Summary
• Main themes of the Groovy 2.0 release
•Modularity
• Embark the JDK 7 enhancements
•Project Coin
•Invoke Dynamic
• Static aspects
• Static type checking
• Static compilation
61
118. Thank you!
ge
e Lafor lopment
Gu illaum ovy Deve
Gro
H ead of
om
ge@ gmail.c
Emai l: glafor forge e
:@ gla .to/glaforg
Twitter : http://gplus spot.com
+ pp
Google p://glaforge.a
tt
Blog: h
63