The September/October 2016 Issue of Java Magazine
Total Page:16
File Type:pdf, Size:1020Kb
JAX-RS 39 | JAVA INTERFACES 47 | FANTOM 53 SEPTEMBER/OCTOBER 2016 magazine By and for the Java community Devices and IoT INTERACTING 14 WITH SENSORS CONTROLLING CNC ROUTING 24 FROM A RASPBERRY PI IOT AND 32 THE CLOUD ORACLE.COM/JAVAMAGAZINE //table of contents / 14 24 32 RASPBERRY PI– USING THE CLOUD INTERACTING WITH SENSORS CONTROLLED CNC WITH IOT ROUTER By Eric Bruno ON INTEL’S X86 GALILEO BOARD By Stephen Chin By pushing device control and Programming the Raspberry Pi analytics into an IoT-specific to manage cutting, carving, cloud, devices can be remotely and routing operations managed and operated. By Gastón Hillar Capturing and responding to data are the heart and soul of IoT. Here’s how to do both with Java on an inexpensive board that uses an x86 processor. COVER ART BY I-HUA CHEN 04 11 47 58 From the Editor JVM Language Summit 2016 New to Java Fix This Appreciating Limited Choice in Recapping a small annual conference The Evolving Nature of Interfaces By Simon Roberts Languages: The more prescriptive that dives deeply into the JVM By Michael Kölling Our latest code quiz a language is in the details, the 12 Understanding multiple inheritance and 23 easier it is to code productively. Java Books the role of Java 8’s default methods Java Proposals of Interest 06 Review of Java Performance Companion 53 JEP 293: Revising the format Letters to the Editor 39 JVM Languages of command-line options Comments, questions, suggestions, Enterprise Java Fantom Programming Language 64 and kudos By Brian Frank User Groups JAX-RS.next: A First Glance A language that runs on the JVM and 09 By Sebastian Daschner Danish JUG JavaScript VMs and delivers excellent Events A look at what’s coming next in UI-building capabilities 65 Upcoming Java conferences and events JAX-RS 2.1 Contact Us Have a comment? Suggestion? Want to submit an article proposal? Here’s how. 01 ORACLE.COM/JAVAMAGAZINE /////////////////////////////// SEPTEMBER/OCTOBER 2016 EDITORIAL PUBLISHING Editor in Chief Publisher Andrew Binstock Jennifer Hamilton +1.650.506.3794 Managing Editor Associate Publisher and Audience Claire Breen Development Director Copy Editors Karin Kinnear +1.650.506.1985 Karen Perkins, Jim Donahue Audience Development Manager Get Java Technical Reviewer Jennifer Kurtz Stephen Chin ADVERTISING SALES DESIGN Sales Director Senior Creative Director Tom Cometa Francisco G Delgadillo Account Manager Mark Makinney Certified Design Director Richard Merchán Account Manager Senior Designer Marcin Gamza Arianna Pucherelli Advertising Sales Assistant Designer Cindy Elhaj +1.626.396.9400 x 201 Oracle University Jaime Ferrand Mailing-List Rentals Senior Production Manager Contact your sales representative. Sheila Brennan Production Designer RESOURCES Kathy Cygnarowicz Oracle Products +1.800.367.8674 (US/Canada) * Oracle Services Upgrade & Save 35% +1.888.283.0591 (US) ARTICLE SUBMISSION Get noticed by hiring managers If you are interested in submitting an article, please email the editors. SUBSCRIPTION INFORMATION Subscriptions are complimentary for qualified individuals who complete the Learn from Java experts subscription form. MAGAZINE CUSTOMER SERVICE [email protected] Phone +1.847.763.9635 Join online or in the classroom 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 Connect with our Java Customer Service. certification community Copyright © 2016, 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 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 Save 35% when you upgrade or advance your existing Java certification. Offer expires December 31, 2016. Click for further details, terms, and conditions. 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 affiliates. Other names may be trademarks of their respective owners. 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. 02 ORACLE.COM/JAVAMAGAZINE /////////////////////////////// SEPTEMBER/OCTOBER 2016 //from the editor / Java in the Cloud Appreciating Limited Choice Oracle Cloud delivers high-performance and in Languages battle-tested platform The more prescriptive a language is in the details, and infrastructure services the easier it is to code productively. for the most demanding Java apps. ur coverage of JDK Enhancement Proposals command-line switches should be included in Oracle Cloud. O (JEPs) in this issue examines a recent pro- style guides for the language. If the Java team Built for modern app dev. posal to standardize the syntax of command-line had specified a standard convention for switches Built for you. arguments for tools that ship in the JDK. As the when it released the language (in the same way proposal points out in support of its core concern, that it recommended initial capitals for class presently there are multiple ways of asking for names and all capitals for constants), this small help from the command line. And if you happen annoyance would not exist. The more a language to guess wrong when using a given tool, you need can formalize small details, the easier it is to get to circle through the variety of possibilities. These things done. can vary from –help to --help to -?. And then But in an ideal world, even this solution is there’s the unmentioned last resort, which is to insufficient. I strongly believe that the abundance Start here: run the program with no arguments and see what of Java style guides is itself a limitation. I’d far developer.oracle.com kind of information you get in the error message. prefer that there be one consistent set of recom- I wholly support this standardization, but mendations that was universally followed. For I’d go much further. In my view, the syntax of example, writing out definitive guidelines for the #developersrule PHOTOGRAPH BY BOB ADLER/GETTY IMAGES 04 ORACLE.COM/JAVAMAGAZINE /////////////////////////////// SEPTEMBER/OCTOBER 2016 //from the editor / location of opening braces, size tions of an integer. As a result, there are additional constraints. The convenience and benefits of indents, tabs vs. spaces, how porting C from one platform For example, the executable code of such strictures that ensure to stagger or not stagger if/else to another was extraordinarily after any if statement must be uniform syntax are widely rec- sequences, Javadoc’s numerous tedious. Java solved these prob- enclosed in braces, even it if con- ognized. This is evident in the formatting options, and so forth. lems. Data items had fixed sizes tains only a single line. Many other choice of most modern develop- Obviously, this would apply to across platforms, and code could conventional items are defined by ment organizations to prescribe higher-level concerns as well: fully be run on multiple platforms what is known as “idiomatic Go.” their own “house style” for code, expanded imports vs. wildcards, without modification. The happy result is that all Go code which is frequently enforced in the sequence of import state- C’s lack of standardization looks the same. Reading and writ- code reviews, so that all develop- ments and variable declarations, caused so much pointless activ- ing it is easy. ers use the same conventions. But and so on. By having a fixed set of The lack of standardization these styles conflict with each guidelines, every Java listing would of details during the last few other for lack of a single, unified be consistent and not require re- years has been an issue in Java set of conventions. examination to adjust to a given Most modern development in small but annoying ways, If the world were all Java, I individual’s or site’s style. organizations prescribe beyond command-line syntax. For think it would not be too onerous Curiously enough, in a certain their own “house style” example, the three variants of the to put up with the differences, way, Java’s initial appearance on annotation for indicating a field although the time lost in doing so the scene addressed what, at the for code, which is frequently should not be null: @NonNull, is lost for no good reason. time, was a tremendous laxity in enforced in code reviews. But @Nonnull, and @NotNull. The But in an increasingly poly- language that made some tasks these styles conflict with each first of these was used by Check- glot world in which other lan- exceedingly tedious. The principal style and FindBugs, the last of guages (JavaScript, HTML, and language before Java was C. It was other for lack of a single, unified them by Java EE 6 and the IntelliJ so on) play significant roles, the purposely designed from a radi- set of conventions. IDE. The result was that if you lack of enforced coding standards cally nonprescriptive perspective. coded in one environment and in Java and especially across those Even today, after many rounds of moved to a different development languages combine to create a standardization, C has numerous environment, you had to change sustained and pointless drag on places where behavior is unde- your code or your toolchain to productivity.