SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
This is not your father’s Java
Sven Efftinge - itemis
5 Missing Features
Collection Literals
Object Literals
Closures
Properties
Multiline Strings
Collection Literals

List<String> names =
      new ArrayList<String>();
names.add(“foo”);
names.add(“bar”);
names.add(“baz”);
Collection Literals

List<String> names =
      new ArrayList<>();
names.add(“foo”);
names.add(“bar”);
names.add(“baz”);
Collection Literals


newArrayList(“foo”, “bar”, “baz”)


    Static imports, generified method
              and var-args!
   Do you already use Google Guava?
Object Literals


Readable data construction
Java Devs usually flee to some external format,
such as XML or JSON.
Object Literals
         Java enforces imperative style.


Person p = new Person();
p.setFirstName("Hans");
p.setLastName("Albers");
Address address = new Address();
address.setStreet("Am Germaniahafen 1");
address.setCity("Kiel");
p.setAddress(address);
Object Literals
Person p = new Person() {{
  firstName = "Hans";
  lastName = "Albers";
  address   = new Address() {{
    street   = "Am Germaniahafen 1";
    city     = "Kiel";
  }};
}};
Object Literals
Person p = new Person() {{
  firstName = "Hans";
  lastName = "Albers";
  address   = new Address() {{
    street   = "Am Germaniahafen 1";
    city     = "Kiel";
  }};
}};

         anonymous classes
Object Literals
Person p = new Person() {{
  firstName = "Hans";
  lastName = "Albers";
  address   = new Address() {{
    street   = "Am Germaniahafen 1";
    city     = "Kiel";
  }};
}};

              Initializer
No Closures
      My friends’ names in a comma
             separated string.
List<Person> myFriends = ...
StringBuilder sb = new StringBuilder();
for (Person person : myFriends) {
  sb.append(person.getName())
    .append(“, “);
}
String result =
  sb.toString().substring(0, sb.length()-2);
How about this?

List<Person> myFriends = ...

String names = joinFrom(myFriends).getName();




           generics and proxies!

LambdaJ - http://code.google.com/p/lambdaj/
Closures in Java 8


List<Person> myFriends = ...
List<String> names = myFriends
 .map(#{ p -> p.getName(); });
Properties

class Person {
  public String firstName;
}
Person p = ....
p.firstName = “Horst”;
Properties
 class Person {
   public String firstName;
   public void setFirstName(String s) {
     firstName = process(s);
   }
 }
 Person p = ....
 p.firstName = “Horst”;

Byte code manipulation during class loading!
Multiline Strings
public static void main(String[] args)
{
  System.out.println($(/*
    Wow, we finally have
    multiline strings in
    Java! HOOO!
  */));
}

  Source code & stack trace information
Beyond Java

Other JVM-Languages
 Eclipse Xtend
DSLs
 Eclipse Xtext 2.

Weitere ähnliche Inhalte

Was ist angesagt?

Lecture 22
Lecture 22Lecture 22
Lecture 22
rhshriva
 
Grails: The search is over
Grails: The search is overGrails: The search is over
Grails: The search is over
Aécio Costa
 

Was ist angesagt? (19)

Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Grails: The search is over
Grails: The search is overGrails: The search is over
Grails: The search is over
 
An Introduction to Tuple List Dictionary in Python
An Introduction to Tuple List Dictionary in PythonAn Introduction to Tuple List Dictionary in Python
An Introduction to Tuple List Dictionary in Python
 
Invertible-syntax 入門
Invertible-syntax 入門Invertible-syntax 入門
Invertible-syntax 入門
 
ElasticSearch 5.x - New Tricks - 2017-02-08 - Elasticsearch Meetup
ElasticSearch 5.x -  New Tricks - 2017-02-08 - Elasticsearch Meetup ElasticSearch 5.x -  New Tricks - 2017-02-08 - Elasticsearch Meetup
ElasticSearch 5.x - New Tricks - 2017-02-08 - Elasticsearch Meetup
 
Working with text, Regular expressions
Working with text, Regular expressionsWorking with text, Regular expressions
Working with text, Regular expressions
 
Haskell
HaskellHaskell
Haskell
 
Grails queries
Grails   queriesGrails   queries
Grails queries
 
Functional programming in java
Functional programming in javaFunctional programming in java
Functional programming in java
 
PHP 7 – What changed internally?
PHP 7 – What changed internally?PHP 7 – What changed internally?
PHP 7 – What changed internally?
 
2017 02-07 - elastic & spark. building a search geo locator
2017 02-07 - elastic & spark. building a search geo locator2017 02-07 - elastic & spark. building a search geo locator
2017 02-07 - elastic & spark. building a search geo locator
 
DBIx::Class introduction - 2010
DBIx::Class introduction - 2010DBIx::Class introduction - 2010
DBIx::Class introduction - 2010
 
Creating Domain Specific Languages in Python
Creating Domain Specific Languages in PythonCreating Domain Specific Languages in Python
Creating Domain Specific Languages in Python
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
 
Java String class
Java String classJava String class
Java String class
 
The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type System
 
Protocol-Oriented Programming in Swift
Protocol-Oriented Programming in SwiftProtocol-Oriented Programming in Swift
Protocol-Oriented Programming in Swift
 
Handout - Introduction to Programming
Handout - Introduction to ProgrammingHandout - Introduction to Programming
Handout - Introduction to Programming
 
DBIx::Class beginners
DBIx::Class beginnersDBIx::Class beginners
DBIx::Class beginners
 

Andere mochten auch

Event driven architecture in practice
Event driven architecture in practiceEvent driven architecture in practice
Event driven architecture in practice
mimmozzo_
 

Andere mochten auch (6)

Doing REST Right
Doing REST RightDoing REST Right
Doing REST Right
 
Drive your dba crazy in 3 easy steps
Drive your dba crazy in 3 easy stepsDrive your dba crazy in 3 easy steps
Drive your dba crazy in 3 easy steps
 
Event driven architecture in practice
Event driven architecture in practiceEvent driven architecture in practice
Event driven architecture in practice
 
Event Driven Architecture
Event Driven ArchitectureEvent Driven Architecture
Event Driven Architecture
 
Event Driven Architecture
Event Driven ArchitectureEvent Driven Architecture
Event Driven Architecture
 
Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA)Event-Driven Architecture (EDA)
Event-Driven Architecture (EDA)
 

