Tuesday, June 4, 2013

Why Use A Virtual Machine For Development?

As web developers sometimes we have a tendency to take the path of no resistance. See I went straight past least all the way to "no". Sometimes this is ok, others times not so much. One such area I have seen this happen in many times would be a development environment. I am no stranger to doing some of the worst possible things known to development. Editing on production, not using source control, etc. The list goes on for a very long time.

One of the common practices I see many developers do, that I think makes no sense, is using their development machine as the environment for development. If you are asking yourself right now "Why is that so bad?". Please, for the love of all that is good and wholesome in this world, do not stop reading!

Let's start with some of the reasons why having an *AMP stack on your computer would not be the most horrible thing in the world.


  • You don't really care about specifics you just want to run some test code. 
  • You are throwing together some crappy prototype that you know won't actually be used by anyone besides yourself.
  • The guy you are interviewing seems to think that a case statement doesn't need a break in order to stop executing.
  • Any other reason where the code will either be deleted, actually moved into a proper development environment before more than a few hundred lines of code has been produced, or no one will ever see this code besides you.

That is about the only reasons I can come up with to install your *AMP stack on your computer. Any other reasons I will immediately chalk up to laziness or not giving 2 shits about your craft. 


So what is so bad about a *AMP stack on your work computer?

You are locked into that specific environment. Is your code really going to be pushed to a production server that is running Windows 95/98/98SE/ME/2000/XP/7/8 and WAMP? If it is, well you have bigger problems and I don't mind if you stop reading now and continue to cry softly into your pillow at night. For those of you who are getting smug right about now because you run some flavor of linux, hold that smirk for a bit, I will get to you.

Do you work on a team? Is everyone running the exact same craptacular OS you are? Are they running all the same extensions as you? How many times have you needed to say "It works on my machine"? If any of those sound familiar to you, you are making this harder than it needs to be.

Haha, I run linux, I am immune! Not so fast bash master. So you're running Ubuntu, is your production box also running that? Same everything? I mean nothing could possibly be different. Surely you are not installing anything or compiling anything even remotely different from any other environment in your deployment process right?

So here's the deal. If you are doing this. You are causing yourself headaches or just waiting around for a headache to occur. It is not a question of if. This is definitely a when situation. Someone is bound to use a newer version of some part of your stack. Someone is definitely going to have an OS that ignores case for file names. When this gets pushed to QA you are now wasting their time running down bugs that could have been very easily avoided. Do you really have the time for this?

What can a VM development environment do for you?

Most important and really this reason alone is enough to do it. Consistency! By establishing a VM with the same specs as your other environments you can rest assured that if the code runs on the VM, it will run on all the other environments. Sure you will have other problems that a VM can't solve. Out of date data sets. Not updating your code. Bad configurations. All sorts of problems. You won't be hunting down that weird extension that Joe forgot to install though. Let's face it those are the worst kinds of things to debug usually.

How would you like to be running 2 completely different stacks on the same machine? How about 3 or 4 or 5 or 20? Want to experiment with all the new hotness that is in the newest version of your favorite database engine? Thinking about making an upgrade to your version of PHP and want to see how badly it breaks your application? Easy, fire up a new VM with whatever configuration you want and go to town. Bounce back and forth between that environment and your stable development environment with ease.

You get the ability to share with others. This would make your mother proud. By establishing a base VM you can now easily give others an environment to utilize to do work on that won't differ from yours. Making everyones life easier.

By abstracting your stack into it's own little isolated environment you get flexibility to have endless environments. Or at least as many as your poor little development computer can handle.

1 comment:

  1. Hi Chad Robertson ..
    i have read your blog "Why Use A Virtual Machine For Development?"you are good solution give of this question .
    Resistance-free Development

    ReplyDelete