Tag Archives: java

Trip Report: JavaZone 2018 🇳🇴

Hmm, too few posts. I definitely have to change this. In my defence I’ll say, that only for this summer I’ve visited 12 countries. But you will argue, that for example Josh Long (my hero) made 12 countries only for this week, and he still has written several blog posts for this time. And you a right, I’m too lazy, I have to post more often!

Finally I’m in the local Starbucks, my cappuccino is ready, looks like it’s a perfect time to remember one of the greatest adventures of this year so far – JavaZone 2018!

When earlier this year, in May, I have received this email telling me that my talk “Java and the GPU: unlock the massive performance” was accepted for this year’s edition of JavaZone in Oslo, Norway, I literally jumped out of mu chair shouting out “Yes!!!”.

Visiting this conference was definitely one of my dreams, I’ve heard so many good words about it! Now finally this dream came true. Huge thanks to the committee for accepting my talk!

Finally September has arrived, I’ve landed in Oslo and literally fell in love with Norway from the first site!

An express train brought me from the airport directly to the Oslo central station for only 19 minutes. You may ask – so what? Actually the airport is about ~60 km away from the city and we were cruising with more 220 km/h. And those trains are scheduled to make this route every 10 min. This so cool!

For this conf choosing the train was the best choice, as the venue – Spectrum arena is just next to the central station. The hotel was there as well. So we were perfectly located.

Oslo welcomed us with a grey rainy weather

But just 20 min later it was beautiful and sunny, like in every northern town

In the evening we were invited to the speakers dinner that took place in a beautifully located restaurant with some stunning views of Oslo!

Oh, thats Chris Thalinger also making some photos of this wonderful sunset. By the way it’s raining.

Definitely a wonderful place to relax before the conference. We stayed there until late.

The next day was the first day of the conference. The first thing I saw was the looooong queue of the attendees.

The good (or may be the bad) part was that my talk was scheduled on for the second day. So the first day I had a chance to explore a little bit.

The conference organisation, or I may even say “architecture” is totally different from all other conferences I have attended. The venue is a huge arena, where big concerts take place. There is a big central area where you can find a lot of software company’s booths.

 

Just take a look how big is it and how many people are in!

The conference kick-off was lovely with some guitar players

sdr

The coolest part is that practically all the booth serve their own food all day long! Yes, yes.. you can have food all the time, all day long.. all two days! There was only one major problem for me – I couldn’t taste it all! I haven’t had enough capacity! Definitely OMG.

But not only food, but tons of other cool activities

One of the unique features of JavaZone are the 8 parallel tracks. Yep, 8! That’s a lot! The rooms are themselves not very big, but that makes the cozy.

That’s me attending Vlad Mihalcea’s great talk.

And like every conference the main reward is actually meet and talk to people! Hey, that’s Chris (..and Doug)!

My good friends Simon, Simon, Phillip and my new friend Jennifer

Finally could meet Sharat Chander in person!

Awesome hardcore JVM company of Doug, Volker and Steve

The discussions we had were really useful to me!

At the end of the day we had a wonderful hangout with David, Vincent and Matthew

Then actually came the funny part. My talk was scheduled for 9.00 the next morning. I was sincerely wondering who will ever be interested in GPUs and massive parallel computation so early in the morning? I was a bit nervious wen my talk was approaching.

But I was ready!

So I was expecting a maximum audience of 3 people to show up. What was my surprise when I found my room fully packed!

Oh My God! Absolutely unexpected!

I sincerely want to thank everybody that came. I hope the talk useful and fun to you!

By the way, it became available just few hours later in vimeo! Cool organisation at JavaZone!

When I was done with my talk I took the chance to hang around the beautiful city of Oslo!

Definitely a beautiful capital!

JavaZone 2018 was a great new experience for me! I’ve seen a cool organisation, met great friends and made great ones!

I want to say huge thanks to Rafael, Rustam, Mark and all the team for having me and making this conf a blast!

At the end as always my best five IMHO sessions of the conf from those I was able to see myself live:

Now I’m on may way watching the other talks I’ve missed (and those I’m able to understand)! They are just great!!!

So good bye Oslo! Thank you for being awesome! Hope to see you again!

 

 

Java as a technology glue, or how to use GPU from JavaScript

Ah! It’s been a while since I’ve posted the last time!

But this year was quite a DE(VOXX)ED for me! First I had a chance to speak in wonderful Romania, then beautiful Vienna, after that amazing Lugano, then the loveliest Krakow, finally at the huge Antwerp event! In between I also gave some talks in my home towns Sofia –Java2Days and St. Petersburg – Joker! Let’s not forget that I was in the dreamteam of 5 to organize and run the coolest jPrime conf!

