Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I see a few developers that like to use virtual machines for web development. Are there others that do this? If there are, why do you do it? Are there any pros / cons to developing on a VM rather than in a non virtualised environment?

I would think things are slower in a VM.

share|improve this question

closed as primarily opinion-based by gnat, GlenH7, MichaelT, thorsten müller, Kilian Foth Oct 7 '13 at 11:43

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Besides virtualization, there's also image-based systems like Squeak and Pharo (a squeak derivative). –  Jesse Millikan Feb 15 '11 at 7:53
    
@Jesse Millikan I'm not sure what you mean. Isn't Squeak and Pharo a programming language? I'm trying to understand how they relate to virtual machines. –  7wp Jun 18 '12 at 15:57

10 Answers 10

up vote 19 down vote accepted

I use VMs for IE testing. I do have a dedicated Windows machine, but I lean towards using VMs for a few reasons:

  • It's a hassle to switch computers, even if it's right next to you
  • It's extremely easy to rollback a VM to have a clean testing environment
  • I'd rather use an environment users are actually going to use rather than kludges like IETester, and you generally can't run multiple versions of IE at the same time.
  • It's cheaper to run multiple VM instances than it is to buy multiple testing computers
  • VMs, at least the ones for Mac OS X, have gotten so good in the past couple of years that the "slow" stigma given to VMs is unwarranted.
share|improve this answer
2  
VM's are fine speedwise, but only if you have the spare memory to support one properly. –  Matthew Scharley Sep 16 '10 at 21:00
    
@Matthew: Yeah, but most computers these days come with 4GB standard, and for a web developer, that's enough to run at least one (if not two) VMs simultaneously. –  user8 Sep 16 '10 at 21:10

The other reason people use a VM for web development is to virtualise a server environment that they can turn off really easily.

At home I always use a VM for setting up personal projects so that I can turn it all off completely when I want to, say, play a game. In a work environment you might want to turn it off so that you have full resources to transcode a video to FLV.

It just gives you that flexibility to do what you want with your resources.

share|improve this answer

I prefer to use VMs for pretty much all development... especially when I'm working with a team of developers. VMs allow me to build an "environment in a box" that can be quickly set-up with little headache. Since I use a MBP as my primary machine, I prefer VMWare... it's a lot less painful especially in a "mostly-Windows" environment.

As far as speed is concerned, it honestly varies from setup to setup. The only real issues I've seen with VM speed involve a.) not having enough physical resources (memory, etc.) or b.) not allocating enough resources to your VM. Otherwise, I actually prefer working in a Windows VM on my Mac than working on a native box.

share|improve this answer

Testing environments is a big one as others have mentioned.

  • browser testing (ie, safari, etc,...)
  • clean testing environment
  • easy to have multiple configurations
  • accessibility testing (screen readers and the like)

I have a VM strictly for profiling and debugging my code which has kcachegrind already setup, along with selenium, xdebug and a few other tools configured to easily profile and debug my code. Yes some may say this is what a development environment already would be but personally I like having a VM on my desktop dedicated to this sort of task.

Also, regarding the slowness in a VM:

Things are slower in a VM because of the overhead requires to "virtualize" the environment. However, the VM is becoming closer and closer to the hypervisor which lessens the overhead required for the VM.

share|improve this answer

I use virtual machines all the time. For testing purposes, the reasoning is obvious, but I also use it for my actual development environment, mainly because 1) it makes migration to new hardware a no-brainer, and 2) it gives me an easy "snapshot" (or set of snapshots) fall back to as needed for those configurations of my development environment. My needs may be unique -- I am primarily a Delphi developer using multiple versions of Delphi, and lots of third-party components -- but the amount of time and headache having my development environment inside of a virtual machine has saved, probably could not be overstated.

That said, don't scrimp on the box you run them on, especially when it comes to memory. ; )

share|improve this answer

