Sunday, January 22, 2017

Twitterfeed #4

Welcome to the fourth issue of my Twitterfeed. I'm still quite irregular on posting the links. But here are some interesting articles that I think are worth sharing.

News, announces and releases

Atlassian aquired Trello. OMG! I mean... happy for Trello founders. I just hope that the product would remain as good as it was.

Docker 1.13 was released. Using compose-files to deploy swarm mode services is really cool! The new monitoring and build improvements are handy. Also Docker is now AWS and Azure-ready, which is awesome!

Kotlin 1.1 beta was published with a number of interesting new features. I have mixed feelings, however. For instance, I really find type aliases an awesome feature, but the definition keyword, "typealias", feels too verbose. Just "alias" would have been much nicer.
Meanwhile, Kotlin support was announced for Spring 5. I think this is great - Kotlin suppot in the major frameworks will definitely help the adoption.

Is there anyone using Eclipse? [trollface] Buildship 2.0 for Eclipse is available, go grab it! :)

Resonating articles

RethinkDB: Why we failed. Probably the best post-mortem that I have ever read. You will notice a strange kvetch at first about the tough market and how noone wants to pay. But then reading forward the author honestly lists what was really wrong. Sad that it didn't take off, it was a great project.

The Dark Path - probably the most contradicting blog post I've read recently. Robert Martin takes his word on Swift and Kotlin. A lot of people, the proponents of strong typing, reacted to this blog post immediately. "Types are tests!", they said. However, I felt like Uncle Bob just wrote this articles to repeat his point about tests: "it doesn't matter if your programming language strongly typed or not, you should write tests". No one would disagree with this statement, I believe. However, the followup article was just strange: "I consider the static typing of Swift and Kotlin to have swung too far in the statically type-checked direction." OMG, really!? Did Robert see Scala or Haskell? Or Idris? IMO, Swift and Kotlin hit the sweet spot in regards to type system that would actually _help_ the developers without getting in the way. Quite a disappointing read, I have to say..

Java 9

JDK 9 is feature complete. Those are great news. Now, it would be nice to see how will the ecosystem survive with all the issues related to reflective access. Workarounds exist, but there should be a proper solution without such hacks. Jigsaw caused a lot of concerns here and there but the bet is that in the long run, the benefits will outweigh the inconveniences.


The JVM is not that heavy
15 tricks for every web dev
Synchronized decorators
Code review as a gateway
How to build a minimal JVM container with Docker and Alpine Linux
Lagom, the monolith killer
Reactive Streams and the weird case of backpressure
Closures don’t mean mutability.
How do I keep my git fork up to date?

Predictions for 2017

Since it is the beginning of 2017, it is trendy to make predictions for the trends of the upcoming year. Here are some prediction by the industry thought leaders:

Adam Bien’s 2017 predictions
Simon Ritter’s 2017 predictions
Ted Neward’s 2017 predictions

Wednesday, December 28, 2016

Twitterfeed #3

Welcome to the third issue of my Twitterfeed. Over two weeks since the last post I've accumulated a good share of links to the news and blog posts, so it is a good time "flush the buffer".

Let's start with something more fundamental than just the news about frameworks and programming languages. "A tale of four memory caches" is a nice explanation of how browser caching works. Awesome read, nice visuals, useful takeaways. Go read it!

Machine Learning seems is becoming more and more popular. So here's a nicely structured knowledge-base at your convenience: "Top-down learning path: Machine Learning for Software Engineers".

Next, let's see what's new about all the reactive buzz. The trend is highly popular so I've collected a few links to the blog posts about RxJava and related.

First, "RxJava for easy concurrency and backpressure" is my own writeup about the beauty of the RxJava for a complex problem like backpressure combined with concurrent task scheduling.

Dávid Karnok published benchmark results for the different reactive libraries.

"Refactoring to Reactive - Anatomy of a JDBC migration" explains how reactive approach can be introduced incrementally into the legacy applications.

The reactive approach is also suitable for the Internet of Things area. So here's the article about Vert.x being used for IoT world.

IoT is actually not only about the devices but also about the cloud. Arun Gupta published a nice write up about using the AWS IoT Button with AWS Lambda and Couchbase. Looks pretty cool!

Now onto the news related to my favourite programming tool, IntelliJ IDEA!

IntelliJ IDEA 2017.1 EAP has started! Nice, but I'm not amused. Who needs those emojis anyway?! I hope IDEA developers will find something more useful in the bug tracker to fix and improve.

