I just recently stumbled across this interesting presentation from Ben Christensen, a Software Engineer in Netflix. Netflix has developed an interesting approach to create a high performance and scalable system. This approach gives Java capability of Functional Programming, before Java 8 with Lambda support went public. They call it ReactiveJava, or RxJava for short. RxJava is a library for creating event-based application, using technique called Observable pattern. More detailed informations are available on their site or their github repo.

I just started learning this, and all I can say is RxJava is a very interesting library. It will take some time to learn (or adopt), but resources below I found very helpful.

  1. Ben Chistensen’s video presentation at GOTO Conferences.
  2. Russel Elledge’s Course about Reactive Programming using Java 8.
  3. Leo Campbell’s Book: Introduction to Rx.

Weird Bug in Chrome

I would like to tell a story about the newest thing I found related web development. We are currently building an integrated system for promotions and coupons related. The system consists of an Android client, a RESTFul API Server module, and a Content Management System (CMS) module. We use Jboss Wildfly 8 as our Application server, running on top the Java 8. We love Java 8’s functional capability, but I will save the details on the other post.

So the problem started after we are doing deployment into our production environment. Some users send bug reports about the problem in login process. After doing some thorough investigation, we found that we missed redirect tag used in Shiro authentication. Adding those missing tags,compiled new binary and done! Our modules are updated in production server.

Our users then perform their usual activities. The login problem apparently has been addressed with our latest fix, so we continued the development process. After a couple of minutes, a new bug report came in. And the bug is very weird. Some users using Google Chrome browser, experiencing some oddities interacting with our CMS. Several users report that they need to click submit button twice before they can login. The problem did not stop there, they said that our system kicked them out after just clicking some menu.

Our first approach is examining our server’s log, to find root cause of this problem. After doing some testing, we found that the server was performing just fine. Our authentication system responds in the correct manner. Based on our experiences, this could means one thing, the problem is on the client’s (browser) side. We then prepared several browser in different conditions, trying to reproduce the weird bug. After doing some tests, we find that only Google Chrome browser has this problem. Any other browser does not have this problem, which is weird, since Chrome has a good reputation related with web technology standards.

Since we have not experienced this problem before, we immediately went back into our first hunch, that the problem is mostly located in the server side. We did quick comparison our current production environment configuration with our development and staging environment, to find differences that could lead to this problem. We found that the only differences between our environment is that our production use nginx’s virtual host heavily. Again, this kind of approach deserves another blog post. So, we splitted our development team into two, the one with backend specialties will investigate our current nginx configuration, whilst our frontend gurus will perform debugging in the browser side.

This scenario was effective, our backend team can easily confirm that our nginx is not having any faulty configuration that cause that problem. So, we can put our focus into frontend debugging. As usual, some queries sent to Google leads us into several StackOverflows discussions, but nothing giving us clear answer about this problem. We fired up the firebug toolbar, and examined what interactions actually happens.

I have to admit, we approached this problem in not efficient way, since by using Firebug, we easily figured out why our user has to click Submit button twice. We found that Chrome is trying to load a favicon file, which does not exist in our newest build. We immediately put our favicon into assets folder and put appropriate code to load it. One engineer is curious and query google with favicon and login keyword leads into interesting StackOverflow discussion at http://stackoverflow.com/questions/8880592/chrome-and-jsessionid. We then went to that discussion in details and found an answer. Finally, somebody had a problem like us in the past and solved it!.

Apparently, Chrome and other WebKit-based browser use different approach in handling pages with redirect. Chrome creates two separate JSESSIONID cookies, first time is when our login form appeared, and one after successful login. Since the content of JSESSIONID has been updated, any further request marked as invalid and system forces user to login again. Following the lead, then we examined our code and put our favicon into proper place. We build new version, deployed them and the problem was gone.

This problem was hard and weird. We spent hours in confusion, but in the end of the day, we went home with new knowledge. This information will be very useful in the future, to help us build a better application.

Keyboard Cover for iPad

Today I bought a new accessory for my iPad, a Bluetooth keyboard. I chose Logitech Ultrathin Cover for iPad Air. Mainly because it is very thin (as the name sung), and it has a very good keyboard keys.

I read reviews in some sites and they are pointing this keyboard keys configuration as the main advantages of this keyboard. Many other keyboard cover tries too hard, they had some extra keys for mimicking the iPad touch screen function, but it makes the button smaller and harder to type on. I don’t want those to happen. I just want a keyboard for my iPad so I can write faster and become more productive than using virtual keyboard.

Eventhough the box said that it was made special for the latest iPad, I have been using it in my original iPad (as like now) and my iPhone, both of them can connect without any hassle. The only quirk I got though is I am not certain that my keyboard is connected, because the indicator lamp sometimes goes off.

So why a keyboard cover? Basicly, I want to use my iPad in a more productive manner. I want to use it as my development machine as well my blogging environment. The latest iPad Air, with 64-bit capability is more than capable for doing some bacis stuff and with so many new productivity apps out there, I just want to try them on.

The other advantages of using keyboard cover, especially on iOS 7, is the keyboard shortcut support. In some application, such as Byword, which I use for writing this blog post, you can use shortcut like CMD+B for creating bold text easily. This capability is very helpful and gives you feel that the iPad can finally replace your laptop.

Lesson from Good Book

Good Reading

“The more that you read, the more things you will know. The more that you learn, the more places you’ll go.”
– Dr. Seuss, I Can Read With My Eyes Shut!

