
Porting a macOS Clojure Dev Setup to Windows WSL2 - Borkdude
https://blog.michielborkent.nl/2020/07/26/remote-wsl2-clojure/
======
nickjj
WSL 2 is pretty decent honestly.

I've been using WSL 1 + Docker for full time web development since early 2018
on Windows 10 Pro.

Upgraded to WSL 2 when it hit the stable release and it works quite well. The
only thing that sucks is mount performance for files outside of WSL 2's file
system but if your source code is inside of WSL 2's file system it's very
solid.

This is with ~$850 worth of 6 year old hardware too (i5 3.2ghz, 16gb of RAM,
1st generation SSD, etc.). I never bothered to upgrade because everything I do
around Flask / Phoenix / Rails / Node development + running Docker / VMs +
etc. works great. I do video editing too.

If anyone is curious what it's like, I made a video where I went over all of
the tools I use on Windows and WSL 2 to have an acceptable dev environment for
Linux based development [https://nickjanetakis.com/blog/a-linux-dev-
environment-on-wi...](https://nickjanetakis.com/blog/a-linux-dev-environment-
on-windows-with-wsl-2-docker-desktop-and-more).

It covers both the Windows tools and how I have everything configured on the
WSL 2 side of things (tmux, terminal Vim, etc.).

~~~
91edec
I'm really torn with WSL. WSL1 has far superior performance when performing
I/O tasks on the mounted Windows drives, but slower than WSL2 locally. WSL2 is
unbearably slow when performing I/O on the mounted Windows, using vim with a
git pluggin or FZF is crippling. So I attempted to just use WSL2+vim on the
linux local file system, but then when I try to run Windows npm scripts in a
folder UNC paths cannot be understood by CMD.exe. It is the only thing
preventing me from fully switching over.

~~~
nickjj
If you have npm installed in WSL 2, what use cases are you running into where
you need to run Windows npm scripts?

You could exclusively run npm commands inside of WSL 2 and never have to touch
cmd.exe.

~~~
91edec
I have to run npm scripts in Windows land because they launch electron apps
that require Windows.

------
zamalek
> Installing Ubuntu on new PC. The installer is surprisingly smooth, detects
> my wifi, even nvidia video card apparently.

This is the advantage of the development model behind Linux "drivers." People
with serious commitment to code quality review them. They typically should
work more reliably.

I usually don't complain about anything Windows, but certain OEMs (Dell, HP)
clearly care only for hardware. I've been suffering through a comedy of awful
drivers, culminating in using my phone to print.

I wish WHQL did more thorough testing.

~~~
boogies
[https://en.wikipedia.org/wiki/WHQL_Testing](https://en.wikipedia.org/wiki/WHQL_Testing)
is out of date, does WHQL still exist, after Microsoft firing a testing
division in favor of Windows Insiders?

------
auganov
It's not spelled out clearly, but I'm understanding that the main rationale
here is to:

    
    
      - have an Ubuntu dev environment, 
      - while benefiting from Win's RDP 
      - AND also having access to native Windows for testing.
    

Because Clojure runs perfectly well on regular Windows, it's not like WSL is
required. So otherwise the author would have to have a separate Windows
install just for testing.

~~~
Borkdude
Author here. This sums it up well. I want the WSL2 setup so I can also keep
running the zsh setup and bash scripts I was already using on macOS. For work
I need to run several Docker containers in addition to the Clojure/Java stuff.
Since I had not used Docker on Windows prior to WSL2, I jumped to the
combination immediately. I figured that running everything in WSL2 was easier
than some things inside and some things outside.

~~~
auganov
Well if you don't strictly need Ubuntu chances are your scripts would work
with Cygwin. Which operates under the regular Windows paradigm. Then you can
use native Emacs too[0].

I've been doing Clojure stuff on a pure Windows setup for quite a while and
honestly I liked it more than my current Linux setup (only switched because of
some linux kernel features I needed).

[0] note that ansi-term is (or used to be) broken on Windows tough , other
than that pretty much everything works

~~~
tootie
I think Cygwin and msys are essentially deprecated at this point. WSL is
easier to setup and more compatible. I was big Cygwin fan for a long time, but
I've definitely run into edge cases that it couldn't handle. WSL works pretty
flawlessly for me so far and I can just use apt for package management instead
of the Cygwin setup tool.

~~~
auganov
Depends if you care about doing anything natively on Windows or not. Say
Windows has perfectly good native support for NodeJS. If you go with WSL
you'll be running WSL's Node. Many may not want that.

Java/Clojure same deal. There's no problem with them on Windows. Running
everything under WSL sounds like a big compromise to make to me. Though for
Java/Clojure I could imagine you could still for most projects start your
software from the normal java.exe as jars generally don't have platform
specific code. But in my codebase I do actually use a few libraries that are
system specific.

~~~
tjoff
You can run windows apps within WSL too though.

(I guess maybe not WSL2)

~~~
auganov
Well the thing is if you npm install a lot of stuff using the WSL version
there may be packages that include platform specific stuff. Then trying to run
it with the native node might not work. But thinking of it I guess you could
have all the WSL scripts use the native version. Not sure if there would be
issues.

Or let's say you have to compile something that you want to use as a child
process in your software. If you compile that under WSL (correct me if I'm
wrong[0]) it's not going to be easily accessible to normal Windows apps.

[0] I see that now there's some way to invoke wsl commands from regular
Windows but not sure how that works exactly.

------
shmerl
Why not run Linux natively? If you need Windows, you can run it in VM.

~~~
anaisbetts
I don't know any legitimate mainstream reason why you would run Linux when
WSL2 exists. It runs everything Linux does perfectly, but also with an
operating system that isn't built around an 11-year old somehow still
"experimental" display server that leaves fundamental use-cases like screen
sharing to "an exercise for the reader"

~~~
qalmakka
Also, have you ever tried to do any serious in C++ development work under
Windows? Downloading 10 gigabytes of SDK just to run the compiler is not fun.

Also, most if not all compilers (GCC is a number 1 offender here) are much
slower than Linux or macOS under Windows. It all depends on what you do, what
kind of user you are and what kind of job you are trying to do. No one uses
something worse on purpose, so there sure must be reasons why people still say
installing Linux is worth it. WSL is good for those who would have run Linux
in a VM anyway, but if you need Linux or if you're just used to it, it's still
not enough.

~~~
mehrdadn
I haven't noticed GCC being slower, though I admittedly haven't measured.
Which build of GCC do you use? MinGW64? or MSYS or something else? If you use
the versions that are Cygwin derivatives, they will probably be slower, but
that's not really due to GCC.

~~~
qalmakka
No, it's a native mingw-based GCC toolchain(cross compiler for an embedded
platform), and everything is noticeably slower than on Linux or even macOS. I
think it's because GCC is designed as relying on a multitude of separate
binaries instead of being a single process. For each file it compiles it
spawns a truckload of separate processes (collect2, cc1plus, as, ld...) and if
there's something that's slow as heck on Windows, is spawning processes.

