We work and we play. Read about both here.

Web applications developed in popular open source web technologies like Ruby on Rails, Django, or one of the many PHP or JAVA frameworks have a natural fit with Linux web servers. As the features of a web application grow and are optimized for speed and scalability, the dependency on Linux grows due to additional services (e.g. memcached) and platform specific third party libraries. Because of this natural relationship, one's development environment tends to lean towards Linux or Mac OS X (due to OS X being a UNIX kernel and supports dang near everything). Add in to the mix the requirement of running OS X to develop iOS apps, and I think Mac has a major edge in this market. Anyone observing the laptops used by the presenters and attendees at a conference like The Strange Loop would not disagree with me. This brings me to the topic of this article. How do I go about developing these same web applications in a Windows development environment, which does not seem to have a natural fit to many of these open source technologies? Many of these technologies do have Windows support for a development environment, but it fails the "have a development environment that closely matches production" test.

Various software used in the setup

I have been developing web applications just under two years now, and my road to a good development environment has been very bumpy. Prior to developing web applications, I was an embedded systems developer at a big corporation, and Visual Studio was where I spent most of my time. Due to a good friend's persistence I was finally convinced to work at Red Nova Labs. Since day one, I have been on my quest for a good development environment, and that quest still continues; in fact I am often teased about the frequency with which I change my setup.

Attempt 1 - The Dummy Terminal (PHP)

The Dummy Terminal way of developing is where all your computer does is provide Input, Output and Networking to connect to a Linux server (often an EC2 or Rackspace cloud server). The tools of this method are PuTTY/KiTTY, WinSCP and Notepad++ (optional if you are not VIM savvy). While this might seem completely strange to some, it is actually not a horrible development environment. In fact, it is quite popular to the remote peer programming group (wherever and whoever they are). Along with the ability to share an environment, it is an exact copy of your setup. If you choose to go the VIM route, you will experience some lag in your typing but it is usable. If you choose to use WinSCP with Notepad++ as your text editor you get to use a fairly good text editor and WinSCP is pretty snappy at uploading your file quickly when you save your document.

The disadvantages to this environment are search, cost, speed and absolute dependency on network. The cost of this environment is pretty negligible for new applications, but if your application gets decent in size and you work off a copy of your production database, you may find yourself spending more money than you want on a development environment. When developing a web application, you tend to turn off caching, so on top of the lag of uploading your source code on save you will also have some slowdown when viewing your changes in a browser. While the speed is bad in some ways it does have some advantages if interacting with other Amazon AWS services.

The major killer for The Dummy Terminal method is search. I am not a haxor at VIM and I don't really care to be. Grep is fine, but having to alt-tab to switch between Notepad++ and terminal is a deal breaker to me. Add in the other disadvantages and I quickly abandoned this method.

Attempt 2 - NetBeans + Dummy Terminal (PHP)

This method is very similar to The Dummy Terminal, but the only difference is you're using NetBeans with a local copy of your repository. NetBeans PHP has a superb SFTP plugin that uploads all changes to your repository server automatically with great support for PHP/HTML/JS. While this method fixes the search problem it gives you the additional problem of having to manage two copies of your repository so your local files match your remote files. While NetBeans is pretty good at keeping files in sync, it is not perfect. All in all, this method was quite good, and I used it for about a year.

The main killer for NetBeans + Dummy Terminal was the dependency on PHP. NetBeans Python and Ruby plugins are community supported only, and Java has no concept of SFTP to work remotely. When I started developing Python, JAVA and Ruby, I had to abandon NetBeans.

Attempt 3 - Linux (Python, JAVA, Rails, PHP from now on)

This was my favorite method, and I was very happy and at home here, but this article is not about Linux development environments. My main complaint was a good text editor. NetBeans was a fail for Python/Ruby, so I found myself regretfully using Eclipse.

Major disadvantages: font rendering on web browser (kind of important if you want to keep your design team happy), multiple monitor support, laptop support in general.

Interlude

