Martin @ Blog

software development and life.

Flower

Devoxx 2015

Devoxx 2015

On 10, 11 and 12 November, the yearly Devoxx Belgium conference took place in Kinepolis Antwerp. With 3500 attendees, 8 tracks and over 200 speakers, this is the biggest Java Community conference of Europe. Of course, it is not only about Java, but all JVM languages are covered, including (of course) Scala and Clojure. Also related technologies, like frameworks, development methodologies and best practices regarding deployment, architecture and testing are covered.

Because of the size of the conference, you have to make a lot of choices. Originally, I wouldn’t go alone, but unfortunately the conference was sold out well in advance, which caused that in the end I was the only one able to get a ticket. The good news is that all sessions were recorded and are available on YouTube for free.

Main topics

As already mentioned, there where 8 tracks with 7 slots per day, which results in a large number of talks. Despite that I think a couple of topics which were more covered than others and they more or less align with the current trends in the software development world, and more specific in the JVM community.

  • Java 9/10
    • Modules
    • JShell (REPL)
    • Additions to Collection API
  • Microservices
    • Resilient software design
    • Deployment best practices
    • Chaos testing
  • Functional Programming Paradigms and Reactive Programming
  • IoT (Internet of Things)

Java 9

Mark Reinhold, Chief Architect of the Java Platform, did the opening Keynote of Devoxx. It was (of course) all about Java 9 and mainly the modularization of the language they are planning to do. After the keynote, there were a number of sessions on the various aspects of this change, covering from how they implemented it to how to use it in practice. I didn’t attend all those sessions, because 7 years ago they did saying it would appear in Java 7, which eventually didn’t. The requirements have changed quite a bit since then and the implementation with it as well. For example, they removed support for versioning of modules, because it became too complex and it would be really complex to make it work with existing tools, like Gradle and Maven, as well. At the time, the modularization was mainly inspired by JavaFX at the time, which is now less relevant as well. The main reasons for modularization are:

IMG_7950

  • More scalable for small devices (think IoT)
  • Improve security and maintainability (it is possible to actually remove unused parts… Corba!)
  • Improve performance

This talk is also on Youtube.

Java 9 is expected next year and next month the current development version should be feature complete. Mark Reinhold and Alan Bateman did a large number of sessions on the modularization of Java and how to prepare your application for it:

Besides modularization, Java 9 will contain a REPL, called jshell which was presented by Robert Field and an improved API for collections, mainly for creating new collections, presented by Stuart Marks. Java 9 will also include support for HTTP/2. Simone Bordet did a talk on HTTP/2 which was interesting to see. HTTP/2 will result in the same speed gain as the SPDY protocol, but is better supported by browsers. It will also give improvements for server-to-server communication. To benefit optimal from HTTP/2, you should integrate it in your app logic to indicate which resources are belonging together. The latest versions of Jetty contain already support for HTTP2.

Second Keynote

Lawrence Krauss

There was a second keynote by Dr. Lawrence Krauss, a theoretical Physicist, about the creation of the universe. This was very interesting, and can also be found on Youtube.

Microservices

I’ve attended a couple of sessions on Microservices. The most interesting one in my opinion was the session of Sam Newman, author of the book ‘Building Microservices’ published by O’Reilly. His talk focussed on 8 principles for designing Microservices:

  • Modelled Around Business Domain
  • Culture of Automation
  • Hide Implementation details
  • Decentralize all the Things
  • Deploy Independently
  • Consumer First
  • Isolate Failure
  • Highly Observable

Sam Newman

It is a bit too much to go over detail for ever principle, but relevant things for us to mention are:

  • Hide implementation detail: Hide your database, services shouldn’t share a data model.
  • Decentralize all the things: He discussed a concept called ‘the magical mystery bus’ which is a central communication bus which has a lot of knowledge on how message should be handled.
  • Consumer first: Many organizations deploy all the services together, because they are tested together. To fix that problem, you should do consumer based testing: identify what the consumers of a service do and make that into a contract. Tools for doing that are for example Pact.
  • Isolate failure: It is easy to create a ‘distributed single point of failure’ when building a Microservice based application. Solutions: reasonable timeouts, bulkhead downstream connections and circuit breakers.

