Skip to main content

Deals You Can't Miss

1 Year Subscription

WSL For Development In Windows 10 Is The New Kool-Aid

I had been a happy-go Java developer on Windows platform. And then I had to ride the Ruby-on-Rails wave over Linux platform, only to realize how much I didn't know about productivity with automation. Later I moved onto MacOS to experience bliss before starting to hate it for one thing after the other; right from their buggy operating system upgrades to Apple not providing power cable compatible to Indian market resulting in earthing issues. Out of frustration I jumped back to Ubuntu and now back on Windows after long years. 

Getting onto Windows was more out of necessity than interest and I started to explore how much things have changed in the Windows world. It wasn't a smooth return for me but the teething period is over and I'm loving Windows again. If you are onto Windows 10 Pro edition, and wanting to get the best of both worlds (Windows and Linux), this post is for you. I am jotting down ProTips to experience delight and productivity at development work.
  1. Use WSL 2 instead of WSL 1, for the former is far less resource intensive by integrating natively with Windows 10 Hyper-V virtualization stack, and thus phenomenally faster too. If you are on Windows 10 Home edition, you need to upgrade it to Windows 10 Pro edition and it is worth it, for you can get it at half the price upon upgrade.
  2. Do not mount windows native formatted drive (NTFS) onto WSL for code that can be developed both in WSL environment and Windows. While this works, it is snail paced and you will frustrated too soon. I tried this out of curiosity and frustrated beyond my anticipation. If you are still wanting this, you will have to first format the storage drive in DOS format (as FAT32), so that it works well with your WSL and host Windows operating systems. This is possible the best middle-ground that you can hit upon.
  3. Use Windows Terminal instead of  CmderConEmuMinttyCygwin or any other console emulators. Why? You can customize it with default settings for each of WSLs, Windows Command Prompt, Powershell or other terminals integrated with it. Also Windows Terminal is lightweight and faster.
  4. When you start your development server in WSL 2, try testing it in your browser with localhost, it won't work. WSL is one proper sandboxed environment or VM. You need to port forward localhost settings for this to work. This can be done by adding the line like below in your .wslconfig file in your windows $HOME directory.
    -- --
  5. WSL 2 can consume all of your host memory. You can set limits to it by appending the line memory=16GB in your .wslconfig file.
  6. Do install Oh-My-ZSH to use zsh shell instead of the default bash. You get bunch of goodies like pre-configured aliases for Git and more by way of its plugins that you can configure to your preference.
  7. If you are into using tmux, you can use that too in your WSL 2, and power it up with tmux-powerline.
  8. You can change the location of your WSL 2 distribution's virtual hard drive. I keep all of my VMs (and now WSL 2 virtual hard drives) in D:\VMs\<platform>\<distribution name>. Run the following commands in PowerShell - replacing distribution name and preferred location:
    ----
    Also at the time of writing, when you import a distribution, you may need to tell WSL 2 to start the distribution using the Linux user account you created when you first created the distribution. Thanks to 58bits.com that you can run the below PowerShell script that imports the distribution, and resets the default user as you would like it to be.
    -- --
    Note that if your import fails with 'Unspecified error' (or other) - you may need to limit the amount of memory allocated to vmmem. You can do this with WSL2 config to limit memory as mentioned in ProTip 5 above.
  9. If you are into using VS-Code as your IDE for development, you can launch the one you installed on your host Windows 10 OS from WSL 2 bash in your project's root folder and executing `code .`. With this you can work on your windows operating system launching your development servers in WSL environment, thus getting the best of both the worlds. Additionally, you can install your vs-code extensions on remote wsl as well as on host OS, all from within your IDE.
  10. And Docker Desktop for Windows works well with your WSL2 too. You just can extract the best from everything. 
Upcoming Feature: Having dual boot for Windows and Linux? You can mount your linux partitions onto WSL2 in Windows 10. Checkout Microsoft Dev Blogs

Windows 10 is super cool again with WSL 2. Whether you are a Windows buff wanting to leverage Linux goodies, or a Linux buff wanting to draw upon Windows 10 strengths, you can have it all. Happy coding!!..

References

My Popular Posts

Ten Commandments of Egoless Programming

We are nothing but the values we carry. All through my life thus far, I tried to influence people around me with the virtues I value. Thanks to some good reading habits I had inculcated, and the fortune of being in good community of peers and mentors alike, I managed to have read some real good books. This post is about the 10 commands of egoless programming in Weinberg's book. I shall explain the commandments based on my experience here. So very many decades ago, Gerald M. Weinberg authored  The Psychology of Computer Programming . In it, he listed The Ten Commandments of  Egoless Programming , which remains relevant even today for us as not just programmers but as team-members. Weinberg is regarded as a pioneer in taking a people-centric approach to computing, and his work endures as a good guide to intelligence, skill, teamwork, and problem-solving power of a developer. When they appear to inspire and instruct, we find that they can apply to just about every business area, and e

Should I buy refurbished laptop from Amazon?

This post is based on my experience with amazon.in and guess it to be true on all other platforms as well. At least you can check out and verify for these pointers before you make that decision to buy renewed/refurbished laptop on Amazon with your hard earned money. I see this question propping up in several forums and on many different occasions. In the recent past, I had my 5 year old dell laptop that gave up because its motherboard failed. One of the options that I had in my mind was to re-use the HDD and the 16GB DDR4 RAM of that old laptop in the one that I purchase next as secondary.  I had come to a conclusion that it is not worth buying a refurbished/renewed laptop at all. Why? For the following reasons, most of which I see as BIG #RedFlags: You got to remember that Amazon provides a platform for 3rd party sellers to sell their products as well. So in your search for refurbished laptops you wouldn’t want to choose some random 3rd party seller who Amazon doesn’t endorse. You cou

Multi-tenant Architectures

  Multi-tenancy Application Deployment Architecture could be modeled in 4 broad ways: Separate Apps & Separate Databases Shared Apps & Shared Databases Separate Apps & Shared Databases Shared Apps & Separate Databases There is no right or wrong here. It's about choice and consequence that you should consider taking into your business context and constraints. In this post I intend to jot down a some key points to keep in mind for each of these multi-tenant architecture. These are more of quick notes for my quick reference, a cheat-sheet of sorts when I have to make choices. And I guess this can come handy to you too in your wise decision making. Separate Apps & Separate Databases Easiest to implement from development and deployment stand-point. Just automate the deployment infrastructure for every tenant for quick set-up. Most expensive of all the models from infrastructure cost stand-point. Relatively longer deployment t