Three things I learned at Devoxx

devoxx logo

Throughout Devoxx Belgium, I attended many talks on an array of topics. Writing about everything I learned would produce a novel rather than a blog article so here are some of highlights.

Java 9 Key Features

Modules

Java 9’s biggest disruption to the ecosystem is the addition of modularity. Implementing this feature into existing applications requires the most work but allows for clear separation of functionality within a monolithic application. This feature may be popular for those looking to develop microservices.

JShell

JShell is Java’s new Read-Eval-Print Loop shell. Many other languages such as Perl, Python, Ruby, C, Erlang have REPLs and now Java does too.

This new feature is applicable to several use-cases. It is an easy environment to teach Java rather than having to set up a project and classes. The setup for a Java project can seem intimidating to those new to programming and JShell avoids that barrier to entry.

For experienced developers, JShell can improve workflow. When creating new functionality, a developer may need to test small bits of code as they go. Doing so by running an application can be slow. The shell allows those snippets to be run and produce instant feedback. With the quick feedback loop, fixes and improvements in the code can occur more quickly.

CompletableFuture

The CompletableFuture class produces “promise” functionality seen in other languages like JavaScript. CompletableFuture provides a large amount of built in methods to support development needs.

Factory methods

Factory methods are now available to easily initialise certain data structures available in Java. Producing a populated List, Set or Map can be cumbersome but these new methods ease the process significantly.

  • List.of(1,2,3,4,5)
  • Set.of(1,2,3,4,5)
  • Map.of(1,”a”,2,”b”,3,”c”)

New Stream features

Streams have become more powerful in Java 9 with new methods and the Optional<> object. The new methods include takeWhile to return the head of a stream once a condition is not satisfied by the given element. In contrast, dropWhile returns the tail of stream once the condition is not met. For an ordered list of integers, the following code snippet can produce a list of integers below 50.

List Integer numbers = List.of(1,13,32,45,65,72,91);
Optional List underFifty = numbers.stream()
     .takeWhile(e -> e < 50);                         // underFifty.get() == {1,13,32,45}

The Optional object can be used to avoid null pointers. In the following case, no value in the stream matches the condition, thus the List will be null. The Optional object will treat this as it having no value set as is shown in the comment. Using Optional objects allows for safer code and null checking.

 List<Integer> numbers = List.of(1,13,32,45,65,72,91);
 Optional<List> overHundred = numbers.stream()
     .dropWhile(e -> e < 100);                         // overHundred.isPresent() == false

Newest Asynchronous JavaScript Patterns

As JavaScript continues to develop, we see constant change in design patterns. One of the talks at Devoxx highlighted the newest developments (some newer than others).

Promises

Promise structure allows us to separate out the return-scenarios we are interested in from a function. With a promise, we have our input request, what to do with our expected output, and what to do in the event of an error. This can cleanly be displayed in the following way where the request function returns a promise:

 request(itemURL).then(handleSuccess).catch(handleFailure);

Generators

Generators are essentially functions that allow for multiple returns via .next() calls. Each .next() call returns an object with KV pairs of value and done. Value is the output whereas done is a boolean to to indicate where the generator can be called again.

 function *get() {
    var item = yield fetch(itemURL);
     var purchases = yield this.getPurchases(item);
 }

Async, Await

This third pattern is similar to the generators + co in functionality but has objectively cleaner syntax. It also does not require any external packages such as ‘co’.

 async getItem(itemURL) {
     let item = await fetch(itemURL);
     let purchases await this.getPurchases(item);
     return item;
 }

Tensorflow and Machine Learning

Resources: Kaggle, ML Engine,

There were many talks on deep learning around a range of use-cases. A Deep Dive session on Tensorflow was particularly interesting. I learned a lot about the tools and resources available. Kaggle is a website/community that offers lots of data for use in machine learning projects. ML Engine is Google’s tool to export machine learning tasks to be computed on other servers.

Neural network structure and weightings

A neural network is a complex structure of nodes. You can have several layers of these nodes. Each node takes inputs to produce an output. These nodes are an array of aspects relevant to the problem at hand. For instance, if you are trying to estimate the value of a house, a node may take the number of windows and produce an output. Each output has a weighting associated with it indicating how important it is in the evaluation. If a neural network is trying to tell apart a cat from a human, it may use the presence of whiskers as a strongly weighted node in the network.

Generative Adversarial Network

Another interesting application of neural networks that is picking up a lot of interest is generation. It is possible to train a neural network while training a generator at the same time. The end goal is for the generator to be able to produce an image where the neural network can only marginally make a decision. This is essentially training a neural network while training a generator to be able to fool it. Here is an example of a generator trained to produce fake celebrity images.

Were you at Devoxx Belgium this year? Let us know your key takeaways.

If you’re a first-time reader, or simply want to be notified when we post new articles and updates, you can keep up to date by social media (Twitter, Facebook and Google+) or the Blog RSS.

Related Posts:

The following two tabs change content below.

Ovidijus Okinskas

Java Developer / Support at IDRsolutions
Ovi is a developer at IDRsolutions, currently working on JPDF2HTML5. He enjoys self-help reading, batch- cooking and card games.

Latest posts by Ovidijus Okinskas (see all)

ovi

About Ovidijus Okinskas

Ovi is a developer at IDRsolutions, currently working on JPDF2HTML5. He enjoys self-help reading, batch- cooking and card games.

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>