Quite an intense year!!!

So finally this weekend I had some time just to play. Of course play with coding!

As may be some of you saw, I’m really interested in the Nashorn engine to run JavaScript on JVM. I gave once some talks about it!

But not only this bothers me! For several years I’m interested in General Purpose computations on Video Cards (GPGPU)! I even gave some introductory talks on how to use GPU and Java together.

On Devoxx in English:

https://www.youtube.com/watch?v=BjdYRtL6qjg

And on Joker in Russian will be hopefully available soon 🙂

But! What will happen if actually unite these two my passions? How to run some code on the GPU but submitted from.. JavaScript!!!

You will say just use WebCL! But, isn’t it a little bit not ready yet? And as far as I know it is not exactly a full binding to OpenCL but mainly browser oriented stuff. Please correct me if I’m wrong. I’ve even played with some experimental drafts.

What if I want to utilize the full control of our computations on GPU through JS and make it very dynamic?

Yes, yes!! Nashorn is here to help us! And yes, we have the full power of the available bindings like those provided by JOCL!

So let’s do it! The usual example with vector add will be just cool enough!

That’s the JavaScript code:

I just put it all in jscl.js file.

As you in the beginning I’ve added some type definition shortcuts just to make code look more readable.

To run it in the console I just put:

JJS is available by default if you have minimum Java 8 installed.

The JOCL jar you can just get from their site.

And what we have (on my Mac):

Isn’t this lovely!!

Funny fact that is that because of the memory latency it about 700 ms no matter if I make 1k computations or 100m of them 🙂

Still, this may be good example of how Java/JVM can be a kind of a technology glue. Having in mind that there are more than 40 languages running on JVM, all of them can benefit from the de facto standard libraries already available for Java.

This is so much cool!! Have Fun!

Thoughts on Enterprise

I’ve always considered myself a Spring guy. I mean, it’s so cool to code with Spring! Spring is quite honestly the essence of the modern Java enterprise! It has everything for building an amazing, modern, scalable web application. The most of the routines are highly automated there. Just with few annotations you can convert some crappy POJOa into a real world working webapp. And it will work, it will scale, it will be testable! At some moment it came to a point that it’s not even required to implement some methods. Just annotate a method and Spring will read the method signature and implement the method for you! I believe that in the future you will just write something like:

You may lough, but just go to http://start.spring.io/ and it’s quite near to the idea above. Btw, it will be a cool idea to create a DSL to “talk to Spring”. I always liked and still like coding with Spring!

And then… suddenly, a disaster happened!

I had to start to work on a pure Java EE project! Oh no!

My first reaction was like: well, at least I will be paid for that.

At that period Java EE was considered as something big, outdated, sluggish.. at some parts even retro, with all the negative in this word. And my reaction was predictable since I had some “nice” experience with EJB 2. Yes, yes – EJB 2.0! Remember all this remote interfaces, local interfaces etc, etc. But after that I never touched it again. Good for me!

From several conferences I came to a feeling that Java EE just copies everything from Spring, and renames some of the annotations. And I said to myself – actually, that’s a huge plus for me! I just need to write @Inject instead of @Autowire.

So I’ve started the project and what was my first surprise? Of course it came out of maven. The pom file was really small.

And not more than 3-4 other small dependencies like Primefaces. And that’s ok! You have everything on board. And you don’t have to care about every API you use and every realization of that API etc etc. Unless you want to spoil everything, or, in other words, optimize.

And all of these ugly EJB 2.0 stuff is no more there. Everything is very nice and pure! Again with some annotations you convert your POJOs into beautiful enterprise webapp! Java EE is AWESOME!

So everything is standardized. And that rulez everything. In theory I don’t have to think about on what platform my WAR runs, it should demonstrate the same output every time I call something from my app. Realizing this was like OMG! So now we can develop one app and not think much of what dependencies to include. Take the app and drop it on every server supporting the current profile of Java EE. And we can make almost the same stuff as Spring does. Or I would say the really essential part of it with not so much sugar. Exactly – standards are the true essence of the common functionality widely used in the industry at its best! Damn! I’m in love! From now on I’m a Java EE definite fan! And always will be!

And I have discovered the power of the @EJB annotation!

So I’ve started digging in and then I faced some real life.

The first thing that blocked me was the … you are right – configuration! Every server is configured in its own way!!! So I can’t just drop my app and and make it work, I have to configure some datasources, security and many other stuff. Oh.. so now I have to ship my app with bunch of configs… a little bit disappointing. Still, I don’t have to ship my app with tons of custom libraries, or even with the server itself where it is all set up.