Andrey Cheptsov experiments with code folding in IntelliJ IDEA. The Advanced Expressions Folding plugin is available for download - give it a try!

Claus Ibsen announced that the work has started on Apache Camel IntelliJ plugin.

Since we are at the news about IntelliJ IDEA, I think it makes sense to see what's up with Kotlin as well. Kotlin 1.0.6 has been released, which is the new bugfix and tooling update. Seems like Kotlin is getting more popularity and people try to use it in conjunction with popular frameworks like Spring Boot and Vaadin.

Looks like too many links already so I'll stop here. I should start posting those more often :)

Monday, December 5, 2016

Twitterfeed #2

So this is the second issue of my Twitterfeed, the news that I noticed in Twitter. Much more sophisticated compared to the first post, but still no structure and no definite periodicity.


Java Annotated Monthly - December 2016. Nice collection of articles about Java 9, Java 8, libraries and frameworks, etc. With this, my Twitterfeed is now officially meta! 😃

RebelLabs published Java Generics cheat sheet. Print it out and put at the wall in your office!

Server side rendering with Spring and React. Interesting approach to UI rendering with React. Some parts of the UI are rendered at the server side, and some data is then rendered at the client side.

One year as a Developer Advocate. Vlad Mihalcea reflects on his achievements from the first year in the role of a Developer Advocate for Hibernate. Well done!

IDEA 2016.2 Icon Pack. IDEA 2016.3 update came with the new icons and some people don’t really like those. There is now a plugin to replace the new icons with the old icons. Enjoy!

Oh, and talking about IntelliJ IDEA, there is another great blog post related to 2016.3 release. Alasdair Nottingham writes about Liberty loos applications support in IDEA: Faster application development with IntelliJ IDEA 2016.3

Reactive programming vs Reactive systems. Jonas Boner and Viktor Klang make it clear, what is the difference between the two. "Messages have a clear (single) destination, while events are facts for others to observe".

Good Programmers Write Bug-Free Code, Don’t They? Yegor Bugayenko has a good point about the relation of good programming to a bug-free code.

Cyclops Java by Example: N-Queens. A coding kata for N-Queens problem using "cyclop's for-comprehensions".

Zero downtime deployment with the database. The name says it all.

RxJava 2.0 interview with David Karnok about the major release. Here comes support for Reactive Streams specification!

Reactor by Example. Reactor is very similar to RxJava, but it is also in the core of Spring Framework’s 5.0 reactive programming model.

An explanation of the different types of performance testing. I think this is quite important to make the difference.


Spec-ulation by Rich Hickey. As usual, must watch!

Microservices evolution: how to break your monolithic database. Microservices are becoming mainstream, it seems. So we need best practices for building microservices based systems.

Tuesday, November 22, 2016

Twitterfeed #1

Twitterfeed is the collection of news that I find via Twitter. I have no particular system or a method on how do I pick the news. Neither do I have a predefined period for grouping the news. It is neither daily or weekly or monthly - it is all just random. Enjoy! :)

Java 10 is now officially a project
IntelliJ IDEA 2016.3, my favourite IDE, was released!!! Yay!
CLion 2016.3, a IDE for C/C++ development was released
Rider, a new IDE for .NET is now publicly available via EAP
Akka 2.4.14 was released
Ceylon 1.3.1 was released
Fedora 25 was released

Heinz Kabutz teaches how to implement our own ArrayList in less than 10 minutes
Martin Kleppmann talks about conflict resolution for eventual consistency
Yegor Bugayenko rants about software architects
Roland Kuhn writes about understanding distribution

Wednesday, May 18, 2016

Hello World with JBoss Modules

JBoss Modules is quite an interesting project that powers JBoss application server and some other projects in JBoss ecosystem. However, I was surprised to find out that there isn't much you can find about Modules on the webs. Documentation is... bad half-done, not that many tutorials, no good examples of how you could use this awesome library in your project. The best you can find is the description on how to apply JBoss Modules within the application server. (sad panda)

I was looking for the simplest "Hello World" example and couldn't find it. Well, why not create one myself then? 

Downloading JBoss Modules

A surprising fact is that you won't find JBoss Modules in the list of upstream projects at jboss.orgThe first option is to download the jboss-modules.jar from Bintray or Maven Central. And the second option is to build it from sources