This is a late answer. I agree with all the points in the accepted answer, but I wanted to add that I use VMs exclusively for Web development, and not just for testing. I'm on an iMac using VirtualBox to run Windows, Fedora, and Ubuntu -- sometimes all at once. I don't have any problems with performance.

I prefer working this way because I work for customers running both Fedora and Ubuntu servers and it allows me to closely match the development environment with the production environment. It also makes me a better systems administrator in the areas that are most important from a development standpoint.

share|improve this answer

Have found using VMs a good way of keeping a client-specific development setup.

In a past consultancy company, Devs knew that firing up a specific VM meant you had a working environment for developing/testing and deploying the software we supported for that client. Particularly useful when supporting some real oddball systems.

For new apps, you'd have the latest and greatest setup on your main Dev machine. But what about when you need to bugfix some old VB6 app that your company still supports. Fancy installing Visual Studio 6 on your lovely clean VS2010 machine? I don't think so!

Also meant it was pretty easy for any Dev to support any client.

share|improve this answer

I've certainly used virtual machines for testing websites, but not for writing code in.

The benefit of virtual machines is that you can have different OS's and browsers set up, to test the inevitable css bugs you'll discover in IE6 / 7 / 8.

share|improve this answer

I don't see a reason to develop websites in a virtual machine, there isn't a need for it for a Windows user.

You can run everything in a Windows install (Portable IEs, Chrome, Firefox, Safari, ...),
alternatively you could use Expression SuperPreview to enter a new world of cross-browser testing.

share|improve this answer
    
Things like Portable IE, Expression SuperPreview, IETester are, for all intents and purposes, virtualized environments. You're not actually running a real-world copy of older versions of IE, and in the case of things like SuperPreview and IETester, you don't even have access to the browser chrome or plugin architecture. Beyond IE, you don't have access to other OS's versions of the same browsers. For example, Safari on Mac OS X has features that don't exist on Safari for Windows, and Chrome for Mac generally lags behind Chrome for Windows. –  user8 Sep 16 '10 at 21:14
    
No, no, no! Portable IE, Expression SuperPreview, IETester run native on your system, there is no virtualization involved. You are running a real-world copy that has been adjusted to run in the current environment and has the same behavior... There is no need to have access to the browser chrome or plugin architecture when web developing. For Safari, extra features are again irrelevant to cross-browser web development. For Chrome, versions can be used simultaneous... If one really needs to test each browser version on each OS version there is browsershots.org for that purpose. –  Tom Wijsman Sep 16 '10 at 21:40
    
Try testing integration with multiple versions of Office. VMs are still amazingly handy to have. –  davewasthere Sep 19 '10 at 16:36
    
@davewasthere: And how is Office related to Web Development? I'm sure VMs have their use for various things, but for web development you are fine without it... Even multiple version of Office and Visual Studio can be installed together without a VM, but indeed, there are limits and tradeoffs where you really need a VM. –  Tom Wijsman Sep 19 '10 at 21:16
    
@TomWij - I've got one client with an intranet application in ASP.Net that integrates with Word. Since they use multiple versions of Office, it's nice to be able to have an image with each version installed. I know it's possible to side-by-side Office and IE. But in reality I find it a pain. VMs just seem a lot cleaner/easier... –  davewasthere Sep 26 '10 at 22:10

I use a virtual machine to map subdomains of virtualbox.me (I own the domain) to subdirectories of a folder on my host machine shared to the guest.

With this setup, I just create a new directory and immediately have a new project under it's own subdomain, i.e. /home/pete/virtualwww/my-super-project maps to http://my-super-project.virtualbox.me/

I've written up guide for replicating this (it uses mod_vhost_alias and VirtualDocumentRoot) here:

http://otaqui.com/blog/1652/setting-up-a-virtualbox-virtual-machine-for-web-development-with-multiple-sites-using-mod_vhost_alias-and-virtualdocumentroot/

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.