Ähnlich wie This Is Not Your Father's Java

2.1 Recap From Day One
2.1 Recap From Day One2.1 Recap From Day One
2.1 Recap From Day One
retronym
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
Seri Moth
 
Opa presentation at GamesJs
Opa presentation at GamesJsOpa presentation at GamesJs
Opa presentation at GamesJs
Henri Binsztok
 

Ähnlich wie This Is Not Your Father's Java (20)

Scala in a Java 8 World
Scala in a Java 8 WorldScala in a Java 8 World
Scala in a Java 8 World
 
Scala - en bedre Java?
Scala - en bedre Java?Scala - en bedre Java?
Scala - en bedre Java?
 
What's New In C# 7
What's New In C# 7What's New In C# 7
What's New In C# 7
 
Kotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
Kotlin Programming Language. What it is all about. Roman Belov, PMM in KotlinKotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
Kotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
 
C# 6.0
C# 6.0C# 6.0
C# 6.0
 
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developersSoftshake 2013: 10 reasons why java developers are jealous of Scala developers
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
 
Presentatie - Introductie in Groovy
Presentatie - Introductie in GroovyPresentatie - Introductie in Groovy
Presentatie - Introductie in Groovy
 
From android/java to swift (1)
From android/java to swift (1)From android/java to swift (1)
From android/java to swift (1)
 
Type script by Howard
Type script by HowardType script by Howard
Type script by Howard
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
 
Howard type script
Howard   type scriptHoward   type script
Howard type script
 
2.1 Recap From Day One
2.1 Recap From Day One2.1 Recap From Day One
2.1 Recap From Day One
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
 
Grails - The search is over
Grails - The search is overGrails - The search is over
Grails - The search is over
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Opa presentation at GamesJs
Opa presentation at GamesJsOpa presentation at GamesJs
Opa presentation at GamesJs
 
Linq And Its Impact On The.Net Framework
Linq And Its Impact On The.Net FrameworkLinq And Its Impact On The.Net Framework
Linq And Its Impact On The.Net Framework
 

Mehr von Sven Efftinge

Xtext at MDD Day 2010
Xtext at MDD Day 2010Xtext at MDD Day 2010
Xtext at MDD Day 2010
Sven Efftinge
 
Dependency Injection for Eclipse developers
Dependency Injection for Eclipse developersDependency Injection for Eclipse developers
Dependency Injection for Eclipse developers
Sven Efftinge
 
Challenges In Dsl Design
Challenges In Dsl DesignChallenges In Dsl Design
Challenges In Dsl Design
Sven Efftinge
 

Mehr von Sven Efftinge (20)

Parsing Expression With Xtext
Parsing Expression With XtextParsing Expression With Xtext
Parsing Expression With Xtext
 
Language Engineering With Xtext
Language Engineering With XtextLanguage Engineering With Xtext
Language Engineering With Xtext
 
Future of Xtext
Future of XtextFuture of Xtext
Future of Xtext
 
Auto-GWT : Better GWT Programming with Xtend
Auto-GWT : Better GWT Programming with XtendAuto-GWT : Better GWT Programming with Xtend
Auto-GWT : Better GWT Programming with Xtend
 
