The Dzone Guide to Volume Ii
Total Page:16
File Type:pdf, Size:1020Kb
THE D ZONE GUIDE TO MODERN JAVA VOLUME II BROUGHT TO YOU IN PARTNERSHIP WITH DZONE.COM/GUIDES DZONE’S 2016 GUIDE TO MODERN JAVA Dear Reader, TABLE OF CONTENTS 3 EXECUTIVE SUMMARY Why isn’t Java dead after more than two decades? A few guesses: Java is (still) uniquely portable, readable to 4 KEY RESEARCH FINDINGS fresh eyes, constantly improving its automatic memory management, provides good full-stack support for high- 10 THE JAVA 8 API DESIGN PRINCIPLES load web services, and enjoys a diverse and enthusiastic BY PER MINBORG community, mature toolchain, and vigorous dependency 13 PROJECT JIGSAW IS COMING ecosystem. BY NICOLAI PARLOG Java is growing with us, and we’re growing with Java. Java 18 REACTIVE MICROSERVICES: DRIVING APPLICATION 8 just expanded our programming paradigm horizons (add MODERNIZATION EFFORTS Church and Curry to Kay and Gosling) and we’re still learning BY MARKUS EISELE how to mix functional and object-oriented code. Early next 21 CHECKLIST: 7 HABITS OF SUPER PRODUCTIVE JAVA DEVELOPERS year Java 9 will add a wealth of bigger-picture upgrades. 22 THE ELEMENTS OF MODERN JAVA STYLE But Java remains vibrant for many more reasons than the BY MICHAEL TOFINETTI robustness of the language and the comprehensiveness of the platform. JVM languages keep multiplying (Kotlin went 28 12 FACTORS AND BEYOND IN JAVA GA this year!), Android keeps increasing market share, and BY PIETER HUMPHREY AND MARK HECKLER demand for Java developers (measuring by both new job 31 DIVING DEEPER INTO JAVA DEVELOPMENT posting frequency and average salary) remains high. The key to the modernization of Java is not a laundry-list of JSRs, but 34 INFOGRAPHIC: JAVA'S IMPACT ON THE MODERN WORLD rather the energy of the Java developer community at large. 36 FROM DESKTOP TO WEB JAVA: A PLANNER’S GUIDE TO MIGRATION In fact, the enthusiasm of practicing developers has been BY BEN WILSON Java’s strength since the beginning. The Java platform has 40 HASH TABLES, MUTABILITY, AND IDENTITY: always been backed, but never limited, by a single entity. HOW TO IMPLEMENT A BI-DIRECTIONAL HASH TABLE IN JAVA Sun first made Java for their own enterprise hardware BY WAYNE CITRIN and software ecosystem, but WORA made everyone else want to use it, too. Microsoft failed to fork Java onto a 42 EXECUTIVE INSIGHTS INTO JAVA DEVELOPMENT Windows-flavored JVM because the developer community BY TOM SMITH – spearheaded by Javalobby, DZone in its earliest form – 46 JAVA SOLUTIONS DIRECTORY understood the vital importance of a platform-neutral, industrial-strength, object-oriented language. Google is plenty 55 GLOSSARY gung-ho to create its own languages (Go, Dart) but chose Java for Android – fatefully, since now Java powers far more feature and smart phones than any other language. A few months EDITORIAL BUSINESS PRODUCTION ago Red Hat, IBM, Tomitribe, Payara, and other groups banded CAITLIN CANDELMO RICK ROSS CHRIS SMITH DIRECTOR OF CONTENT + COMMUNITY CEO together to sketch out the beginnings of a specification for DIRECTOR OF PRODUCTION MATT WERNER MATT SCHMIDT ANDRE POWELL microservice support in Java – just the most recent of many CONTENT + COMMUNITY MANAGER PRESIDENT & CTO SENIOR PRODUCTION COORDINATOR platform-driving endeavors of the Java community beyond the MICHAEL THARRINGTON JESSE DAVIS CONTENT + COMMUNITY MANAGER G. RYAN SPAIN formal JCP. EVP & COO PRODUCTION PUBLICATIONS EDITOR NICOLE WOLFE CONTENT COORDINATOR KELLET ATKINSON One of the more convenient effects of Java’s strong DIRECTOR OF MARKETING commitment to backwards compatibility is that we don’t MIKE GATES ART CONTENT COORDINATOR MATT O’BRIAN ASHLEY SLATE have to change when the language and/or platform do. But [email protected] DESIGN DIRECTOR SARAH DAVIS DIRECTOR OF BUSINESS DEVELOPMENT those changes aren’t determined by corporate or academic CONTENT COORDINATOR ALEX CRAFTS experiment. A broad-based community means that the Java SPECIAL THANKS to our INDUSTRY + VENDOR DIRECTOR OF MAJOR ACCOUNTS topic experts, Zone Leaders, ecosystem evolves in response to developers’ changing real- RELATIONS JIM HOWARD trusted DZone Most Valuable world needs. We’re steering this ship; let’s ride it as fast and SR ACCOUNT EXECUTIVE JOHN ESPOSITO Bloggers, and dedicated users as far as it can take us. SENIOR RESEARCH ANALYST CHRIS BRUMFIELD for all their help and feedback in TOM SMITH ACCOUNT MANAGER making this report a great success. So here at DZone we’re thrilled to publish our 2016 Guide to RESEARCH ANALYST Modern Java. No other language has benefited the world as much as Java, and we’re proud to be a part of that ecosystem. We know you are too, and we hope you’ll be able to do even WANT YOUR SOLUTION TO BE FEATURED IN COMING GUIDES? Please contact [email protected] for submission information. more with Java after reading this Guide. LIKE TO CONTRIBUTE CONTENT TO COMING GUIDES? BY JOHN ESPOSITO Please contact [email protected] for consideration. SENIOR RESEARCH ANALYST, DZONE INTERESTED IN BECOMING A DZONE RESEARCH PARTNER? [email protected] Please contact [email protected] for information. 2 DZONE’S GUIDE TO MODERN JAVA DZONE.COM/GUIDES DZONE’S 2016 GUIDE TO MODERN JAVA of view, dive deeper into the lambda calculus. Celebrate your Executive shrinking chances of cursing the existence of Null. MICROSERVICES ADOPTION IS GROWING STEADILY DATA In August 2015, 10% of developers were using microservices; in January 2016, 24% were using microservices somewhere in their organization; in a report just published Summary by Lightbend, 30% are using microservices in production; and, in our latest survey, 39% of developers are currently The most successful programming language in history using microservices, and another 19% are planning to adopt microservices in the next 12 months. owes much of its continuing vitality to the most effective development community in history. More than IMPLICATIONS No matter how old the concept, and no matter any other widely used programming language, Java how much you appreciate the headaches of locating complexity learns from and responds to millions of developers’ in the entire component graph rather than individual nodes, developers are already architecting their applications as needs; and the most important perspective on how microservices at significant rates and will doing so even more in Java is working well, and what Java needs to do better, the near future. comes from experienced software engineers spending hours every day in their Java weeds. Is Java doing its RECOMMENDATIONS Consider how you might refactor your job? We surveyed 2977 developers to find out. And we "monolithic" applications into microservices, even if you decide to retain your "monolith" in production. Become more familiar went deeper, seeking to discover exactly how developers with distributed computing principles. Practice domain-driven are using Java to solve today’s business problems, on design. Read Markus Eisele’s article on page 16 below. modern deployment topologies, using modern release practices, in shortening release cycles, with increasingly NON-JAVA JVM LANGUAGES ARE PROLIFERATING modularized application architectures, meeting AND ENJOYING MORE USE, ESPECIALLY SCALA increasingly stringent performance requirements. DATA 45% of developers are using Groovy, up from 39% in 2015. Here’s what we learned. 41% are using Scala in development (18%), in production (10%), and/or just for fun (26%), up from 31% in 2015. Clojure use has JAVA 8 IS NOW DOMINANT doubled over the past year, and Kotlin is now used in significant DATA 84% of developers are now using Java 8, showing steady numbers, although still mostly just for fun. growth from October 2014 (27%) through May 2015 (38%), August 2015 (58%), and March 2016 (64%). IMPLICATIONS The JVM continues to gain momentum even among non-Java developers. JVM developers are increasingly IMPLICATIONS Java 8 is the new normal. You are increasingly playing with programming models beyond object-orientation. (and now extremely) likely to encounter Java 8 code in others’ For all the valuable readability introduced by Java’s verbosity, the applications (especially applications created in the past year), syntactic sugar offered by Kotlin and Groovy, for example, is not and you will be increasingly expected to be able to write code in to be dismissed lightly. idioms influenced by Java 8. RECOMMENDATIONS Play with other JVM languages: Groovy RECOMMENDATIONS Take advantage of features new to Java 8 for high-productivity scripting, Scala for type-safe and multi- and assume that you will encounter Java 8 in other developers’ paradigm programming, Clojure for Lisp-like macros and code. For more on modern Java API design, check out Per code-as-data functional purity, Kotlin for the pleasure of rapid Minborg’s article on page 10. development and beyond-Groovy performance on Android. DEVELOPERS ARE USING NEW-TO-JAVA-8 FEATURES THE FUTURE OF JAVA LOOKS BRIGHT EXTENSIVELY, ESPECIALLY LAMBDAS AND STREAMS DATA 80% of developers are optimistic about the future of Java DATA 73% of developers are using lambdas. 70% are using the (42% "very optimistic," 40% "fairly optimistic"). Stream API. 51% are returning Optionals. IMPLICATIONS Java is neither dead nor dying. Java developers have IMPLICATIONS Two of the three most important features new both the highest stakes in the future of Java and also the deepest, to Java 8 are now used by a large majority of developers. Both most information-rich engagement with the Java community; so (lambdas and streams) facilitate function composition and (for developers’ aggregate opinions on the future of Java should be an certain kinds of function pipelines) more readable code. Multi- excellent indicator of the health of the ecosystem. paradigm programming in Java is a reality. Separately: as Optional usage increases, NullPointerExceptions become less likely. RECOMMENDATIONS Keep writing Java. Contribute to open- source Java projects. Participate actively in the community- RECOMMENDATIONS To exercise your modern Java muscles, driven improvement of the Java platform, whether via the JCP practice refactoring code using lambdas, streams, and Optionals.