Slide 1

Slide 1 text

macOS-like Developer Experience with WSL2, Windows Terminal, VSCode and Docker Desktop microWSLConf 2020 Kohei Ota, Hewlett Packard Enterprise / CNCF Ambassador GitHub: @inductor, Twitter: @_inductor_

Slide 2

Slide 2 text

Agenda ● What’s macOS like DX? ● Tools and where they cover ● Real world issues and workarounds ● Customizing and sharing

Slide 3

Slide 3 text

This talk does not cover ● What are WSL and WSL2 ○ WSL2 architecture and such ● How to use macOS ● How to use Docker

Slide 4

Slide 4 text

What’s macOS-like DX? ● Runs shell natively ● IDE and filer integration ● Easy tab management just like browsers ● Better copy-and-paste experience than classic cmd.exe ○ Just use Ctrl+C and Ctrl-V ● Package management ● Runs code quickly and easily! (w/ the power of Docker)

Slide 5

Slide 5 text

What’s macOS-like DX? ● Runs shell natively ● IDE and filer integration ● Easy tab management just like browsers ● Better copy-and-paste experience than classic cmd.exe ○ Just use Ctrl+C and Ctrl-V ● Package management ● Runs code quickly and easily! (w/ the power of Docker) WSL2 Windows Terminal Homebrew Docker Desktop VSCode

Slide 6

Slide 6 text

Quick demo

Slide 7

Slide 7 text

Quick comparison table

Slide 8

Slide 8 text

Windows vs macOS features comparison macOS Windows Shell environment Native WSL2 IDE and filer integration Native VSCode + Bash script Easy tab management Terminal.app / iTerm2 Windows Terminal + Config Copy and Paste (C+C/C+V) Terminal.app / iTerm2 Windows Terminal + Config Package management Homebrew + dotfiles Homebrew + dotfiles Run code quickly and easily Docker Desktop for Mac Docker Desktop for Windows

Slide 9

Slide 9 text

IDE and filer integration

Slide 10

Slide 10 text

VSCode Remote + WSL2 ● VSCode has supported WSL2 remote since the end of 2019 ○ https://code.visualstudio.com/blogs/2019/09/03/wsl2 ● Type ‘code’ in your WSL bash and it will launch VSCode! ○ https://code.visualstudio.com/docs/remote/wsl-tutorial#_run-in-wsl

Slide 11

Slide 11 text

Additional tip for IDE ● Jetbrains families are actively implementing WSL2 environment supports!

Slide 12

Slide 12 text

Reproduce ‘open’ command in WSL2 ● macOS shells support ‘open’ command to open directories in their filer ○ e.g. “open .” and it will open the current directory on Finder ● In WSL, you just need this one line in your .bashrc :) ○ alias open="powershell.exe /c start"

Slide 13

Slide 13 text

Easy tab management

Slide 14

Slide 14 text

Introduce Windows Terminal ● Windows Terminal is a new Terminal officially developed by Microsoft ○ Supports powershell, cmd and WSL background ● Fully open source on GitHub ○ https://github.com/microsoft/terminal ● Available on Microsoft Store

Slide 15

Slide 15 text

Customize Windows Terminal ● All settings are configurable with JSON format "profiles": { "list": [ { "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}", "hidden": false, "name": "Ubuntu", "source": "Windows.Terminal.Wsl", "startingDirectory": "//wsl$/Ubuntu/home/kela", "fontFace": "Roboto Mono for Powerline" } ] } Set your $HOME for new tabs!

Slide 16

Slide 16 text

Customize Windows Terminal ● All settings are configurable with JSON format Copy and Paste Tab management Key bindings "keybindings": [ { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" }, { "command": "paste", "keys": "ctrl+v" }, { "command": "closeTab", "keys": "ctrl+w" }, { "command": "newTab", "keys": "ctrl+t" }, { "command": "find", "keys": "ctrl+shift+f" }, ]

Slide 17

Slide 17 text

Package management

Slide 18

Slide 18 text

Homebrew supports Linux ● https://docs.brew.sh/Homebrew-on-Linux ○ WSL support included! ● Homebrew installer now runs pure bash and brew contains portable ruby ○ Better portability and less external dependency

Slide 19

Slide 19 text

Make your dotfiles ● Manage your brew install and bashrc changes on GitHub ○ https://github.com/inductor/dotfiles ● When you get a new computer, just run dotfiles installer then you’re all set!

Slide 20

Slide 20 text

Run code quickly and easily

Slide 21

Slide 21 text

Docker Desktop for Windows ● Now it supports WSL2 on Windows 10 Home 1903/1909 ● I’d personally recommend Edge channel ○ New features & performance fixes come more frequently ● Developing inside a Container ○ https://code.visualstudio.com/docs/remote/containers

Slide 22

Slide 22 text

Real world issues

Slide 23

Slide 23 text

Memory usage explosion in WSL2

Slide 24

Slide 24 text

● Set .wslconfig in %UserProfile%\.wslconfig ● Here’s my personal setting ● Available options are on https://docs.microsoft.com/en-us/windows/wsl/wsl-config Memory usage explosion in WSL2 [wsl2] memory=6GB swap=0 processors=4

Slide 25

Slide 25 text

Windows Filesystem performance issue

Slide 26

Slide 26 text

● The best workaround right now is not to use Windows filesystem ● VSCode Remote and Docker and IDE integration with WSL2 make it possible ● I strongly recommend the ‘open’ command support if you want to use explorer.exe with working directories! Memory usage explosion in WSL2

Slide 27

Slide 27 text

Key takeaways Windows has become very developer friendly It’s nice to have a workstation that both my favourite software work: Age of Empires 2 and Docker! WSL2 still has problems, but it is already enough for most users who use macOS for Web development Windows Terminal keybindings are powerful WSL2 networking and filesystem shareing is convenient

Slide 28

Slide 28 text

Thank you!