Functional programming with Xtend
Functional programming with XtendFunctional programming with Xtend
Functional programming with Xtend
 
Codegeneration With Xtend
Codegeneration With XtendCodegeneration With Xtend
Codegeneration With Xtend
 
Gwt and Xtend
Gwt and XtendGwt and Xtend
Gwt and Xtend
 
Domain Specific Languages (EclipseCon 2012)
Domain Specific Languages (EclipseCon 2012)Domain Specific Languages (EclipseCon 2012)
Domain Specific Languages (EclipseCon 2012)
 
Xtend @ EclipseCon 2012
Xtend @ EclipseCon 2012Xtend @ EclipseCon 2012
Xtend @ EclipseCon 2012
 
Eclipse Xtend
Eclipse XtendEclipse Xtend
Eclipse Xtend
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]
 
Xtext at MDD Day 2010
Xtext at MDD Day 2010Xtext at MDD Day 2010
Xtext at MDD Day 2010
 
Dependency Injection for Eclipse developers
Dependency Injection for Eclipse developersDependency Injection for Eclipse developers
Dependency Injection for Eclipse developers
 
Xtext Webinar
Xtext WebinarXtext Webinar
Xtext Webinar
 
Challenges In Dsl Design
Challenges In Dsl DesignChallenges In Dsl Design
Challenges In Dsl Design
 
Code Generation in Agile Projects
Code Generation in Agile ProjectsCode Generation in Agile Projects
Code Generation in Agile Projects
 
Xtext Eclipse Con
Xtext Eclipse ConXtext Eclipse Con
Xtext Eclipse Con
 
Generic Editor
Generic EditorGeneric Editor
Generic Editor
 
Eclipse Banking Day
Eclipse Banking DayEclipse Banking Day
Eclipse Banking Day
 
Bessere Softwareentwicklung (Itemis Wintercon)
Bessere Softwareentwicklung (Itemis Wintercon)Bessere Softwareentwicklung (Itemis Wintercon)
Bessere Softwareentwicklung (Itemis Wintercon)
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 

This Is Not Your Father's Java

  • 1. This is not your father’s Java Sven Efftinge - itemis
  • 2. 5 Missing Features Collection Literals Object Literals Closures Properties Multiline Strings
  • 3. Collection Literals List<String> names = new ArrayList<String>(); names.add(“foo”); names.add(“bar”); names.add(“baz”);
  • 4. Collection Literals List<String> names = new ArrayList<>(); names.add(“foo”); names.add(“bar”); names.add(“baz”);
  • 5. Collection Literals newArrayList(“foo”, “bar”, “baz”) Static imports, generified method and var-args! Do you already use Google Guava?
  • 6. Object Literals Readable data construction Java Devs usually flee to some external format, such as XML or JSON.
  • 7. Object Literals Java enforces imperative style. Person p = new Person(); p.setFirstName("Hans"); p.setLastName("Albers"); Address address = new Address(); address.setStreet("Am Germaniahafen 1"); address.setCity("Kiel"); p.setAddress(address);
  • 8. Object Literals Person p = new Person() {{ firstName = "Hans"; lastName = "Albers"; address = new Address() {{ street = "Am Germaniahafen 1"; city = "Kiel"; }}; }};
  • 9. Object Literals Person p = new Person() {{ firstName = "Hans"; lastName = "Albers"; address = new Address() {{ street = "Am Germaniahafen 1"; city = "Kiel"; }}; }}; anonymous classes
  • 10. Object Literals Person p = new Person() {{ firstName = "Hans"; lastName = "Albers"; address = new Address() {{ street = "Am Germaniahafen 1"; city = "Kiel"; }}; }}; Initializer
  • 11. No Closures My friends’ names in a comma separated string. List<Person> myFriends = ... StringBuilder sb = new StringBuilder(); for (Person person : myFriends) { sb.append(person.getName()) .append(“, “); } String result = sb.toString().substring(0, sb.length()-2);
  • 12. How about this? List<Person> myFriends = ... String names = joinFrom(myFriends).getName(); generics and proxies! LambdaJ - http://code.google.com/p/lambdaj/
  • 13. Closures in Java 8 List<Person> myFriends = ... List<String> names = myFriends .map(#{ p -> p.getName(); });
  • 14. Properties class Person { public String firstName; } Person p = .... p.firstName = “Horst”;
  • 15. Properties class Person { public String firstName; public void setFirstName(String s) { firstName = process(s); } } Person p = .... p.firstName = “Horst”; Byte code manipulation during class loading!
  • 16. Multiline Strings public static void main(String[] args) { System.out.println($(/* Wow, we finally have multiline strings in Java! HOOO! */)); } Source code & stack trace information
  • 17. Beyond Java Other JVM-Languages Eclipse Xtend DSLs Eclipse Xtext 2.