Your SlideShare is downloading. ×
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
This Is Not Your Father's Java
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

This Is Not Your Father's Java

1,322

Published on

A presentation about creative API Design and language feature emulation with Java

A presentation about creative API Design and language feature emulation with Java

Published in: Technology, News & Politics
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,322
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
16
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. This is not your father’s JavaSven Efftinge - itemis
  • 2. 5 Missing FeaturesCollection LiteralsObject LiteralsClosuresPropertiesMultiline Strings
  • 3. Collection LiteralsList<String> names = new ArrayList<String>();names.add(“foo”);names.add(“bar”);names.add(“baz”);
  • 4. Collection LiteralsList<String> names = new ArrayList<>();names.add(“foo”);names.add(“bar”);names.add(“baz”);
  • 5. Collection LiteralsnewArrayList(“foo”, “bar”, “baz”) Static imports, generified method and var-args! Do you already use Google Guava?
  • 6. Object LiteralsReadable data constructionJava 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 LiteralsPerson p = new Person() {{ firstName = "Hans"; lastName = "Albers"; address = new Address() {{ street = "Am Germaniahafen 1"; city = "Kiel"; }};}};
  • 9. Object LiteralsPerson p = new Person() {{ firstName = "Hans"; lastName = "Albers"; address = new Address() {{ street = "Am Germaniahafen 1"; city = "Kiel"; }};}}; anonymous classes
  • 10. Object LiteralsPerson 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 8List<Person> myFriends = ...List<String> names = myFriends .map(#{ p -> p.getName(); });
  • 14. Propertiesclass 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 Stringspublic static void main(String[] args){ System.out.println($(/* Wow, we finally have multiline strings in Java! HOOO! */));} Source code & stack trace information
  • 17. Beyond JavaOther JVM-Languages Eclipse XtendDSLs Eclipse Xtext 2.

×