Node.js on the Road: Our Tale from Java to Node.js

Node.js on the Road is an event series aimed at sharing Node.js production user stories with the broader community. Watch for key learnings, benefits, and patterns around deploying Node.js.

Luca Maraschi, Architect at Icemobile, talks about their move from Java to Node.js.

Luca Maraschi Architect

I'm not a designer by the way. So I try to take you into a tale, to a small story, I hope it's not a goodnight story that you still are awake at the end, so I try to be very short, I'm very famous for long story. I try to keep it in 20 minutes, it's a promise. So well, who am I? I'm just Luca, Italian as you can imagine. I'm working as an architect and I lead all the Node.js stack in IceMobile, I'm a SmartOS lover, although we're not using it yet and I do have feelings for Node.js from deep of my heart because I come from Ruby, so I can share the pain of that path. I'm working for IceMobile that is a kind of famous Dutch agency. We created the famous [xx] the ABN Amro Bank here, so my Dutch is very bad.

Then we got acquired by Brand Loyalty, a big loyalty company around the world, and recently we got a big deal from ADS and we just got all acquired in a big multi-national and stock traded company. And what we do every day is try to bring digital to the loyalty programs, so I don't know if you've ever been to a supermarket but when I was a kid, not shorter because I was always this height, but I was much younger and I remember collecting all the stamps to get a pen, whatever things that you can find in a supermarket, and actually what we are doing we are removing you the pain of having the paper stamp that you always lose by the way, and put it on your iPhone or your Android and soon on the web. And as kind of a big reward we just started to one and half year ago to bring this digital to the loyalty world, and we just won an award a couple of weeks ago in London as Best Loyalty Program in the world with our Russian customer.

So the company
always placed as an agency values around design. That's where we won most of our awards, and we create some principles that are really important to understand this story. So you need to focus on people.

Magic happen at the intersection.

We are always open to change we need to change fast, we need to keep stuff very simple and we do epic shit. That's our motto, I hope we do.

So when when I joined the company one and a half year ago, I was coming from start-ups and small companies. And I found this beautiful stack that everybody who works in a start-up can recognize, because you definitely want to have oracle Linux in your start-up, because it brings up very cheap licence of Oracle WebLogic.

Where you can easily put your beautiful Java stack, that you want actually to support with a strong backen in J2E, and definitely come on, seriously you just want an Oracle database, because it's good for enterprise, because you have to imagine that we interface with supermarkets, so people were bleeding-edge technology—well, they don't even know what it is, because they still think Oracle is bleeding edge.

And so this one was the stack that I found in front of my eyes. I found Camp, that I didn't know until few months ago what it was. It's a load balancer, kind of nginx you need to pay a licence, and we are a mobile client that connects with. So I said no OK, come on seriously, we need to do something different, I need to introduce something green there, there's too much blue. So I said well, definitely we need something more agile, much simpler, much easier, faster.

Because after just three weeks that I was in the company, I was already the worst enemy of all the Java developers over there. And I said well guys seriously, if a designer wants to see something he's going take almost a millennium to get it done. So when some designers, you know designers are very good because they think and illustrate on Photoshop they're converted into code and they're still thinking about that.

They really do believe in that, and unfortunately it's not reality and what we always say is well to build the module or to build a customization is going to take some time because, well we need to bootstrap the project every time and we don't have a lot of PHD people in the company, so well we said you need a PHD sorry a Masters is not enough. And I said OK guys seriously WebLogic. I mean, I come from Microsoft IIS, I went to WebLogic and I said, OK you really want very better yourself, you really want to make your days nightmares.

So well the thing that I had in front of my eyes was this picture. Seriously, I felt like if I was in a ritual every time, and every time was the same repetitive pattern over and over and over again. So I said, OK well I think we can make a change. [xx] I suggest to watch it. There's a nice scene after but I could not put it in the presentation.

