Debate :Project Lombok / Project Coin                                          By Romain MATON                            ...
Project Lombok                       !!!                 M O            DE                             2
Project Lombok      Adding Java new features      Smaller code      Easier to read, no more POJO verbosity      Always...
Not Project Lombok             Netbeans             IntelliJ IDEA             Incubation but coming                    ...
Project Coin       7 proposals over 70 ! (forms mailing list)       Automatic Resource Management (Joshua Bloch)        ...
Project Coin       Improved type inference for generic instance creation        (Jeremy Manson)              Map<String, ...
Not Project Coin       Improved Exception Handling for Java (Neal Gafter)             try { doWork(file); }             c...
Survey      Lombok :          I want to use it right now !          Suspicious tool… but why not.          Never !    ...
Questions      Should we really rely on our IDE to generate this kind       of code ?      Should we really have to see ...
Questions      Lombok scope : @Data and that’s all ? What about       @Delegate, multiline String…      Poject Coin : 5 ...
Upcoming SlideShare
Loading in …5
×

XKE - Lombok

1,228 views

Published on

Presentation of Lombok with a debate (good/bad ideas ? feelings ?).
Given at Xebia during XKE (February 4th, 2010).

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,228
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

XKE - Lombok

  1. 1. Debate :Project Lombok / Project Coin By Romain MATON February 4th, 2010 www.xebia.fr / blog.xebia.fr
  2. 2. Project Lombok !!! M O DE 2
  3. 3. Project Lombok  Adding Java new features  Smaller code  Easier to read, no more POJO verbosity  Always up to date  And more to come (@Builder, @Delegate…)  Run with :  eclipse,  javac, maven, ant with lombok.jar in the classpath,  GWT, javadoc…  Use delombok to revert your project 3
  4. 4. Not Project Lombok  Netbeans  IntelliJ IDEA  Incubation but coming 4
  5. 5. Project Coin  7 proposals over 70 ! (forms mailing list)  Automatic Resource Management (Joshua Bloch) try ( FileOutputStream fos = new FileOutputStream(file); InputStream is = url.openStream() ) { byte[] buf = new byte[2048]; int len; while ((len = is.read(buf)) > 0) { fos.write(buf, 0, len); } }  Better Integer literals (Derek Foster) double amount = 1_000_000_000.00; // 1 milliard int color = 0xff_ff_ff; // white int binary = 0b11_1110_1000  Collection literals (Joshua Bloch) final List<Integer> piDigits = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]; final Map<Integer, String> platonicSolids = { 4 : "tetrahedron", 6 : "cube", 8 : "octahedron", 12 : "dodecahedron", 20 : "icosahedron“}; 5
  6. 6. Project Coin  Improved type inference for generic instance creation (Jeremy Manson) Map<String, List<String>> anagrams = new HashMap<>(); • String in switch (Joseph D. Darcy) String s = ... switch(s) {case "foo": processFoo(s); break;} • Simplified vargars method invocation (Bob Lee) static List<Callable<String>> stringFactories() { Callable<String> a, b, c; ... return asList(a, b, c); }  Support of JSR-292 including invokeDynamic (John Rose) JLabel label = new JLabel("Demo"); MethodHandle handle = MethodHandles.lookup().findVirtual(JLabel.class, "setText", MethodType.make(void.class, String.class)); // type de retour + paramètres handle.invoke(label, "Hello"); // equivalent de label.setText("Hello"); handle = handle.insertArgument(handle, 0, label); handle.invoke("Hello"); // equivalent de label.setText("Hello"); 6
  7. 7. Not Project Coin  Improved Exception Handling for Java (Neal Gafter) try { doWork(file); } catch (final IOException | SQLException ex) { logger.log(ex);throw ex; }  Elvis and null-safe operator (Neal Gafter then Stephen Colebourne) String name = null; if (group != null && group.members != null && group.members[0].name != null) { name = group.members[0].name; } else { name = "nobody"; } String name = group?.members?[0]?.name ?: "nobody";  Large arrays (J. Lowden) long [] fib = new long [3000000000L]; fib [0] = 1; fib [1] = 1; long length = fib.size (); for (long i = 2; i < length; i++) fib [i] = fib [i - 1] + fib [i - 2]; 7
  8. 8. Survey  Lombok :  I want to use it right now !  Suspicious tool… but why not.  Never !  Coin :  JDK 7 ! JDK 7 ! JDK 7 !  Pretty good but not a revolution  Waiting 2 or 3 years to have “that”… 8
  9. 9. Questions  Should we really rely on our IDE to generate this kind of code ?  Should we really have to see all these methods clutter our code ?  Should we really need to lose time and focus to manually verify that our hashcode, equals, toString methods are sync ?  @SneakyThrows ? @Synchronized ?  Great coin features… but remember me, when will we enjoy that ?  And my CI, production mode ??? 9
  10. 10. Questions  Lombok scope : @Data and that’s all ? What about @Delegate, multiline String…  Poject Coin : 5 features every 2/3 years ?  Annotations processor : in favor or against ?  Patch/Plugin : good idea ? (javac ok)  Aspects : @RooToString and @RooEquals ok for you but not @ToString and @EqualsAndHashcode  Create fields and automatically call “generate *” : crazy ? And what about public field ?  Other languages have that (Groovy, Scala…) but for Java, is it so advantageous ? 10

×