A related talk to this was by Jonas Bonér: Without resilience, nothing else matters. This was about how to create resilient software. The basic idea of this session was based on the design principles of Erlang, which is that it should be able to crash without causing data to be corrupted. He proposed the use of a supervisor to manage the individual parts of the system which perform the critical operations. Those modules should be abel to crash safely and start quickly, which means they should be as stateless as possible.

Lorin Hochstein, an engineer at Netflix, continued on this topic by explaining how Chaos Testing is part of the development culture at Netflix. Familiar to most people is probably the Chaos Monkey, which takes out services and other parts of the Netflix infrastructure to test resilience, but he also explained another new testing method at Netflix which is called ‘Chaos Kong’. Chaos Kong does not just kill a single service, but periodically takes down an entire datacenter. We do this of course as well, but he emphasize that automating these kind of tests make it something which is on top of mind of the engineers. He also talked a bit about the general development culture at Netflix. Interesting points he made regarding their testing and deployment of services. Since their entire architecture consists of a very large number of services, it is impractical to have it running on a ‘development environment’, so they don’t test end-to-end before release. Instead they have detailed monitoring on everything. The main metric to see if systems are healthy is visualized in a graph displaying the number of started streams. This should consistent over the weeks and a deviation from previous weeks indicate some malfunction of a service. If this number is influenced, it means there are serious issues. He recommends for each business to have something similar to monitor the health of production systems. He also pointed out the only way to ‘visualize’ their architecture is by generating a diagram. It is too complex for a single engineer to keep all the services and all their connection in his head.

Another relevant session in this area was The Twelve Factor app: Best Practices for Java Deployment by Joe Kutner which discussed how to deploy services.

  1. Codebase
  2. Dependencies
  3. Config
  4. Backing services
  5. Build, release, run
  6. Processes
  7. Port binding
  8. Concurrency
  9. Disposability
  10. Dev/prod parity
  11. Logs
  12. Admin processes

Functional Programming paradigms

Java 8 introduced Lambda’s and closures. For many developers this is a whole new paradigm with which they are not really familiar. Venkat Subramaniam did a session on how some of the Design Patterns described in the famous ‘Gang of Four’ book with Lambda’s, reducing the amount of boilerplate significantly. It was interesting, probably doesn’t contain a lot of new concepts for Scala developers, but very nice to see nevertheless. The same presenter also had a session during the Unversity days on Core Design Principles for Software Developers which is very nice to see.

Other talks

Of course there was a lot more I saw.

Below some pictures on the optimisation achieved with HTTP2. The example consists of a Jetty:// logo build from a number of small images. In the first image you see the load time without HTTP2 and in the second image with HTTP2

Without HTTP2

With HTTP2

Using Boxen to manage your machine

What is Boxen

Boxen is a framework developed by Github to automate the initial installation of a new laptop for development (or any other task which requires a fixed set of tools). It is developed by Github and was initially called The Setup. The philosophy behind Boxen is that development is production which means that it should be automated like a production environment. Boxen is opinionated in some choices made by the developers who created Boxen, but it is also very pragmatic.

Boxen is basically a wrapper around Puppet, and should be used to manage your installed applications and tools. The nice part is that, since it is open source and used by quite a number of companies already, there are many modules available to automatically install and setup a wide variety of tools, ranging from MySQL to Skype and from Caffeïne to Minecraft. It is also highly configurable and it is very easy to made custom changes for individual developers or machines.

Initial installation of a laptop basically only requires you to install Xcode (which is very trivial since Mavericks) and cloning the our-boxen Git repository and your laptop will be installed within minutes. The best thing is that the latest changes and updates are also pulled automatically when you run boxen, so it is not only useful for when you have a brand new installation on your laptop.

Why Boxen

