groovy - dave-reed.com · apache groovy developed by james strachan talked about wanting to create...

17
Apache Groovy Parker Johnson Brad Koenen

Upload: others

Post on 06-Apr-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Apache GroovyParker Johnson

Brad Koenen

Page 2: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Brief History of Java

❏ One of the most popular languages in use today

❏ At the core of Java is the Java Virtual Machine (JVM)❏ JVM’s exist for almost all popular operating systems

❏ Released in 1995❏ Before the web became a major platform for apps and business

❏ Many other languages have come along to fill the gap

❏ High performance, compiled, statically typed language

Page 3: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Apache Groovy

❏ Developed by James Strachan

❏ Talked about wanting to create a “groovy” new language that runs

on the JVM

❏ Wanted to address the shortcomings of Java

❏ First appeared in 2003

❏ Version 1.0 released in 2007

❏ Open source under Apache license

Page 4: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Apache Groovy

❏ Uses the JVM

❏ Enhancement to Java❏ Modern language syntax

❏ Compiles directly into Java code

❏ Call Java code from Groovy and vice versa

❏ Able to use almost all existing Java libraries❏ Java with less boilerplate and more power

features

Page 5: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

A Closer Look“Powerful, optionally typed and dynamic language, with static-typing and static compilation capabilities” groovy-lang.org

❏ Powerful❏ Seamless access to almost all existing Java libraries❏ Dynamically typed

❏ Majority of type checking is done at run-time❏ Values have types, variables do not

❏ Options❏ Dynamic when you need to crank out code fast❏ Statically compiled for code that is production ready and more long term❏ Static typing also allows for easier debugging

❏ compiler errors vs. runtime errors

Page 6: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Goals

Web Dev

ImproveDevelopment Experience

Optional Typing Seamless

Page 7: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Code Examples

Page 8: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Cleaner CodeFlat learning curve

-Control statements

-Functions

-Inheritance

-Data types

Page 9: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Traditional Java CodeFor loop is more drawn out, initializing “i” variable and continuing on.

Apache Groovy CodeGroovy allows an upto method, provided the size of the loop necessary. “$” is a closure that gives the value of the current loop.

Control Statements

Page 10: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Functions

“It” is a keyword used to represent a single parameter.

Page 11: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Simple Inheritance

Page 12: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Data Types - Bytes to BooleanNo semicolons! SEE CONSOLE

Page 13: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Why not just use Java?Trade-offs

Page 14: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Who uses Groovy?

Netflix

Cisco

Best Buy

MasterCard

LinkedIn

Sony

Oracle

Target

Walmart

Page 15: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Why?

❏ Embedded Business Language (Domain-Specific Language)

❏ Netflix uses Groovy to offer various levels of filtering through Groovy scripts

❏ Mainly used in production code

❏ Existing Java libraries❏ JVM❏ Improved dev experience

Page 16: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Sourceshttp://groovy-lang.org/

https://detechter.com/everything-wanted-know-groovy-language/

https://www.java.com/en/

https://www.udemy.com/apache-groovy/ (Introduction)

https://www.tutorialspoint.com/groovy/

Page 17: Groovy - dave-reed.com · Apache Groovy Developed by James Strachan Talked about wanting to create a “groovy” new language that runs on the JVM Wanted to address the shortcomings

Questions?