Then some other issues came like one with JAAS. So JBoss/Wildfly and TomEE they both support it but in some slightly different ways.. so in my code I had to put some ifs and see on which platform does the app actually run and call appropriate custom method.

Then the other issue came. The Primefaces upload worked gracefully on TomEE and didn’t even show up on Wildfly. With some insane magic I found out that if I remove the upload filter in web.xml the situation will switch to the opposite – it will work on Wildfly and stop working on TomEE. And that was predictable since at that point they used different versions of Mojarra..

So.. In theory I had to ship different web.xml files. But, that’s so much NOT beautiful! I spent one night almost in tears as I was unable to find a nice solution. But after some beer an in genius solution came to my head – create a server “on start listener” and fix all missing “on the fly”. That was so brilliant that the next night I didn’t sleep as well since I was drunk in the bar. I couldn’t withstand and put some other server depended config there. But that were just two other small things.

And what about the performance and the resources consumption? Surprisingly, the average memory consumption of this app written with Java EE 7. I was expecting something like several gigs, but it was only about 250 Mb RAM on TomEE with about 100 users connected. Not bad at all!!! I have even packed it as single executable jar with TomEE and uploaded on some of the cheap cloud providers. It performed great! Beautiful!

Btw. This app that I’ve written had to make some of Batch activities. And guess what? I didn’t even have to put any additional dependency in my maven or reinvent the wheel, since JBatch was already there in that Java EE provided dependency. I just used it! That’s so cool!

So Java EE can rule them all! In some cases, definitely yes, especially when your tasks are standard enough. And I may say, that from my decade in this branch the most of the tasks are quite standard. With really few deviations.

And what about Spring? With Spring you can do the same and sometimes more (and I wonder if it can do less). Yes, there are some differences in the “philosophy”, but it is obvious that many of the coolest ideas now available in Java EE actually came from Spring, or were deeply influenced by Spring. If there is a request to build something with very narrow Time-To-Market frame, I think I’ll first think about Spring, especially Spring Boot. There I can put some piece of code into real world production within just two hours. Although this can easily be done with TomEE or Payara as well. There are so many things available out of the box, like security, data, MVC, even batches! Batch is one of the examples how a Spring solution inspired the creation of a JSR-352. Btw now it’s the opposite – Spring Batch conforms the standard. It already supports the JBatch job declaration.

So they both do the same? Here is one small thing, rarely discussed. Spring is a proprietor solution. It’s a full ecosystem driven by one company, with a lot of open source efforts included. Still the evolution decision process is a bit different there.

So isn’t Oracle doing the same? I personally think that it has tried to do the same, but they couldn’t. Actually the Java EE standard evolution and support is driven by the Java Community Process. And unlike Spring Java EE is a standard, not a product. At the moment a discussion about Java EE end of life emerged the community and EE vendors started a campaign against those predictions. The well-known Java EE Guardians were formed, with a great support from the community and James Gosling himself. Four big Java EE middleware vendors have even started a common effort for creation of a fraction of the Java EE suitable for optimal microservices operation called Microprofile.io. And its fully community driven and open. The guys standing behind this initiative are really amazing! Truly passionate professionals that do care!

So Spring and Java EE are both comparable and incomparable. And I believe they both serve their needs, although in many areas they are overlapping.

I prefer even not to compare them but there is one thing we developers quite often forget – the financial part of the story. As written in the Adam Bien’s post Spring has its very clear support policy – upgrade or pay for the support. This once played some bad story for us. We have started the project with one version of Spring and somewhere in the middle a new version of it was released with some of the interfaces deprecated. This caused us some delays as we were dealing with updating our code. Still their corporate support is really awesome.

In terms of Java EE, it kind of moves this question to hierarchically lower level – to vendors that do implement this standard has their own support strategies. But the good thing is that they have to correspond to the standard, and the standard does not change too often. On the other side not all the issues can be solved entirely by some standard portable code. At some moment it comes to the point of “no turning away” when it’s necessary to switch to some, for example, underlying API provider specific optimizations. And the portability of the code declines drastically. But you still are not fully tied to one and only proprietor support, and switching it is much less painful. Btw. this question about equalizing of some of the parameters arose at the Microprofile.io multivendor session on the latest Devoxx.

So it’s a tricky question what is better. The answer is though very easy: well, it depends! It’s not always about the technology. A clear knowledge of how your app will perform and evolve can have more impact than just choosing the latest and the trendiest technology.

But if we take the just the technology itself, in my humble opinion Java EE and Spring are doing a great synergy together and move the Enterprise Java forward!