A while ago I looked into using Boxen to manage my laptop, especially because it would be a very easy way to setup laptops of new colleagues as well. Before I heard about Boxen, I created an install script for MacBooks which is used quite a lot within our company, but has a lot of issues. The main problem with an install script are:

  • Hard to make it idempotent (i.e. to re-run it once it has ran once)
  • Very hard to make it fail-safe. This is because every slight difference in configuration can make the script fail and impossible to recover. You have to cater for almost every possible setup which exists.
  • It doesn’t handle changes in configurations nicely.
  • It is a awful lot of work to keep it up-to-date

With Boxen, all those points are addressed.

Another nice thing is that Boxen is taking the pragmatic approach, so you can basically change everything and still benefit of the fact that a lot of code is reused and it will always be possible to re-run the script to automatically adopt changes in configurations required by your projects.

There are some downsides to Boxen as well. I started experimenting with Boxen around a year ago, at which point the documentation was not very abundant. That is a bit improved now, but many things still have to be deducted from the source. When you have problems, it is not always easy to find the cause and it requires some painfull debugging now and then. Fortunately, since quite some developers are using it nowadays, many issues are somehow covered in issues in Github, so this problem is less prominent then in the beginning.

The main issues I had where because we are using GitHub Enterprise (which means that we have our own GitHub installation running on a private server), and in the beginning that wasn’t really supported (or at least not documented). That is fixed now. Another issue is that our MacBooks are logging in on the Windows Active Directory stuff we have running internally, which causes some issues with user groups. This has been addressed in this issue.

Recommended way of starting with Boxen

Initially, I thought to create an our-boxen repository, tweak it and try it on a fresh VM installation of Mac OS X. While that sort of works, it is quite ellaborate and not very ‘eat your own dogfood’. As a result, I thinkered with the setup for over a year, without really using it. So that is definitely not the recommended way.

The way to get started with Boxen I recommend is to just start using it on your local development environment. For me, that meant that I had to delete my existing Homebrew installation and dump my rvm RVM setup. While that is not always a realistic option, in my experience it is the best one to get started with Boxen. It requires that you fix everything as quickly as possible in order to get a running environment ASAP and also ensures that everything actually works. Because of the fact that I wouldn’t have a running environment for at least a couple of hours, I decided to do this in between Christmas and New Year, because we’re not working that much at our office and it is not a problem that you’re not able to run everything locally anyway.

Don’t do everything with Boxen

Initially, I thought it was a good idea to basically do everything with Boxen, including checking out all the required repositories to run our services on your local machine. However, after a while I discovered that would be pretty much unmaintainable (our setup is quite dynamic, even more dynamic than I expected). So instead of that, I decided that it would be a better idea to make sure all required tools, like Play, Thrift, Scala, Maven, Java, IntelliJ, Skype, etc. would be managed by Boxen and the actualy projects (checking out, starting, stopping, executing database migrations) by the tools which are specialized in that. While we didn’t have a proper tool for those tasks, I decided to create that first (also while using it myself, so it forces me to have it in a working state). This turned out to work quite well and basically allowed me to improve the time to convert a freshly installed MacBook into a completely working environment from a couple of days to around an hour. Having the tools for updating, starting, stopping services to be separate also makes it a lot faster to keep my development machine up-to-date.

Distributing Boxen

There is a project called Boxen-web available which makes it easy to distribute a Boxen setup. However, as far as I could see, that uses Heroku. I didn’t really try it yet, but for now I opted to create a simple script which does the initial setup required for Boxen.

Some things we had to fix

We were still manipulating /etc/hosts file to actually get development domains point to your localhost. With Boxen it is relatively trivial to let everything ending in .dev point to your localmachine. This blogpost has a nice explaination on how to do this.

Conclusion

I have just started using Boxen on my own laptop and besides some testing in VM’s, it is not used yet to install fresh laptops (that will happen this week), so we don’t have much experience yet, but so far it looks very nice.

Java Date and Time API and JSR-310

Dutch version can be found at the Finalist IT Group weblog.

Since the start of the development of JDK 7, there is quite some discussion on the API’s in the standard Java libraries which covers date and time. In the current Java version (1.6) there are roughly three major (groups of) classes which are responsible for handling date and time: Date and Calendar, the formatting classes, and the classes in the java.sql package, including java.sql.Date, java.sql.Time and java.sql.Timestamp. Most developers agree that these classes are far from perfect.

