Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Groovy como você nunca viu

Groovy como você nunca viu

The Developers Conference - São Paulo 2016

Talk: Groovy como você nunca viu

A Java Virtual Machine tem 21 anos de história e desde sua criação diversas linguagens de programação foram criadas neste ecossistema. Uma linguagem em destaque é o Groovy, uma linguagem dinâmica opcionalmente tipada com features extremamente poderosas como static-typing and static compilation. Nesta talk mostrarei diversos cenários onde a estratégia de usar Groovy + Java proporciona ao desenvolvedor flexibilidade, eficiência e poder quase infinito para desenvolvimento de um software para a JVM.

The Java Virtual Machine has 21 years of history and since its inception several programming languages have been created in this ecosystem. A featured language is Groovy, a dynamic language optionally typed with extremely powerful features such as static-typing and static compilation. In this talk show various scenarios where the strategy of using Groovy + Java provides developers the flexibility, efficiency and power almost infinite to develop a software for the JVM.

Exemplo / Example:
https://gist.github.com/fmamud/1cb9eab4fc4ffb102c419867e630a0b9

Felipe Mamud

July 09, 2016
Tweet

More Decks by Felipe Mamud

Other Decks in Programming

Transcript

  1. It's Groovy • Groovy is object-oriented dynamic language by default,

    but… … can be optionally typed; … can be static type checking with @TypeChecked; • dynamic != interpreted; • static compilation with @CompileStatic; • Groovy compiles down to JVM bytecode; • Script vs Classes;
  2. Compilation phases 1. Initialization (read source files and config compiler)

    2. Parsing (text → concrete syntax tree; Antlr2) 3. Conversion (CST → AST) @Grab 4. Semantic Analysis (resolve classes, consistency and grammar) @Lazy @Builder @Field @Log 5. Canonicalization (AST finalize and last chance to use AST) @Delegate @ToString @Immutable 6. Instruction Selection (instruction set for bytecode / type checking) @CompileStatic @TypeChecked 7. Class Generation (create bytecode in memory, AST → bytecode) 8. Output (binary output .class to file system) 9. Finalization (perform cleanup tasks, unused today!)
  3. Awesome! • Optional (Typing, Semicolons, Parentheses, public & return keyword);

    • Native syntax constructs (Closures, Lists, Maps, Regex, Ranges) • Boilerplate mode off; (String, BigDecimal, Null, Truth, Switch) • Java Interoperability & integration; • Groovy Development Kit enhancements (GDK); • DSL easy mode on; • Builders; • AST Transformations;
  4. Groovy’s nature programming language… as type safe as you want

    it static type checking as fast as you need static compilation as functional as you make it closures, immutable, etc…
  5. References • Groovy documentation http://groovy-lang.org/documentation.html • Guillaume Laforge's Blog http://glaforge.appspot.com

    • Cédric Champeau's Blog http://melix.github.io/blog • Groovy in Action, 2nd Edition https://www.manning.com/books/groovy-in-action-second-edition