I just finished reading a great book, titled Dogfight: How Apple and Google Went to War and Started a Revolution. This book mainly told us about fight between Apple and Google, how each of them spent enormous resource and time to innovate, and how their innovation moves the world further than they can ever imagine. You will find the inside stories about the creation of the legendary iPhone and its mortal enemy, the green robot Android.

This post is not going to give you spoilers about the content, since I think it is the best for you to read by yourself. The stories are well written by well-known Wired Journalist, who has special access to some Apple and Google employees. You can feel the tension between them, which makes this book so great in my opinion.

One thing that I can take from this book is, it requires a great amount of passion and hard work to create a truly innovative product. The iPhone and Android was revolutionary product, they are born from years of banging heads into the wall, screaming about endless problems, and cursing about the future. You have to spend a lot of nigths working overtime, weekends in the office, forgetting your anniversary, and perhaps absent from your children’s birthday party. The worst part is, to keep this in complete secret. You might have solve one of the biggest problem in the history of human kind, but you can’t share this, because the future is on your shoulder. Only when you outcome those kind of things, you will, at the end, can give yourself a pat on the back, saying you have done a great job.

I have met some people who demands reward before fulfilling their obligations. They felt that their ideas are so revolutionary, the company must reward them big time. The hard truth is, ideas are cheap. Throwing ideas are great, but building the idea is the crucial one.

Other lesson is coming from Steve Jobs:

You know, one of the things that really hurt Apple was after I left John Sculley got a very serious disease. It’s the disease of thinking that a really great idea is 90 percent of the work. And if you just tell all these other people “here’s this great idea,” then of course they can go off and make it happen. And the problem with that is that there’s just a tremendous amount of craftsmanship in between a great idea and a great product. […]

Good Coding Standard

This week Apple released a critical update on their mobile operating system, iOS for fixing an error in their implementation their SSL. Some people is starting to do some research about Apple’s libssl implementation. By looking at source code, they found an interesting part of code, which lead to the bug. You can see the detail in the image below.

Apple libSSL implementation

One thing to take away from this accident is the importance of having good coding standards. Using tools like Sonar Qube or Checkstyle, you can perform inspection to your code to see which part unsuitable with the coding standard defined. I must admit that sometimes, having a coding standard is a pain, but it will forestall the future incident like Apple had. You can combine previous tools with Findbugs. Findbugs will perform some analysis to find possible bug in your code. You can run those tools via your IDEs or command line tools. By applying this practice, I find we can evade unnecessary work in the future, and can spend time to truly developing next enhancement for our services.

– Fin

Learning Clojure

One of many remarks that I took from Computer Science world in 2013 is the rise of Functional Programming. After years of doubt about its performance comparing the other Programming Paradigm, Functional Programming (FP) finally took its place when most of big players choose to implement FP language in order to handle big data traffic and doing real-time data processing. Scala, has enjoyed the hall of fame in last 2 (two) years, by helping Twitter building their services. Twitter makes some crucial libraries in Scala, and it has been proven that Scala can handle big data better than other programming language, i.e Java or Ruby.

I myself feel very thankful for my almamater for teaching us FP in older days. We learnt Haskell in our Foundation of Programming classes, gave us headaches, because it worked very differently from Java, the first programming language we learnt. One thing that I remembered that FP is helping me to understand the principal of recursion. The recursion code in FP is way more clearer and easier to understand than the Java companion code. But again, we left Haskell in the dust and use Java for the nex assignments until now.

After reading some successful stories about FP implementation, I decided to jump into the same bandwagon. I chose to implement our project at work to get a view about developing Services using FP. To give a brief overview, our current Service built around Java with some Ruby and Python here and there. We use RESTFul to communicate within our modules, and it uses PosgreSQL and some NoSQL databases to store the different kind of data. Based on these circumstances, I think this Project will be very fun to develop using FP.

In 2013, some new FP language finally take the spotlight, giving us another option beside Scala. Don’t get me wrong, I think Scala is great, but the language is very complex. I am looking for more simple approach for FP language, but still can run in Java Virtual Machine (JVM) like Scala. There are some alternatives like Clojure, Groovy and the future, Java 8. The main reason to use JVM-based FP language because it let us to use Java’s 3rd-party library in the FP way. We can reuse the libraries and modules, so we can keep the destruction minimal.

Between Clojure and Groovy, I finally pick Clojure as my next adventure. Clojure has many advantages, as describe in here [1]. Clojure is the most interesting language between the three. It use LISP dialect, where it is so uncommon nowadays.

The next step is to find the good resource to learn Clojure, after doing some Google Search, I found 2 (two) books. The first book is Clojure Programming by Chas Emerick, Brian Carper and Christophe Grand. By reading this book, you will get familiar with Clojure syntax and its capabilities.

The other book is The Joy of Clojure by Michael Fogus and Chris Houser. This book is not for newbie in Clojure. It contains some advanced technique in Clojure that not really easy to understand by beginner programmer.

The other resource for learning Clojure that I’ve found useful is Leiningen. Leiningen is the maven for Clojure, but with much more capabilities. Other than managing your project dependencies, such as libraries and modules, Leiningen also provide a REPL for Clojure. This is the biggest winning feature for me. By issuing lein repl command, I got a full Clojure environment and I can start coding right away. This is the most missing feature from Java IMHO.

At then moment, I am still familiarizing myself with the syntax and patterns, and I hope in the short time I can start my experiment and share the result.

– Fin

  1. http://www.quora.com/Clojure/Why-would-someone-learn-Clojure “Clojure: Why would someone learn Clojure”  ↩