blog.nirav.name
Nirav's Contemplations: December 2010
http://blog.nirav.name/2010_12_01_archive.html
Thoughts on Programming, Software and Open Source. Monday, December 13, 2010. Tackling nulls the functional way. Most programmers have suffered null pointer one way or other - usually a core-dump followed by a segmentation fault on development machine or on a production box with application in smokes. NullPointerException results in a visible embarrassment of not thinking about "that something *could be* null". The paradigm of null fits well in database but not in programming model. Having Nulls in your ...
blog.nirav.name
Nirav's Contemplations: March 2011
http://blog.nirav.name/2011_03_01_archive.html
Thoughts on Programming, Software and Open Source. Monday, March 07, 2011. Why Concurrency is hard. At this point enthusiasts will point out java.util.concurrent. And move on. While j.u.concurrent is nice and a significant improvement over explicit synchronization, it still mandates that API users be concurrency wizards and its complexity exposure is nearly at par with explicit synchronization. Here's one example blog post. Explaining common gotcha with ConcurrentHashMap. V x = atomicRef.get();. Are the ...
blog.nirav.name
Nirav's Contemplations: December 2013
http://blog.nirav.name/2013_12_01_archive.html
Thoughts on Programming, Software and Open Source. Monday, December 16, 2013. Interesting use-case for SynchronousQueue. While working on a very unusual system, where: 1) producers. From Java's util.concurrent. If I was looking at SynchronousQueue. Without the above context, I would have wondered why would anyone need a queue that's not really a queue. Behind the scenes, it uses dual-stack/queue algorithm. Depending on ordering fairness preference) to transfer a reference between threads. Null){ LOCK....
blog.nirav.name
Nirav's Contemplations: MySQL Insert performance and random primary key values
http://blog.nirav.name/2014/04/mysql-insert-performance-and-random.html
Thoughts on Programming, Software and Open Source. Monday, April 14, 2014. MySQL Insert performance and random primary key values. It's been almost a year since I've been putting up with MySQL and its bizarre performance characteristics and lack of choices on index data structures. If it wasn't for the volume and velocity of data we're storing in it, I would have proposed to ditch it by now. MySQL with InnoDB struggles. The only solution that has worked satisfactorily for me so far is to add an AUTO INCR...
blog.nirav.name
Nirav's Contemplations: March 2012
http://blog.nirav.name/2012_03_01_archive.html
Thoughts on Programming, Software and Open Source. Monday, March 05, 2012. On Static v/s Dynamic typing. I've been pondering about trivialities again, I am observing how most programmers have strong vested interest in defending static v/s dynamic. Typing as if they are mutually exclusive. And not worrying about compilation or runtime errors, it mostly ran. Then I was introduced to C (and later C ) and I remember how I hated it because I was now forced to declare variables and had to think about what I wa...
blog.nirav.name
Nirav's Contemplations: February 2015
http://blog.nirav.name/2015_02_01_archive.html
Thoughts on Programming, Software and Open Source. Tuesday, February 10, 2015. A simple rate limiter using Java's DelayQueue. It is rare for me to develop at this level of use case but recently we had to manage a bit of work-load with limited resources that lead to a simplified and light-weight rate limiter using Java's concurrent additions. Is pretty good but I didn't want to include a (fat) dependency on guava just for one class so I wrote a variant based on Java's DelayQueue. Links to this post. View ...
blog.nirav.name
Nirav's Contemplations: October 2011
http://blog.nirav.name/2011_10_01_archive.html
Thoughts on Programming, Software and Open Source. Monday, October 24, 2011. On using "PermGen" as application level cache. I was reading an interesting article ' Assualt by GC. Guy and it felt like a Déjà vu with my past couple of years of development on the JVM. It struck to me that we can definitely do better, so here it goes. One way to eliminate GC on predictable "tenured" application data is to just not store it on JVM heap (i.e. use direct byte buffer. Most of the java developers I know consider "...
blog.nirav.name
Nirav's Contemplations: November 2011
http://blog.nirav.name/2011_11_01_archive.html
Thoughts on Programming, Software and Open Source. Thursday, November 24, 2011. Optimizing string memory footprint in Java - Part 1. This is first in a series of blog posts where I will try to describe my miserable attempts at storing large amount of strings to build efficient spell correction and auto-suggest facility in Java. I learned some important lessons doing this and it will be a waste if I didn't share it. So here it goes. As well as IBM's J9. It has to store length of each array which is anothe...
blog.nirav.name
Nirav's Contemplations: December 2011
http://blog.nirav.name/2011_12_01_archive.html
Thoughts on Programming, Software and Open Source. Monday, December 05, 2011. Avoid storing references of java.net.URL. Normally, I avoid writing something so obvious but since I'm bitten multiple times now, it might help future me. References of java.net.URL in Java collections. The reasoning is pretty simple, 'equals' and 'hashCode' methods of this class does extremely expensive synchronous DNS lookup on every. It is not uncommon to see most of your thread's time being spent on monitors:. At java.n...
blog.nirav.name
Nirav's Contemplations: May 2012
http://blog.nirav.name/2012_05_01_archive.html
Thoughts on Programming, Software and Open Source. Tuesday, May 15, 2012. Achieving Decoupling: Dependency Injection v/s Event driven design. Update: A more exhaustive sequel post is in progress on this topic so don't be disappointed by lack of details and stay tuned). Is considered to be a bad sign in a software design, having seen enough of it in practice I agree with this belief. The need for decoupling has resulted in a cottage industry of IoC. When I was learning object oriented software design.