This year I attended the 2 days of conference at Devoxx UK taking place in London on 10-11th May. This article is a summary of the notes I took during the first day. If you’re interested in more details in a talk, you can watch the associated video.
A Future without Servers, with Danilo Poccia
How to build the best software with the best user experience?
Work backwards from the customer and before starting any implementation:
- Write a Press Release
- Write the FAQ
- Define the Customer experience
- Write the User manual
The idea is to get your system simple. A complex system was simple at the beginning, it became complex!
Architecture is changing:
- 10 years ago: we are splitting our monolith applications using XML and SOAP for the communication
- 5 years ago: we are creating micro services architecture using REST/JSON or binary protocol for the communication
- Now: we are building event-driven architecture with ephemeral functions
What about the data?
Data repositories are becoming a source of events. Each event is an immutable information about business.
There is a shift from ACID (Atomic, Consistent, Isolated, Durable) to ACID 2.0 (Associative, Commutative, Idempotent, Distributed).
With event-driven design, we think cause / effect instead of triggers: “Service B is caused by A” instead of “Service A triggers B”. We use notification and acknowledgement mechanism.
So what does the future will look like?
We will write only business logic code!
Let’s Get Lazy: Exploring the Real Power of Streams, with Venkat Subramaniam
Venkat Subramaniam is a very good speaker. It was the first time I was hearing him and I was impressed by his way of presenting, I suggest you to watch one of his videos.
Haskell is a lazy language by default. With Scala, it’s possible by using the keyword “lazy”. But what about Java? The keyword “lazy” doesn’t exist but it’s possible with functional code and streams introduced with Java 8.
Imperative code has high ceremony and has accidental complexity. You tell what to do and how to do it.
Functional code has less ceremony and less complexity. You tell what to do. It is very easy to read from top to bottom.
However, if the code is “cute”, it may not be sustainable. So what about performance? E.g. Do we compute all the collection to take only the first one?
FindFirst() is the terminal operation of execution. Until we call it, nothing (i.e. all the intermediate operations) will be executed.
Stream does not execute a function for every object in the collection, instead it executes a collection of functions for every object, but only as needed.
Stream is not a collection of objects, it’s a collection of functions.
Lambda are stateless.
List<Integer> numbers = Arrays.asList(1, 2, 3); Stream<Integer> stream = numbers.stream() .map (e -> e * 2); // This is a lambda stream.forEach(System.out::println);
Closure carry immutable state, be very careful when using them.
List<Integer> numbers = Arrays.asList(1, 2, 3); final int factor = 2; Stream<Integer> stream = numbers.stream() .map (e -> e * factor); // This is a closure stream.forEach(System.out::println);
Laziness makes the use of infinite streams possible, otherwise the program below would be an infinite loop.
Stream<Integer> infiniteStream = Stream.iterate(0, e -> e + 1); List<Integer> numbers = infiniteStream .limit(5) .collect(Collectors.toList());
Kotlin for Java Programmers, with Venkat Subramaniam
I stayed in the same room as I really like Venkat’s first talk. With the same way of presenting, this second talk was very good as well.
As I never experiment Kotlin, it was a nice introduction for me. This JVM-based language is really getting popular these days, especially since Jetbrain is pushing it to be the main language for Android programming. Venkat gave us a lot of different tricks to make the code concise and suggest us to play with it ourselves using the REPL (kotlinc). No doubt it is less verbose than Java and comes with very nice features (including null safety and the lazy keyword…). I will probably give it a try at some point.
How to use AI and Java to train your application to recognize people by name, with Ruth Yakubu
Ruth introduced us Microsoft Face API running on its cloud computing platform Azure. Face API is one of the “cognitive” services Microsoft provides, e.g. there is a service to recognize speech and process natural language.
She showed us an application written with Spring Boot that is interacting with Face API. First, she uploaded a set of pictures of the actor Matthew McConaughey (if you don’t know him, he was the main character in Interstellar) to train the model. Then she uploaded a new picture of him and his wife that the system did not know yet. The algorithm recognizes that it was the actor with a high precision while it did not know who the woman was but it was able to give an accurate description of her (smiley woman in her thirties, etc.).
It is possible to build your own Machine Learning algorithm with Java, for example using the library DeepLearning4J. When creating a model, it is important to separate the data into 2 groups, training data (80%) and test data (20%) so you can verify your model has a good prediction. It is also important to use GPUs not only CPUs to improve the performances, now the libraries are taking advantage of this, including DL4J.
Building a self-driving RC car, with Tim van Eijndhoven
It was an interesting talk to create a self-driving (toy) car based on a Radio Control (RC) kit. They build this prototype as part of a challenge. The idea is to get the car to drive autonomously and follow an itinerary (a path delimited by 2 white lines) with potential curves and obstacles.
If Tesla can do it, why not us? At our scale, of course…
On top of the RC kit, they added a Raspberry Pi, a power convertor/supply, a camera and a safe shutdown (useful when the car gets out of range of the WiFi so it doesn’t crash somewhere…). The total budget is around 300 euros.
Regarding the technologies they use:
- Vert.x, reactive application on the JVM, event driven and non-blocking
- OpenCV library (Computer Vision) to process the video stream in real-time and make sure the car is following the white lines
There are a lot of things to think about, the environment is probably the most challenging. The algorithm can get lost depending on:
- The surface (patterned carpet, tiles, dark road)
- The weather (sunny, rainy, the program is very sensitive to brightness change)
- And other random things (window reflection, mirror effect)
They have many ideas of improvement for the future:
- It is not needed to analyze all images coming from the video stream (especially on a straight line). Currently, they analyze one image every 100ms (why 100ms? because it takes this amount of time to process one)
- It is not needed to analyze the whole image (some part can be discarded, what is above the horizon is not needed)
- Having the computation done on the car itself instead of a laptop over the WiFi, to avoid network latency (however the computational power of Raspberry Pi can be limited)
- Use AI and deep leaning algorithm so the car gets better at navigating using a training set: videos when the car is remotely controlled by a human (however it can take ages to build many tracks and take many videos)
Cloud Native Java, part deux, with Josh Long
Josh is Spring Developer Advocate at Pivotal, it was the first time I was attending one of his talk. I really enjoyed it and I was very impressed by the speed of speech and coding simultaneously without forgetting multiple jokes. Such a brilliant speaker.
Josh used https://start.spring.io/ to generate a little project to manage reservations using Spring Cloud (built on Spring Boot). Why you should use this online tool to initialize your project? Watch the video to get the answer from Josh, it was hilarious!
He chose Kotlin for the service (because why not?) with some endpoints to get messages and reservations using a MongoDB reactive datastore. The service was loading some data in a react way during the start up.
He chose Java for the client using various technology coming out of the box with Spring (Eureka, Spring security, Hystrix for internal load balancer and fallbacks). The client was able to query the service to retrieve the data.
At the end of the demo, he also shows us some serverless architecture using RIFF, a FaaS for Kubernetes. He wrote a function to make a string uppercase, then using the command line to invoke the function deployed in Kubernetes. He did not have the time to show us the call from a service, but we got the idea.
My first day at Devoxx was great, this year I tried to attend more innovative talks about Serverless and Machine Learning, a mix of live coding and theory. I will post my summary of day 2 soon, so stay tuned!