Unfortunately our
story never ended that way, but that's how it actually ended, because we had our digital spring frame work running all our APIs where all the POS system are connecting, so where we have our PCI compliant bank and so on and so forth but that's the difference. I had to speed up the animation otherwise we would stay until tomorrow. And I said, guys I don't want to make any arguments I want to make it very factual because there are a lot of emotion, I love Node.js. So you know, when you are in love you are crazy, you don't rationalize anymore. And then I said, OK well seven lines versus three files. Do we have to make any further?

And well, but we are still a Java developer with a lot of experience with a lot of knowledge that they can bring to us. So we needed to find an approach that was lean, fast, modern. So we said well we are going to start to proxy all the Java API in Node.js. Nice job. IT said Camp can do the same, and I said yes, but we try to build something at scalable. I don't want to scale camp I want to scale my application on the cloud.

We redesigned completely our architecture from scratch. I mean, we didn't make a lot of sense against the Node.js philosophy, and well we needed to make a lot of of mentoring to our Devops, so we start to work together with them, because they were used to that. This jar file called Java -r with whatever package and run it, or WebLogic does the magic. I still wonder how. So well this one is actually where I left you before and I said, well we need to change very fast because otherwise Node.js is becoming as old as Java, so we need to speed up and that's actually what is happening as I'm speaking now. I hope people are really working in this moment, and this one is what we are going to actually move towards.

So we remove Oracle Linux because we don't have to pay a license of WebLogic anymore. We tried to run Node.js in WebLogic, it was not successful by the way. We still have license, so let's use them. And we said OK, we are going to make this kind of micro services architecture with a lot of services behind still our Camp, and we are going to remove the Oracle database because the PCI compliance is just kind of bullshit that enterprise put in front of everything because you can be PCI compliant on Amazon without any problem. Also Joyent.

So at the end of this journey that is taking us almost nine months—it's like a baby. We still don't know the sex, but we know one thing. We discover very fast that Java developers, they need a transition phase to Node. Js because they usually try to create 25 layers before making a freaking call to the database.

So we need to remove the ritual. That's the most important thing, and well that one is taking a little bit of time. People are learning fast, so one of my recommendations is help them in this journey. It's not easy because they are coming from building 25 layers to building only one, so is a big transition for them.

And one of the things I was more surprised, I would dedicate ten slides to it, is that I discovered that—I come from .net, so Visual Studio for me is heaven. The Java developers, they love their IntelliJ, or they love their Eclipse, and their Netbeans or whatever, and so they love IDE; and when you put them in front of Vim, or Sublime Text, or Atom, or whatever editor you're using, they are just lost because they say how can I re-factor.

And then when they discover that on Mac command-shift-F allows you to search and with the H to replace everything, it's a kind of big discovery because they are used to click the with the mouse (the thing that you usually get with your computer) with the right click and say re-factor, but it doesn't exist in Vim yet. And one thing that I always have to face as an architect is that when I was presenting all the architecture, they look crazy to everybody because best practices they were missing.