Oh, ok, one more option (not the best one) is to download the application server that includes jboss-modules.jar, e.g. WildFly.

Hello World

Ahh, the good old "Hello World" :) The main application class is as follows:

public class Main {
  public static void main(String[] args) {
     new Hello().say();

So we have a dependency, the Hello class, that will reside in a different module:

public class Hello {
  public void say(){

So to mimic the modules we first have to compile both classes and assemble corresponding JARs. Plus, a proper directory layout is expected by JBoss Modules to resolve the artefacts.

Main class belongs to 'app' module, and Hello class belongs to 'hello' module. Each module requires module.xml descriptor. This part is somewhat documented actually. Also the 'main' directory that you see within each module's directory structure is actually a version (!). 
A version slot identifier is an arbitrary string; thus one can use just about any system they wish for organization.  If not otherwise specified, the version slot identifier defaults to "main".
Here's the module.xml for the app module:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.5" name="app">
  <main-class name="Main"/>

    <resource-root path="main.jar"/>

        <module name="hello"/>

It specifies the main class (i.e. Main), the reference to the actual JAR that will be used in this module's classpath, and a dependency - the 'hello' module.

Same module.xml for the 'hello' module:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.5" name="hello">
    <resource-root path="hello.jar"/>

Voila! Now we can execute our brand new modular "Hello World" app:

> java -jar jboss-modules-1.5.1.Final.jar -mp mods app

The format for the command is as follows. First, java -jar jboss-modules.jar is used to bootstrap the environment; -mp mods, and the 'app' parameter is the name of the application module that should be executed.

This example isn't really practical, but at least it gives a hint on how to get started with JBoss Modules. Hopefully, one day, the documentation for this awesome project will be complete and there will be a bit more tutorials for different the use cases.

Friday, February 12, 2016

HotSwap vs hot deploy

It is the year 2016 and one still has to explain that HotSwap and hot deploy in Java IDEs is not the same thing.

Stackoverflow is full of questions about avoiding restarts of Java applications. So of the answers suggests that “Eclipse can update code without restarting the application” or “IntelliJ IDEA can hot update running applications” or “NetBeans automatically updates running code in debugger”. But the ultimate solution for this problem is JRebel, of course.

UPD: You can also read about various solutions to the redeployment problem in my Stackoverflow answer.

One fundamental thing that people don’t understand is that it is not even the capability of an IDE to be able to update applications. The IDE is just a medium -- it only triggers the update, and then the runtime environment is the one responsible for updating the code.

Repeat after me

HotSwap and Hot deploy is not the same thing!

What is HotSwap?

HotSwap (тм) is the technology in HotSpot JVM that is tailored at updating class definitions at runtime. Most importantly, "HotSwap adds functionality to the Java Platform Debugger Architecture (JPDA) to allow a class to be updated while under the control of a debugger”.

So when it comes to IDEs, once an application is started in a debug mode, the IDE can trigger class redefinition in a running JVM by utilizing JPDA.

If you are interested in the intimate details of HotSwap, read the “Safe class and data evolution in large and long-lived java applications” paper by M. Dmitriev.

It is important to understand the limitations of HotSwap: it is limited only to updating statements of code inside methods. Can’t change method signatures, can’t add new methods, fields, etc. Some JVM implementations are able to do a bit more. For instance, with IBM J9 JVM it is possible to add new methods to an existing class. Nevertheless, HotSwap capabilities are minimal. A JEP for enhanced class redefinition has been submitted long ago, and even a research project was sponsored by Oracle, but no further progress was made.

The bottom line here is that HotSwap is not a feature of an IDE, it is the ability of a JVM that you use.

What is hot deploy?

Hot deploy is the ability of application container to automatically deploy (web) applications at the startup. Obviously, the same feature can be applied to re-deploy the applications without restarting the JVM process.

Hot deploy is not a feature in any of the IDEs either. IDEs can only trigger (re)deployment of an application by either copying the artefacts to a correct location, or by using hooks if provided by the application server. So this is totally application server specific - this is what server adapters are for! It requires the IDE to be aware of the application server specifics, hence some people affiliate this functionality to their IDE.

Redeploying the application drops its state. Sometimes, application server can serialize/deserialize HTTP session state, but that's about it, not more. It can't preserve the state of the structures inside the application; internal caches have to be warmed up; framework internals have to be reinitialized, etc. The process is time consuming.

Application servers rely on class loader magic to redeploy applications. You can read about it in details in ZeroTurnaround’s blog.


Make sure you use the terms correctly -- 'HotSwap' and 'hot deploy' is not the same thing! You may other terms, like 'hot update' -- then make sure to ask, what does the person actually means by this, because the devil is in the details.

Thursday, December 10, 2015

Another great Java interview question: Singleton

I'm not a big fan to ask to write code at the interviews. But I still find it useful to do some coding exercises at the whiteboard. One of my favourites is the Singleton pattern. Because Singleton is so simple, you can use it as a starter for so many interesting discussions.

it often comes down to the discussions about the Singleton being lazy or eager. And while it leads to the discussion about Java Memory Model, it's not the most interesting one. No one understands Java Memory Model anyway :)

BTW, did you know that a single-element enum type is the best way to implement a Singleton?

Yes! And you can't imagine how many people do fail with this. If you deploy 2 web applications with the same Singleton class, will there be two instances of the same Singleton or one? Of course, there isn't one true answer for this question - you have to ask the details. The the answer depends much on how the class is loaded. If the class is packaged within the WARs, then you get 2 instances of the Singleton.

This is why Singleton is such a great interview question - it opens a lot of topics for further discussion!

Saturday, November 21, 2015


I have been interviewing candidates for Java developer jobs for a full decade at this point. I have tried various approaches for the interviews: various tests about language and the APIs, whiteboard programming, bug hunting, homework assessments, etc. There is no best approach for the interviews - it merely depends on the expectations, candidate background, position, day of the week, weather, whatever else.

Despite all the details, I’ve found one interview question that works like a charm. It is almost the best question to start with. And it is quite efficient in filtering the candidates early enough if have to screen a lot of candidates.

Here’ it is:

What is the different between final, finally & finalize?

How is this even a question, you would ask? Asking about the difference of the things that cannot be compared!? Well, apparently, a lot of developers can't make a clear difference. Those who don’t - you just don’t have to interview them further :)

OK, you asked this and candidate answered this brilliantly, now what? Well, I did tell you that it is a very good question to start with, didn’t I? Next, you can take it to any direction of your choice:

  • final - you may take the discussion to Reflection API, for instance. Or you can discuss how the final keyword helps with concurrent programming in Java.
  • finally - talk more about the exceptions in Java and discuss some puzzles. Like the one below. What does it print?
  • finalize - the discussion about finalize() method is only useful to validate the nerd level of the candidate. Usually you’d check why one shouldn't use finalize() in first place. Maybe some rare candidate can tell about legitimate uses of finalize(). This most likely shows that he or she remembers what is written in Item 7 from Effective Java.

I hope you get my point now, why this strange question is a very good one for the Java interviews. Have fun!

Thursday, July 23, 2015

I will be speaking at JavaOne 2015

I'll be speaking at JavaOne this year again! This time I have 2 talks accepted:

CON3597 - Having Fun with Javassist. This is merely a live coding session where I demonstrate various uses of the Javassist library for Java bytecode manipulation. I've delivered this talk multiple times and every time it is different as it turns out quite interactive and attendees usually ask questions right in the middle of the talk so I have to adjust the content as I go. Usually it's quite fun, so I enjoy presenting this talk.

CON6699 - What's the Best IDE for Java EE? I'm not sure how this one turns out - it's so much to talk about and so little time. I'll be presenting this talk along with Max Rydahl Andersen and Adam Bien. This time we're focusing solely on Java EE. Basically - it's and overview of what's available for Java EE users in Eclipse, NetBeans IDE, and IntelliJ IDEA.

Both the talks can be found in the content catalogue for JavaOne.

Friday, July 10, 2015

GeekOut 2015: CompletableFuture

The talk by Tomasz Nurkiewicz about CompletableFuture was rated the highest at GeekOut this year. This is really interesting API that appeared in Java 8

A Future that may be explicitly completed (setting its value and status), and may be used as a CompletionStage, supporting dependent functions and actions that trigger upon its completion.

Tomasz Nurkiewicz - CompletableFuture in Java 8, asynchronous processing done right. from Official ZeroTurnaround Account on Vimeo.

Some time ago Tomasz published a really nice series of articles at his blog - worth reading!

Java 8: Definitive guide to CompletableFuture
Java 8: CompletableFuture in action

And there's more!

Disqus for Code Impossible