Open Source Interdependency

Several months ago I was talking with some Java developers who were being forced to move onto PHP.  They were actually quite open to the idea but had some questions.  One of them was on how you would set up a page counter.  In the Java world what you would do is define a static property within a class, synchronize it, and increment it for each page that hit the site.  In my explanation I went through the myriad of ways that you could do that, probably confusing them even more.

I had thought about it for a while after that discussion and it hit me.  My answers were not wrong, but the way I communicated them was.  In the Java world you tend to look to language answers for problems like that.  Then for much more complex problems you tend to look for software solutions from a given vendor.  In PHP, it's done a little differently.  Rather than add a bunch more features into the language, we tend to depend very highly on third party software to handle problems that might seem more basic for more "enterprisey" languages.

For the problem of the page counter, rather than throwing it into an object, you'd throw it into the database.  Rather than using threads, you might use Gearman or something like Zend Server.  In other words, DRY (Don't Repeat Yourself) is huge in the open source world.  It's almost more DRA (Don't Repeat Anything).  If someone, somewhere in the world, has written it, you should be contributing to that project, not writing yet another library. 

If you have ever compiled software on Linux you actually have experienced what I'm talking about.  The first thing you do is type ./configure and it goes through a litany of different header and library files making sure that you have all that you need.  You see this to a lesser extent with Linux and package managers.  Yum or apt do a good job of hiding the compilation hell, but you still do see a lot of needs for dependencies.

One of the things that I really love about open source is not that you can change the code, or that you can see the code, but that you get many more details about what your application is doing.  The desktop platforms have a strength in that you install something and it just works (supposedly).  But what did they install?  What are the gotchas that their certain version has?  You really don't have nearly the same level of insight into what's going on.  Some people like that.  Some people would rather expect a vendor to provide a big ball of software that solves all their problems.

I can understand the position, but I really like knowing about a dependency.  Why?  Because if there's a bug that needs to be fixed you are only updating one piece of software.  Granted, it could also end up breaking others, but that has very seldom been my experience.

So in the end, if you are ever talking to Java developers who are being told to move to PHP and they ask how you would build a page counter, just tell them that with PHP, and most other open source programs, the goal is to re-use other people's software wherever your code does not provide the functionality needed.  So, if you need a page counter, ask yourself "who else has done this and how can I get their code".

Leave a Reply

Your email address will not be published.