In order to resolve this issue, JSR-310 is started to improve the date and time API in the standard Java libraries. However, due to lack of developers and slow progress, it became very uncertain if the JSR would be ready for inclusion in JDK 7 (which will eventually become Java 7, the name I will use in the rest of this article). JSR-310 is lead by Stephan Colebourne and Michael Nascimento Santos. Colebourne is the original author of the increasingly popular Joda Time project, which is a replacement for the default Java date and time API’s. At Devoxx 2009, taking place last November, Mark Reinhold of Sun announced that Java 7 will be delayed until September 2010 at the earliest. Stephan Colebourne sees this as a opportunity to release at least a partially complete JSR-310 in time for the upcoming Java release. Read the rest of this entry »

Encoding in Scala interpreter

One of the nice things of Scala is the availability of a command line interpreter based on the REPL principle (Read-evaluate-print loop). Last week, for a particular project, I wanted to generate a string containing a part of the UTF-8 character table.
Thanks to Scala’s concise syntax, this would not be very difficult:

(0x20AC until 0x20B6).foreach { x => print(x.toChar + " ") }

This example will print characters 0x20AC (euro symbol) up to 0x20B6 (an unknown symbol to me 🙂 ).

However, the result I got on my system (Mac OS X 10.6.2 using Scala 2.8 nightly) was not really what I expected:

? ? ? ? ? ? ? ? ? ?

Read the rest of this entry »

Update of Weblog

My weblog was not very active lately. Mostly, this is because I’m posting a lot on Twitter (in Dutch however) and post some articles on the weblog of the company I’m working for. Especially the post on Devoxx is an interesting read in my opinion.

However, I’m planning to change this. It is not that I don’t like writing, and in my experience, when I write an article on a specific subject, I have the habit of do some research on it which increase my knowledge on the subject on the go. I have some articles in draft and some others planned to write. With the new year approaching, increased writing sounds like a good intention for the upcoming year.

In order to mark this change, I’ve decided to change the look of my site a bit and add some additional features on it (especially a Mobypicture widget). The new look is not yet finished, but that will come over time.

My blog was hacked

So, if anybody is visiting this weblog (probably that aren’t many people anymore, partly because I didn’t post anything recently…) they definitely noticed that I was a victim of one of the many exploits that are available for WordPress weblogs. The frontpage looked alright, but if one tried to view a single post or clicked some random link on my weblog, the page didn’t work. Of course, I was running an old version of WordPress (2.5 actually…). Read the rest of this entry »

JDK 7: new developments

Java 7: new developments and rumours

As promised in my last post, I will write some more on the Java 7 developments. Since my last post, there are not that many new developments, but since I’m reading a bit more on the subject there are some things I want to mention here. Read the rest of this entry »

Java 7: new coffee

Last week, I wrote an article for our corporate weblog on the development of Java 7. Since the article was in Dutch, I didn’t post it on my personal blog. But I wanted to post some follow ups, and since it is not very easy to do this on the weblog of Finalist, I decided to translate the article to English and post it here. The translation is done pretty quickly, and thus very likely a bit rough on the edges. I think it is also interesting for non-Dutch readers. Read the rest of this entry »

Really amazing on YouTube

In my opinion, most of the stuff on YouTube is not very interesting. However, today I stumbled upon a post on Slashdot which contains a link to a really inspiring video created by somebody with a lot of time, but most of all, a very creative and musical mind. What he does, basically, is gathering music-related video’s from YouTube and edit them in such a way that a new song is created. You should watch some of these:

There are at least six others, just take a look here: http://www.youtube.com/user/kutiman. All the original video’s are linked as well.

New Safari 4 beta

Today Apple introduced the first beta version of Safari 4. While I didn’t read much about this new upcoming browser, I am really enthusiastic about the new features of this browser. I was waiting for Google Chrome to come to the Mac, since I really like lightweight browsers, but Safari made the waiting unnecessary. Read the rest of this entry »