One day when I was grouchy about using Eclipse, someone told me all the cool kids where using Sublime Text 2. I have searched far and wide for a good text editor and ran across Sublime Text 2 many times, but had always disregarded it pretty quickly because it was not free and I did not think it could be all that good. Because I did not like Eclipse and because I trust the opinion of the person who told me about Sublime Text 2, I gave it a go and have never looked back.

Attempt 4 - Mac

This was fine. If I had never gone to Linux I would likely be happy here today. Red Nova Labs spent a truck load of money on my Mac Book Pro with Retina display, and after taking a week getting used to the environment (and missing apt-get greatly) I was completely underwhelmed. There were a few issues that I could have overlooked, but I just liked my Linux environment better.

Attempt 5 - Linux

I was home again, but I did need a laptop upgrade; we were spending a lot of money for big EC2 development servers for our biggest application, so we decided to use VM's on our new fancy computer hardware to save on servers costs. My boss said I should just do Windows + VM because of the screen and browser issues running Linux.

Attempt 6 - Windows + VM Bliss (almost)

This environment is a hybrid environment with an almost symbiotic relationship between Windows and the VM. Here how it is configured:

Virtual Box Setup

VBoxHeadlessTray Menu

  • VM has a NAT network card plus host-only network card on same subnet as virtual network device installed by VirtualBox.

    auto eth0 iface eth0 inet dhcp

    auto eth2 iface eth2 inet static address 192.168.56.10 netmask 255.255.255.0 network 192.168.56.0 broadcast 192.168.56.255

  • Use SSH key-based authentication and install pageant shortcut that auto loads on startup.

  • Install Samba and give full root access over it so I can mount network drive to VM and effortlessly configure and modify files on the Linux server.

    [all] comment = Ubuntu File Server Share path = / browsable = ye guest ok = ye read only = n force user = root force group = root create mask = 0644

  • Use Windows hosts file to make access simple and effortless.

  • Depending on the application I am developing I can increase/reduce memory/CPU easily.

  • Using a PowerShell script, I am able to mount my virtual hard drives over Windows file sharing. The reason to do this over just "reconnect at login" is because Windows will try to reconnect at login before VBoxHeadlessTray starts up and restores the state of the VM.

    $ip = "192.168.56.10" $share = "all" do {sleep -m 500} until (Test-Connection $ip -Quiet -Count 2) net use L: \$ip\$share /P:No net use W: \$ip\www /P:No

  • By installing the Virtualbox Guest Additions I am able to keep the VM clock in better sync. This is needed for connecting to services like Chef or AWS that will deny you access if your clock is too out of date. Every now and then I have to manually sync the clock (/usr/sbin/ntpdate pool.ntp.org).

Additional advantages include the ability to completely turn it off and have full resources for laptop (or turn off to increase battery life so I can browse the web or write a blog post without draining battery). You also get good web browser fonts, multiple monitor support and good hardware support. Lastly, development environment is dang near identical to production environment.

One caveat that I do not have a full answer for is search performance (and disk performance in general). At first I was happy with search, but when I started working on some larger projects I noticed it was taking a little long. To solve this I switch between developing over Samba share and using a Sublime SFTP plugin (similar to NetBeans + Dummy Terminal method), but that comes with some disadvantages of its own. With Sublime 3 (currently in Beta), I am able to use the GoTo definition and reduce the amount of searches I perform, which helps a lot. That is why I tag this method "almost" ideal.

Where do I go from here?

There is nothing special about my setup. Tons of people use VM for various purposes and I certainly did not create VBoxHeadlessTray. The only thing that might be unique is my blatant disregard for Linux security measures. The reason for this is because it is a VM after all, and by disregarding security it is more an extension of your Windows environment.

One thing to note: this level of VM for development is still likely better in Mac OS X or Linux because you can use NFS instead of Samba, and permissions will transfer better between the Host and Guest. It could also be that using Hyper-V or VMware has better disk performance, but for now I am content.

The moral of the story is that you can have a perfectly acceptable dev environment with Windows if that is what you have or prefer.