That's what's missing. You Google something for .net (so let's not hit on Java too much) .net and you'll find MSDN, MSDN brings you every kind of examples that you can find on the planet. And then you go into Node.js and you find Stack Overflow, you know where people put a beautiful green tick when something is good, but you never know if is really good or not until you try it.

And they say I need practices. I need books about that. And I said, well just go and Google for free. Just use your imagination. So one of the things that we use in our company is to create a JavaScript guidelines. We enforce guidelines through jshint as I git commit and git push hook. We're using <span class="STsearchMatch">editor.config</span> to avoid discussion about two, three, four, five, six, n number of spaces for a tab. I mean it was more a lottery than deciding on what, and that's actually the practices we need to build in, we're using for example the Airbnb guidelines, and that's what I usually print and give to freshmen, when they join the company. I say well read the guidelines of Airbnb, and I was telling the joke before to the guys, and I said well most of the people they tell me, but why are you following that guideline?

And I said well when you make them billions with your own company and you create your own guidelines come back because I'm interested, but until Airbnb—you cannot beat them, I think they have enough budget to invest on something, well they are pretty good. And one thing that is pretty difficult and I personally find still difficult everyday is to create a development work flow.

So what is missing in Node.js nowadays I think is to create a development process that is uniform across all developers around the world. So when you join for example, I take again .net, you have Team Foundation Server that has all the ALM processes inside that makes your development process on heaven, it is actually on hell, but you feel like in jail. But people they want it, and it is good for their transition. So one thing that you need to figure it out is how to push into the head of people with this one is the process that you are going to use. Good luck.

And, so we are actually working only with enterprise. You know, supermarket usually they don't have fancy data centers, they don't have internet by the way also I discover, and you integrate with something—it was very funny. It was one of our customer in the East of the world, and we had to integrate with TIBCO. I don't know if any, who knows TIBCO ESB?

Sorry that you know it, because they have their own protocol, but they can expose everything it's like going on WebSphere. So one of the things that they told me, the java engineers, they said yeah but I can import the wsdl, and I can just generate classes in my Java project, and I said well, you have a point. Maybe we should also remove SOAP. But unfortunately they are not happy when you tell them this thing.

And well we hack a little bit, and we found Node SOAP, it's a great library and actually one of our engineer made some fixes to that, now it finally works. So just use it, it's a suggestion and don't try to do something that we try to use handlebars to generate request, because you're going to actually kind of fail. Because you're seeing that they don't change the wsdl but actually they send you a wsdl per day.

I don't know how they can do it even.

So this
one is our stack. We have chef. Remember we're in food retail, so we want to stay bonded with the food. We're using Jenkins Jenkins is our masters of puppets, it's doing everything basically. We are also building front end stuff, so you find Ember, Bower. We're using nginx to serve all of our static content until we don't go on the Cloud, and like I told you we use editor.config use it is an insane way to uniform the way your developers are using editors. Use jshint. Enforce it. So just use a beautiful package called Hosky, you can enforce all this commit. But at the end, something was missing, because we are using a lot of open source technology, but we're not actually actively contributing to the Node.js code base. Sorry TJ. I promise you to do it. I'm going to make a change in the readme so I contribute.

So, well I said to the company, guys seriously, we're getting so many things for free. I [xx] do ut des. It means give to give back. And well we decided to open source five our libraries. Actually three of them they are not really for Node.js, but they're actually all our client-side libraries, and we decided OK, well we move from express to restify, because we are creating API. And what we decided to do, we decided to build our own library. I know, we don't want to reinvent the will but we have serious principle to solve.

Restify is a fantastic library, use it. It does integrated dtrace and is going to help you, if you remember to name your function. Otherwise well good luck. But we said, OK well we built tons of business logic, we customize for our retailer, we need to move fast, we need to be leaner. So we decided to build our own library, it's called Virgilio. So for anybody that's familiar with the Divine Comedy, it's the guide of Dante from the Hell to Paradise, so you get the joke, right?

And we decided to take purely functional approach, so don't expect to have classes or these kinds of things. Remember it's still JavaScript. It is insanely modular, so where everything is a module. And, well, one of our principles is that it has to be minimal, so we don't have the 80 column restriction because that one is too lame. Everybody does it.

We just say it has to be not more than, for example 200 lines of code, that's our goal. And it has to be hackable. I mean I don't want really—for me if it takes more than one day to build a feature on top of it OK, build it in spring, because anyhow you're going back into a ritual.

So we're
also hiring. We are also inviting you to fork our libraries and to contribute to them, because Virgilio is really awesome. Try it out, give us feedback and, well, I wish you good luck if you're transitioning from whatever language to Node.js. But it will be a very fun journey, so good luck. Feel free to contact me if you want some suggestion, and I also do psychological support for people migrating from Java to Node.js or whatever.


Sign up now for Instant Cloud Access Get Started