~~~
mehrdadn
You're right about the slowness! I just noticed it now. I'm confused why
though -- I don't actually see it spawning a lot of processes, and the
slowness is far beyond what could be explained by that. Even a single process
call appears to run much more slowly. I haven't dug into it but maybe the I/O
pattern is funny?

------
crb002
My notes. Many yaks were shaved due to Windows hating my graphics card.
[https://github.com/chadbrewbaker/CompilingOnAWSLambda/blob/m...](https://github.com/chadbrewbaker/CompilingOnAWSLambda/blob/master/wsl2.md)

------
julioo
It’s a little bit off topic but does any one make WSL2 working on Surface Pro
with the LTE connection? Everything works fine un WiFi but nothing works with
LTE.

~~~
m0xte
Usually adapter protocol bindings related. I have the same problem on my
desktop with WSL2. It turns IPv4 off for some reason!

------
Lindoves
Why not use Linux directly? Set up one PC for games, and one for dev; I can't
believe anyone uses Windows for anything but 'games.' But that's fair; just a
subjective comment.

~~~
owenwil
I can think of a few reasons not to, as someone who tried to use Linux first
when switching away from macOS. The most notable of which is using Linux with
a high-density 4k+ display is nightmarish at best; everything is either too
big or too small, and at least in Ubuntu, fractional scaling is too broken to
use on a daily basis – also requiring a ton of manual config and tweaking to
even get usable. Windows, by contrast, works out of the box really well with
HiDPI displays, and generally has a really well-refined experience these days,
particularly between WSL2 and the Windows Terminal experience. It's the best
of both worlds, without the hassle of dual-boot or manual config, IMO

~~~
fmakunbound
A few Windows HiDPI problems I've experienced with an external 4k display: all
the task bar status icons are blurred nearly unrecognizably after a while, Qt-
based applications seem to be twice as large (text scale, and widgets) than
win32 based ones (sure it's a Qt thing, no Windows), Steam can't figure out
where the pointer is after a while (seems to track the pointer as 1/4 of where
it is in x/y coordinates), and win32 applications often appear blurred and
require some compatibility setting via the .exe file's properties thing which
I don't understand because it seems to make no difference.

Honestly, Pop_OS! on the same setup is much smoother. Probably something to do
with the HiDPI Daemon it has running.

The only flawless operating system on this 4k external setup has been macOS.
Can't think of any problems and that's my daily system.

~~~
owenwil
Are you on Windows 10's 2020 release? That doesn't resonate with my experience
at all – macOS has been vastly more frustrating to deal with on 4K displays in
my experience, constant reflowing and forgetting window states, takes forever
to recognize the displays when plugging in or resuming from sleep, etc... I
even have all of the pointer and icon problems you describe with the top bar.
Sometimes, with a 4K display plugged in, it takes 10+ seconds to figure out
how to use it. Meanwhile, none of that on my Windows machine!

~~~
fmakunbound
> 2020 release?

Probably. It's Windows 10 build 2004 or something.

The mac I have is mid-2014 w/ Mojave (also Catalina), and I'm using the hdmi
out. It seems to remember the display, moves the applications I had on it last
time to it, with all the other details like wallpaper scaling settings. It
takes maybe 1/2 second to display.

~~~
owenwil
To be fair that Mac was one of the greatest ever made, haha – I blame most of
my issues with all of this on stability issues with the 2019 MBP I'm forced to
use for work.

