Java Magazine, January/February 2018
Total Page:16
File Type:pdf, Size:1020Kb
INTERFACES IN DEPTH 90 | BOOKS ON JAVA 9 07 JANUARY/FEBRUARY 2018 magazine REACTIVE By and for the Java community PROGRAMMING Handling large data streams efciently 16 32 61 69 REACTIVE RXJAVA— REACTORS IN CQRS: NOT PROGRAMMING REACTIVE SPRING 5.0 THE USUAL WITH JAX-RS LIBRARY FOR CRUD THE JVM ORACLE.COM/JAVAMAGAZINE //table of contents / COVER FEATURES 32 61 69 GOING REACTIVE REACTIVE SPRING COMMAND QUERY WITH ECLIPSE VERT.X By Josh Long RESPONSIBILITY AND RXJAVA Proceeding from fundamentals, SEGREGATION By Clement Escoffier use the Spring Framework WITH JAVA and Julien Ponge to quickly build a reactive By Sebastian Daschner Building fast scalable systems application. Get around the limitations of with one of the most popular CRUD by using event streams reactive Java libraries and an eventually consistent 16 architecture. REACTIVE PROGRAMMING WITH JAX-RS By Mert Çalışkan Using an asynchronous approach and staging to develop responsive reactive apps OTHER FEATURES DEPARTMENTS 90 101 05 13 The Evolving Nature Fix This From the Editor User Groups of Java Interfaces By Simon Roberts and Mikalai Zaikin The decline of dynamic typing The Denver JUG By Michael Kölling Our latest quiz with questions that 07 114 Understanding multiple inheritance test intermediate and advanced Java Books Contact Us in Java knowledge of the language Reviews of Java 9 Modularity and Have a comment? Suggestion? Want to Java 9 for Programmers submit an article proposal? Here’s how. 10 Events Upcoming Java conferences and events COVER ART BY PEDRO MURTEIRA 02 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2018 EDITORIAL PUBLISHING Editor in Chief Publisher and Audience Development Andrew Binstock Director Managing Editor Karin Kinnear Claire Breen Audience Development Manager Copy Editors Jennifer Kurtz Karen Perkins, Leslie Steere Technical Reviewer ADVERTISING SALES Stephen Chin Sales Director Tom Cometa DESIGN Account Manager Senior Creative Director Mark Makinney Francisco G Delgadillo Mailing-List Rentals Design Director Contact your sales representative. Richard Merchán Senior Designer RESOURCES Arianna Pucherelli Oracle Products Designer +1.800.367.8674 (US/Canada) Jaime Ferrand Oracle Services Senior Publication Designer +1.888.283.0591 (US) Sheila Brennan Production Designer Kathy Cygnarowicz ARTICLE SUBMISSION If you are interested in submitting an article, please email the editors. SUBSCRIPTION INFORMATION Subscriptions are complimentary for qualified individuals who complete the subscription form. You’ve Earned It MAGAZINE CUSTOMER SERVICE [email protected] Display Your Oracle Certification Digital Badge PRIVACY Oracle Publishing allows sharing of its mailing list with selected third parties. If you prefer that your mailing address or email address not be included in this program, contact Customer Service. Copyright © 2018, Oracle and/or its affiliates. All Rights Reserved. No part of this publication may be reprinted or otherwise reproduced without permission from the editors. JAVA MAGAZINE IS PROVIDED ON AN “AS IS” BASIS. ORACLE EXPRESSLY DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ORACLE BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING FROM YOUR USE OF OR RELIANCE ON ANY INFORMATION PROVIDED HEREIN. Opinions ASSOCIATE PROFESSIONAL MASTER EXPERT SPECIALIST expressed by authors, editors, and interviewees—even if they are Oracle employees—do not necessarily reflect the views of Oracle. The information is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Oracle and Java are registered trademarks of Oracle Corporation and/or its Claim your certification badge and validate affiliates. Other names may be trademarks of their respective owners. your skills across all online platforms. Java Magazine is published bimonthly and made available at no cost to qualified subscribers by Oracle, 500 Oracle Parkway, MS OPL-3A, Redwood City, CA 94065-1600. 03 ORACLE.COM/JAVAMAGAZINE ///////////////////////////////// JANUARY/FEBRUARY 2018 Register Now Oracle Code is BACK! | 1-Day, Free Event Explore the Latest Developer Trends: • DevOps, Containers, Microservices, and APIs • MySQL, NoSQL, Oracle, and Open Source Databases • Development Tools and Low Code Platforms • Open Source Technologies • Machine Learning, AI, and Chatbots Coming to a city near you: developer.oracle.com/code //from the editor / Java in the Cloud The Decline of Dynamic Typing Oracle Cloud delivers A feature once viewed as a convenience has become more troublesome than it’s worth. high-performance and battle-tested platform and infrastructure services for the most demanding f you follow the rise and fall of programming As a quick refresher, static typing refers to a Java apps. Ilanguages—either from the comfort of an type system that makes it possible to know the armchair, ensconced with your preferred tools type of every data item and expression at compile but interested in other people’s choices, or from time. Specifically, this means that the language Oracle Cloud. a keyboard, happy to hyperkinetically try out all does not allow the use of types that are resolved Built for modern app dev. kinds of new idioms—you will have noticed an at runtime. For example, in JavaScript (a dynami- Built for you. unmistakable trend in modern language design: cally typed language) a variable is declared by a preference for static typing. using var, rather than a specific type. A variable Look at the major languages that have can hold a string, a number, or a boolean at vari- emerged in the past decade—Go, Swift, Kotlin, ous times in the same program. In contrast, static and Rust—they’re all statically typed. Moreover, types, such as those found in Java, force you to languages that were once dynamic have added declare the type when you define the variable. static typing. The most conspicuous example is Static typing provides several important the recent set of updates to JavaScript (or more advantages. The first advantage is that the com- Start here: accurately, ECMAScript). Apple’s choice to replace piler can perform significant program verifi- developer.oracle.com dynamically typed Objective-C with Swift also cation. Because the compiler knows that i, for follows this trend. example, has been declared an integer, it can #developersrule PHOTOGRAPH BY BOB ADLER/THE VERBATIM AGENCY 05 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2018 //from the editor / check that all places where i is this aspect is invaluable. Stepping quick and easy development, was used do expect or at least can through code in which the con- a welcome step forward. support an integer. Likewise, tents of a variable can change But while dynamic languages static source code checkers are type is not anybody’s idea of fun. have retained considerable popu- much more capable when they The dynamic aspect also intro- larity, some 15 years later the have complete type information. duces a kind of uncertainty when cost of dynamic typing is more A second key benefit is per- a bug is discovered. Say the vari- apparent as codebases grow formance. A runtime that must able i, which previously held an larger, performance becomes The Best determine the type of every vari- integer, now holds a string; was more important, and the cost able and the methods that are that a spelling error by the devel- of maintenance rises steadily. Resource available to it while the program oper, who meant to store it in u, While those dynamically typed is running has significant over- or was it an intentional reuse languages will surely be with for Modern head that statically typed lan- of a variable? And if the latter, us for a long time, it is unlikely guages don’t require. In part, this how should you understand that many new languages will Cloud Dev is why many of the traditional other instances of i in the code- embrace the model. dynamic languages—Python, base? These problems are bear- The Oracle Developer Perl, and Ruby—run much more able in the small but extremely Andrew Binstock, Editor in Chief Gateway is the best place slowly than statically typed troublesome in the large. This [email protected] to jump-start your modern options. An exception to this problem—precisely as it appears @platypusguy cloud development skills might be JavaScript, which runs in large projects—was the pri- with free trials, downloads, much faster than many dynamic mary motivation for Microsoft to tutorials, documentation, languages. But this speed is a create TypeScript, its superset of and more. comparatively recent advance JavaScript that added one princi- driven by massive investments by pal feature: types. Trials. Downloads. Google and Microsoft into their Dynamic typing flourished Tutorials. Start here: respective JavaScript engines. in popular languages in the mid- developer.oracle.com A final benefit, which in my 1990s (Python, Ruby, JavaScript, view is the one that has turned and PHP all appeared within the tide against dynamic lan- a four-year window), when PC guages, is maintainability. First, hardware had become power- for readability, it is much easier ful enough to run languages developer.oracle.com to understand code if types are that needed runtime support. At declared statically because it is the time, tools were primitive then possible to tell exactly what and compile times were long, so #developersrule you’re looking at. For debugging, dynamic typing, which facilitated 06 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2018 // java books / Java 9 Books The wave of books for the new release is now arriving. s with all previous major releases, the arrival of Java 9 has unleashed a wave of books examining and A explaining its new features. The next few book columns will review important titles that you’ll want to be aware of.