Fork me on GitHub
#beginners
<
2021-05-03
>
FHE02:05:32

Sorry for the wall of text, but I just want to explain what just happened when I finally got my ClojureScript Quick Start guide program working under WSL2. --- tl;dr The question is: Should I develop CLJS using a Linux-side brower in a VcXsrv X11 window, or in a Windows browser? ---

FHE02:05:08

A crazy (to me at least) thing happened while trying to get my CLJS Quick Start Guide hello world program working on WSL2. When I finally ran my tiny hello-world test program and pointed the Linux browser at localhost:9000, it showed what it was supposed to show (Yay!)....but then this, Windows browser (the one I talking to you in) got hijacked and automatically opened a new tab to localhost:9000 (also with the correct output)!!

FHE02:05:25

When I put a JS alert in the REPL, the alert only pops up in the Linux browser, not the Windows one. Still, though. Utterly surprised it reached out and touched the Windows browser at all. I thought WSL2 (specifically, not the case in WSL1 AFAIK) OS instances were built as if on a separate network/IP. I did not expect localhost:9000 alone to work for the Windows browser side. I was actively deciding to not bother trying to get that working since I had been given advice to just do it all on the WSL2-Linux side. Stranger still is what happened later... The Windows browser I mentioned above is Firefox. The Linux one is Chrome. I just brought a Windows Chrome browser into the mix, and tried pointing that one at localhost:9000 and it works perfectly, displaying the correct page (like the Windows Firefox) but also responding with the JS alerts I put through (unlike the Windows Firefox, but like the Linux Chrome). ...but only one of the Chrome browsers will generate the JS alert, and after some testing it just appears to be whichever browser I more recently hit [F5] (refresh) on!

FHE02:05:13

So...I wasn't trying to get a Windows browser to work for this, and expected that would take some network-fu and was going down the road to getting a Linux browser to work, but...is there any reason I should use the Windows browser instead since it was kind of just dropped into my lap as a possible alternative?

seancorfield02:05:39

I have to say that I have not seen any Windows browser respond to ClojureScript running inside WSL2.

FHE02:05:03

Right? I was floored.

FHE02:05:33

Similar question: Windows Emacs or WSL2 Linux (Ubuntu) Emacs? (either one acting upon program source code files in the WSL2) I went through the process of setting up Doom Emacs on the WSL2 Ubuntu 20.04, but I just realized I could probably simply use my existing Windows Doom Emacs installation to act on the files in the WSL2 file system (in \\wsl$\Ubuntu-20.04 ).

hindol09:05:13

For me, Emacs in WSL2 works much better. If you are facing some issues with the setup, maybe I can help.

hindol09:05:31

I highly recommend Emacs on WSL2 than Emacs on Windows.

hindol09:05:26

The Windows Emacs will be slower on WSL2 files and similarly Emacs on WSL2 will be slower when editing files on the Windows filesystem. So, stick to editing files that are local to that Emacs.

FHE02:05:03

I did not expect to have options for either thing (input (source code editing) or output (browser))!

FHE03:05:42

So I guess now that I have a browser working, I should move on to installing figwheel-main on the WSL2 Ubuntu 20.04?

FHE03:05:20

Or...according to the CLJS Quick Start Guide I might need Node.js? I can't remember if, when I did my tiny webapp under Windows ages ago, I did anything with Node. How important is it? Can I just skip it and move on with installing Figwheel-Main, figuring out CIDER, and figuring out more about deps.edn (and maybe tools.deps IIRC)?

seancorfield05:05:49

I skipped node and used Figwheel. I think if you use Shadow-cljs you kind of have to embrace node and its package manager (you can use Shadow without node, so I'm told, but it's not "normal"). I can't offer an opinion on Emacs/CIDER because I haven't used it for years.

Chandrashekhar V07:05:24

Hi all. What is a good way to go about building mobile apps using Clojure (or Clojurescript)? Most of the examples focus on Cljs + ReactNative but I also see that re-natal hasn’t been updated in quite sometime (and is supposedly fallen behind ReactNative APIs?).

danieroux07:05:28

"GitHub - vouch-opensource/krell: Simple ClojureScript React Native Tooling" https://github.com/vouch-opensource/krell

Chandrashekhar V08:05:17

Thanks. Will look into this!

Eric Ihli04:05:25

This might be a little bit outdated now, but it's about a minimal fully-functioning React Native app that's well-documented. https://github.com/eihli/cljs-react-native-starter/blob/master/src/example/core.cljs

Audrius09:05:32

What would be the best way to parse this string -XX:+UseG1GC to 2 tokens: xx and +UseG1GC ? first token between - and : and second is what is left after : . I think there might be a function that does exactly that.

delaguardo09:05:36

regex or some parser combinator library, https://github.com/blancas/kern for example

1
✔️ 1
pavlosmelissinos09:05:48

If - is always going to be the first character, clojure.string/split might also be more than enough (for a quick and dirty solution):

(clojure.string/split (subs "-XX:+UseG1GC" 1) #":")

=> ["XX" "+UseG1GC"]
(clojure.string/split (subs "-XX:+UseG1GC:lala" 1) #":")

=> ["XX" "+UseG1GC" "lala"]
you can even set a limit
(clojure.string/split (subs "-XX:+UseG1GC:alala" 1) #":" 2)

=> ["XX" "+UseG1GC:alala"] 

✔️ 1
jumar10:05:27

Just curious: why are you doing that? 🙂

Audrius10:05:02

I just need to show these parameters in UI. As we can restart the whole app with different JVM start up parameters if needed