Mark Stephens Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

CodeOne 2018 – Day One talks and Java Keynote report

9 min read

Here are my notes from the talks I attended on Day One at CodeOne (the successor toJavaOne). We have a summary report on our 4 highlights from Oracle CodeOne and  you can find Tuesday’s here, Wednesday’s here, and Thursday’s here.

I have added my takeaways at the end of each. Any mistakes or omissions are mine. Please add comments if you would like any items expanded.

Up and Away: JDK Optimizations Beyond JDK 9 [DEV5091] 

  • Reminder OpenJDK contributors – includes Intel, AMD, Google
  • Worked on JDK9 from 2013. Lots of features including Jigsaw, Variable handles, JShell, Compact strings, Collection factories, Linux/AArch64 Port, Linux/x390x PortAhead of time compilation
  • 1450 improvements to Hotspot.
  • Local Type , new GC interface, Application class-data sharing, Thread-local handshakes
  • Heap allocation on Alt memory devices
  • JDK 10 (started Jan 2017) – Local variable types, GC enhancements, Thread-Local Handshapes, Experimental Java Based JIT compiler (Graal).
  • 400 enhancements in JDK 10 hotspots ie (Math.muliplyHigh())
  • JDK11 (LTS). Nest based Access control, Dynamic class constants, Epsilon GC, ZFGC, Local variable syntax for Lambda, Unicode 10, include flight recorder, Launch Single file source
  • 500 enhancements to JDK.
  • Specific X86 enhancements in 9, 10 and 11
  • Array Compare has been optimised in  11 (2x)
  • Sqrt in 11 (6x)
  • Base64 encode  (2x)
  • From 10, flag to put all/part Java heap on Persistent memory (AllocateHeapAt, AllocateOldGenAt). And use for DirectByteBuffer
  • Lots of work on VectorAPI (ie FloatVector)
  • Direct I/O can bypass kernel and page caching. From Java10.
  • RDMA will allow faster application data transfer when done.
  • Future features for JDK12. Aim for 1 AArch64 Port (not 2), Default CDS archives. Around 210 enhancements to JDK 210. General code optimisations in JVM. (C2 will optimise power-of-2 check, Optimise integer divisible by power-2-check,Lot of code refactoring for new ZGC and Shenandoah GC.
  • Will be more X86 optimisations in JDK12
  • Future features will include VecotrAPI, Limnit Speculative execution, RDMA network sockets, JVM constants API, Intrinics for LDC and InvokeDynamic
  • Some notable Open JDK – Skara (move source code from mercurial to git), Loom (fibres), Panama (improved JNI), Value types (part of Valhalla), Metropolise (Java-on-Java)
  • Most enhancements should not be dependent on specific hardware

My takeaways – very technical talk. Good reminder on features added and some impressive speed boosts in Java11. Lots of new ideas for Java12 and beyond.

Write More Better: Tech Writing for Developers [DEV4430]

  • Now at google. Has written 20 tech books and one romance (last definitely NSFW)!
  • User testing – users read docs and get there via google. Hopefully your notes. Over half issues against docs. If they read the wrong docs, no hope.
  • So SEO and search matters. Links are death. Readers skim.
  • Search engines not good on getting you the latest docs as opposed to latest. So delete all old docs.
  • Every link loses 1% of readers. Every inline link uses 10% or readers and they can’t get back.
  • No one reads the side bar.
  • Only place to put links is bottom.
  • Support skimming. Leave out the boring stuff. Code samples are critical. Bulleted and numbered lists are excellent. Heading and white space help.
  • Write in business casual – straight-forward, not too personal. Keep your distance. No jokes. Aviod culturally specific examples such as baseball.
  • Clear concise and simple prose. Never 3 words where 1 will do. Pros is like code – simple, clean better than opaque, obfuscated, flowery prose.
  • One thought per sentence.
  • Itemised lists good. Numbered lists better.
  • Save big words for technical terms.
  • Aim 8th grade reading level.
  • Many readers not native english speakers.
  • Use present tense except for simple past/future for specific events (ie Java11 was released).
  • Active voice (the input stream reads not the file is read). Makes explicit who is doing the action.
  • You for tutorials. it for references. I/we acceptable for specific war stories/case studies. Otherwise it/computer (I never open a socket – the computer does).
  • Since words are better (ie Java instead of Java Programming language, fast instead of performant). Book – The elements of style
  • Omit needless words
  • Good adjective clarify (ie not beautiful ,clear, Fast, scalable, high performance). If no-one would every say the opposite it does not mean anything.
  • Good adjectives – immutable, arbitrary-precision, signed, decimal.
  • Just say no to adverbs
  • Tell lawyers to take a hike. It is Java not Oracle Java Programming Language Enterprise edition JDK 11.0.2….
  • Google is a verb (and a company)
  • Watch out for chart junk
  • Include what the reader wants, not marketing, lawyers, etc.
  • Write fast; edit later
  • Outline in headings and bulleted lists. Expand later.
  • Include docs in PRs and the agile tracker.
  • Coders write; writers code – keep docs in SC system.
  • Ensure Infrastructure Low effort to publish
  • Make corrections easy – have  link to report issues with page and 1 with content of page. Link to file bug. Apache Maven makes it really easy edit docs with link to pages on GitHub
  • Prefer HTML or markdown over Word, google Docs or PDF.
  • Videos are an addition not a substitute.  Both are cool.
  • Books Elements of Style. The Chicago Manual of style.
  • Google Developer Documentastion style guide, O’Reilly Word List and Style sheet.

My takeaways – Brilliant talk on how to write better documentation with loads of practical takeaways.

JavaScript Libraries: What’s Hot and What’s Not? [DEV4939]

  • Proliferation of JS technologies
  • Lack of standardisation means you often end up with your own custom stack.
  • JS is everywhere.
  • Browser is a platform which has ‘won the war’. Browser everywhere
  • Tradition non-browser solutions include ASF Forms, Vaadin, Gluon, DukeScript.
  • (Unfortunate) benefits of JavaScript are:- Write Once, Run everywhere, makes mobile dev easy (Cordova), lots of developers, lots of innovation, exploration, new ideas, everyone has basic knowledge.
  • Most companies IT  companies (Uber, FT on GitHub) and creating own tech stacks which you can use if in their ecosystem. Need ensure not just a code dump.
  • Enterprise needs:-
  • stable solution
  • responsive design
  • accessibility and internationalisation
  • Data visualisation
  • security
  • Performance optimisation
  • conformance to standards
  • empower business users
  • documentation and support
  • Lesson learned at Oracle with Jet are:-
  • Cordova good enough for most business apps as not high end use for video/animation
  • Jet uses RequireJS for all lazy loading..
  • Rejected Crossroads as did not have all routing features needed.
  • Built jet as modular and hide libs so could switch in/out pieces without making changing to API/user perspective
  • JET being used by an Indian company with millions of users – good test of scaling.
  • Some nice demos using JET (using ojet) which has lots of GUI features so you can graphically create code

My takeaways – Interesting summary of issues facing developers in 2018 and background on Jet. Nice demos if you have not seen it before.

Condy? NestMates? Understanding JDK11’s JVM Features [DEV5652]

  • Smaller, faster releases (ie Java 17 9/21)
  • Nest-based access control and Condy in J11
  • example for simple inner class with private variable. Surprising compiles to invoke static for access variable. Does getField method. Due to misalignment as private’s method can be accessed in nested class but not defined in spec. So compiler creates access bridges – overhead and breaks reflective access
  • New APIS to Class to provide reflective Nest access (ie getNestHost(), get NestMembers(), isNetMateOf()
  • MethodHandles.Lookup and Reflection updated and reflection now works in J11 in this case
  • Good example of JDK paying down technical debt
  • refresher on how invokeDynamic is converted to Java byte code
  • duality between bootstrapped calls and constants – each can implement the other.
  • Condy looks like indy but less overhead
  • Makes it easier to handle bootstraps
  • Good use cases for Condy in new Java releases are providing better non-capturing lambdas, initialisation-on-demand holder pattern, var handle optimisations
  • Nestmates: paying of innnerclasses related technical debt
  • Condy : downpayment on future innovation.

My takeaways – very technical talk. Lots of Java byte code. Nice explanation of Nest issue and fix in Java11.  Good explanation of ConstantDynamic and InvokeDynamic

Type Inference: Friend or Foe [DEV5373]

  • Focus on Java but more general scope
  • Type inference makes sense if statically typed lang (Haskell, Scala, Kotlin)
  • Languages moving to type inference C#, Java, C++
  • In Java since Java5 (generics)
  • Java7 added diamond operator (but does not work with anonymous inner clases – fixed in Java9)
  • Java8 has type inference in lambda (does not allow annotations unless specify type ie final @notNull Integer e
  • Context also need in lambda
  • Java9 fixed anonymous inner classes
  • Java10 adds local variable type inference. Only if 100% clear (both compiler and human)
  • No such thing as a var type – var greet = “hello” – type is string
  • var local variable but can be use din for each  for(var name : names){}
  • can use var in try
  • var does not currently work for fields or parameters
  • var is not a keyword so you can have var var =4;
  • Do not use with <> operator ie ArrayList<String> str = new ArrayList<>(); to var str = = new ArrayList<>(); changes type of str to Object.
  • Some programmers will not take no for an answer. var should not be used for lambdas (you can do with ugly code but should not).
  • Benefits of type inference include:-
  • reduce clutter

My takeaways – great explanation of type inference and covers lots of gotchas delivered with Venkat’s infectious enthusiasm.

Incremental Improvements to the Java Platform [DEV6074]

  • Motivated by speed up in release cycle.
  • Less stuff at more rapid rate
  • How do we know what has improved between major Java release?
  • To answer this need to know what has changed….
  • Details on release notes, CSRs and spec diff, bug database
  • Build and look at annotated source
  • List selected by presenter
  • Deduplicating lambdas
  • Comparison and mismatching over Arrays
  • comparison and mismatching over nio buffers
  • Executing Java source (lowering Java’s activation energy). ie java RunMe.java now works
  • You can add #! in Java11 at top of file with parameters and run ./RunMe (like a bash script) Feels like JShell.
  • collection literals (List.of, Set.or, Map.of. Unmodifiable and null hostile in Java9. Incremental improvements in Java10/11
  • Optional.orElseThrow in Java10
  • Predicate.not in Java 11 stream.filter(not(String::isEmpty))
  • Collection.toArray in Java11
  • Methods on input stream (readAllBytes,readNBytes, transferTo in Java9, readNBytes, nullInputStream in Java11
  • strip, stripLeading, stripTrailing, isBlank, lines, repeat string methods in Java11
  • indent, align String methods in Java12
  • Files has readString, write String in Java11
  • Math.fma one rounding error not 2 in Java10
  • VectorAPI improves performance
  • Faster Square root

My takeaways – Technical talk highlighting some less known but really useful features in Java 9, 10, 11 releases.

Reactive APIs of Java 9 [DEV5374]

  • Reactive programming is not new. Extreme programming.
  • Code should scale and be elastic
  • Message driven (Don’t expose your database instead export your data)
  • In life and programming there are 2 things w should never share  – toothbrush and database
  • Responsive
  • Resilient (fail gracefully and fast)
  • Excel – reactive application (live update in response to your changes)
  • Dataflow (CRUD)
  • Reactive programmin = Functional programming ++
  • FP = functional composition and lazy evaluation
  • Java 8 stream = pipeline, lazy, push data only, error – good luck, 1 channel, no forking, push at will, sequential v parallel
  • Reactive stream = pipeline, lazy, push , data also, error – deal with it downstream, 3 channels (data, error, complete), multiple subscribers, back pressure, synchronous v asynchronous
  • Exceptions and functional programming are mutually exclusive
  • Reactive stream API has 4 interfaces:-
  • Publisher – emit data
  • Subscriber – reads data
  • Subscription – session (can be multiple sessions with single publisher)
  • Processors – can be both publisher and subscriber (ie filter op)
  • Different back pressure strategies allowing you to wait or drop data
  • Java 9 API copies Reactive Stream (same 4 interfaces). Only diff is in java.util.concurrent.Flown rather than reactive.io – still needs external libraries (Oracle just provides the interfaces in Java)
  • Good demo java.util.concurrent.SubmissionPublisher
  • Cold and hot publisher (hot shares subscription). set with .share()

My takeaways – great explanation of Java 8 streams and how Reactive Streams differ and solve additional problems (like exception handling)

Keynote: The Future of Java Is Today [KEY6649]

  • Introduction by George Saab
  • 9 Duke’s choice awards this year
  • GitHub keynote by Matthew McCullough.
  • Project Skara looking at moving Java from Mercurial to Git.
  • Think small to accomplish more. Power on 1
  • 1.1 billion contributions on GitHub
  • Project Skara already provides read-only view on JDK
  • State of Octoverse – GitHub annual review. Java currently number 2 behind JavaScript
  • Project hydro – internal GitHub project to handle messaging. Already have Resque (redis), Webhooks (Kestrel), Analytics (Kafka). Built common internal solution for them in Java, not Ruby. Reasons – parallelism, performance, Strong typing, Ecosystem. So data pipe line in Java not Ruby.
  • Covered Skara ideas including options to move to GitHub
  • Bots in GitHub provide automation on code changes – can give feedback on code changes you push (ie trailing whitespace), ensure you get code review.
  • (back to George Saab) Conflict of stability and change. So OpenJDK ensures development happens in open.
  • Oracle has made Java more open (remaining closed source features contributed to OpedJDK).
  • More rapid development and regular release cycle with LTS releases every third year
  • Oracle offering Enterprise long-term support.
  • Java 11 largest open source involvement of any Java release
  • Continued support for Java ecosystem (Java Champions, JUGs, Java magazine, Student outreach, JDuchess progress).
  • Mark Reinhold onstage
  • Year of change.
  • 26 modules instead of 1 monolith and removed 7 modules to give 19.
  • Now 6 monthly releases.
  • Good reasons for change – things have changed in last 20 years and Java needs to adapt and move fast to remain competitive
  • Modular is also more secure and maintain
  • Internal APIs available for now but will go in future. Use jdeps tool to see if you use internal APIs.
  • Removed Java EE and Corba in JDK and obscure methods (after analysing code in wild)
  • Methods removed in 9,10,11. Always flag at least 1 release in advanced
  • Working to remove finalise() as fundamentally broken
  • Java is still free. You can buy support (from Oracle or others)
  • Top 5 misconceptions –
  • every release will be as disrupted as in past.
  • non LTS releases are experimental
  • To remove a deprecated feature needs 3 years
  • If you maintain an infrequently migrated system you can ignore non-LTS
  • There will never be more than 3 years of LTS support and 6 months on non-LTS. There are other providers out there.
  • #worksFineOnJDK9 #worksLikeHeavenOnJDK11
  • Everything changes and nothing stands still.
  • Java 9 last massive release – 90 JEPS
  • Aims of Java:-
  • Developer productivity
  • Program performance
  • Interesting JDK projects:-
  • Amber – right-sizing language ceremony
  • Simplify and remove bugs in case statements
  • Record feature will add easy way to create classes like Point(x,y) with data rather than Class with lots of boilerplate.
  • Pattern matching in switch statements will remove lots of casting in if statements.
  • Loom – continuations and fibres
  • Threads have always been in Java but have lots of complexity and baggage. Expensive to create and switch
  • Fibre is like a thread but not linked to OS thread. Assigned to thread by Java scheduler. Much simpler. Work well with completable futures.
  • More responsive and consistent than threads
  • Panama – foreign function/data interfaces
  • Make it easier and faster to use native code than current JNI
  • jextract tool creates Java interfaces/Classes for accessing C code
  • Uses Libraries.bind in Java to then give access to native code
  • Can also access foreign data
  • Valhalla – value types
  • pointer do not work as well with modern caches.
  • Gives flat data structures – codes like a class, works like an int
  • Enabled with value keyword in class definition
  • All 4 feature demos showed these features all up and running but still slightly flaky and final spec still being decided
  • Mark used this favourite IDE – emacs….

My takeaways – Much less sales than previous keynotes and nice summary of where Java is and going.

 

 

 

 

Mark Stephens Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Leave a Reply

Your email address will not be published. Required fields are marked *