beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
2021-05-01T01:18:38.303200Z

Would like to the naming convention for this

mobile.ui.components.nativebase :as (nativebase? or cnb? or unb?)
Basically, will you prefix the last part nativebase with some strings?

FHE 2021-05-01T02:17:51.316900Z

Hi everyone. It's been a few months since I was here, or attacked trying to piece together my dev environment. The last thing I accomplished with getting WSL2 set up, then Ubuntu, then Clojure CLI tools (including bash, curl, rlwrap, and Java). I'm kind of lost as to what to do next. I can't even see any file system from within this WSL2 thing ('ls').

FHE 2021-05-01T02:20:39.319600Z

I just want to be able to create ClojureScript things that can be exported and run on a local browser or from a website. I imagine that will mean creating a shell of a .html webpage including a big canvas area for the ClojureScript program to target, then creating a CLJS project and going from there?

2021-05-01T15:08:42.383800Z

I appreciate the dialog in this thread and can relate to too many of the thoughts discussed. As a student of the language/ecosystem in my precious few moments of spare time, I admit I default to the path of least resistance for working through the problem in front of me. Given what I've read, if you are attempting to get something fired up quickly and are familiar with creating VMs I'd probably just fire up a VM with your favorite distro to accomplish your immediate goal.

FHE 2021-05-01T15:29:32.384Z

I've downloaded VMWare before but that's as far as I ever got. There was some kind of stumbling block and at the time no great reason for me to use a VM other than just for a fairly secure browser. Thanks for the idea, though. I just might do that. Could it be easier/better than WSL2 and easier than setting up than dual booting (and continuing to dual boot)?

2021-05-01T17:17:17.388200Z

I'd say whichever you're most comfortable with is the right choice here. Windows does have Hyper-V built in and VirtualBox has treated me well in the past as well, but to each their own. I like the ability to teardown and rebuild VMs at will so, I'd personally take the VM route.

FHE 2021-05-01T20:24:10.391900Z

Extremely basic VM question: They can be persistent (or rather save state) across restarts/sleeps/userchanges of the host system, yes?

seancorfield 2021-05-01T20:24:50.392100Z

Yes. That's essentially what WSL2 is: a VM.

FHE 2021-05-01T21:11:44.396400Z

So between a VMWare VM and WSL2...?

seancorfield 2021-05-01T21:59:24.396600Z

@factorhengineering You should already know my answer 🙂 WSL2 provide full integration with Windows — you can access the Windows filesystem easily within it, you can use Windows apps within WSL2 (e.g., using notepad.exe README.md to open that (Linux) file in (Windows) NotePad, you can also start Linux apps from Windows (in the latest version of WSL2/Windows) — e.g., Google Chrome from Linux appears in my Windows Start Menu. If you use a standalone VM, like VMWare, you won’t have that sort of integration.

seancorfield 2021-05-01T22:00:58.396800Z

(and with VS Code, at least, you can have a full Windows-native editor experience while still having everything running on WSL2)

FHE 2021-05-01T22:26:15.397Z

Oooh. Actually I don't think I happened upon the fact that it can access the Windows file system. I did come across the fact that Windows can access the WSL2 file system, though, which is good.

FHE 2021-05-01T22:27:10.397200Z

How does one navigate to the Windows file system from the WSL2 Ubuntu CLI?

seancorfield 2021-05-01T23:26:06.397600Z

/mnt/c is your C: drive.

FHE 2021-05-02T00:49:54.399600Z

Nice and simple. Thanks!

FHE 2021-05-02T02:58:31.400700Z

So my task list from last night was: (1) Figure out how to get a second WSL2 CLI (when Terminal isn't offering it). (2) Figure out how to get a browser running in WSL2. (3) Figure out what X11 is an how to get that going. (4) Figure out how to get Doom Emacs installed on WSL2.

FHE 2021-05-02T02:59:10.400900Z

(1) was easy: just launch the Ubuntu Windows app a 2nd time for a 2nd CLI

2021-05-02T03:00:05.401100Z

Or use Windows Terminal and have them tabbed

FHE 2021-05-02T03:00:16.401300Z

(4) I did next. It took hours and hours but it's done now. Doom Emacs (27.2) looking fine on WSL2 Ubuntu 20.04 (CLI-only), though until now I had never seen it not it its own window.

FHE 2021-05-02T03:00:41.401500Z

Windows Terminal will not offer me that option. Only command prompt, powershell, and some azure thing.

FHE 2021-05-02T03:01:18.401700Z

I thought it offered the WSL2 option after I first installed it a while back, but if it ever did it has since disappeared.

2021-05-02T03:02:28.401900Z

It definitely should list all distros installed. In the dropdown and you should be able to configure your default.

FHE 2021-05-02T03:02:36.402100Z

I think (2) will follow from (3). I am trying to understand it now. Based on this info I think I just need a single window-launcher thing. https://utf9k.net/blog/emacs-wsl2-install/#an-optional-prerequisite

FHE 2021-05-02T03:06:26.402500Z

@seancorfield had recommended VcXsrv, but I thought I heard bad things about SourceForge a while back, and X410 is available as a Win10 app. Hmm...

2021-05-02T03:28:32.402700Z

@factorhengineering It seems you're not alone with the disappearing WSL profiles in the Windows Terminal. https://github.com/microsoft/terminal/issues/6946

FHE 2021-05-02T03:39:38.403Z

Aha. Glad to know it's not something I messed up.

seancorfield 2021-05-02T05:28:39.417Z

Looks of useful information about workarounds in that issue. Interesting stuff.

seancorfield 2021-05-02T18:41:50.442700Z

In a wonderful stroke of irony, I fired up my laptop today, fired up Terminal, and my Ubuntu profile was missing -- just like issue 6946. First time I'd ever encountered that. I rebooted, let my machine settle down -- waited for all the startup processes to complete -- and then started Terminal and Ubuntu was there as usual. So, as the issue suggests, this is a timeout issue that WSL doesn't respond quickly enough if you open Terminal while your system is "busy". Interesting.

2021-05-03T14:56:03.480600Z

@factorhengineering I would imagine this is extremely frustrating, all of emacs, windows dev, browser dev, and cljs are fiddly setups with a lot of weird evolved baggage and a lot of special case tweaks. If this gets overwhelming I'd advocate taking on fewer weird new things at a time, eg. starting with jvm clojure on osx (or linux if you are comfortable with it) and just using whatever editor you know best already

piyer 2021-05-01T03:29:42.324300Z

I am not sure what are you trying to achieve. Setup a website?

FHE 2021-05-01T04:00:47.325300Z

Yes, basically. Really just want to get started making programs in general, but targetting the browser seems to be the way to go to make my programs easy to let others try.

FHE 2021-05-01T04:03:06.325500Z

I followed the ClojureScript quick guide way back, and put together a simple .html webpage then had ClojureScript grab text from an input field, do some useful manipulation of it, and show the resulting text in another area of the webpage.

FHE 2021-05-01T04:06:15.325700Z

I just copied and pasted the folder structure from the example, though, and now I'd like to do the project folder and file structure a little better (maybe with a tool?)...or at least understand it better...trying to get that side of things more set and then I want to get into doing more advanced stuff (like actual graphics and real-time interaction---for educational games at first) in the browser.

raspasov 2021-05-01T04:19:27.326Z

@factorhengineering do you have a ClojureScript REPL/editor all setup?

FHE 2021-05-01T04:33:46.326200Z

I have Doom Emacs. Not overly familiar with it, but again I'm trying to up my game.

FHE 2021-05-01T04:34:23.326400Z

Last time I used NotePad++, but I understand Doom Emacs has nice parenthesis handling, as well as some kind of built-in REPL that could help?

FHE 2021-05-01T04:35:44.326600Z

By the way, when I did my small program in ClojureScript last time, I followed the Quick Guide from the Windows perspective. This approach of doing things from Linux (well, WSL2) is new to me.

raspasov 2021-05-01T05:09:42.326800Z

Sorry, I can’t really help with Windows specifically… Last time I used Windows it was in 2009 or so 🙂

raspasov 2021-05-01T05:11:28.327Z

Using MacOS, but can help with Linux basics as well.

raspasov 2021-05-01T05:11:38.327200Z

If you have a REPL going, are you using either figwheel-main or shadow-cljs? Those are the two most common options for ClojureScript REPLs and auto-reloading.

FHE 2021-05-01T05:23:25.327600Z

Well I'm trying to use WSL2, so I would imagine (hopefully, after the immense amount of time it took to install it LOL) that I shouldn't have to deal with any more Windows-isms.

FHE 2021-05-01T05:24:20.327800Z

I mean I'll be running my Emacs in Windows, but operating on files in the WSL2 (Ubuntu) subsystem.

FHE 2021-05-01T05:25:03.328Z

I thought I was told I could just use deps.edn (or maybe that was tools.deps) and not need to used Leiningen or shadow.cljs

FHE 2021-05-01T05:28:46.328200Z

Wait a sec...misread what you said. You're talking about the live-update functionality, not the project management piece, right? I think figwheel/figwheel-main or the live-update part of shadow.cljs is in the picture for me, yes (though the project management part of shadow.cljs, like Leiningen, seems to not be needed given what @seancorfield advised me months back (but only a small step ago since I was derailed. Does that sound about right, @raspasov?

seancorfield 2021-05-01T05:37:32.328400Z

@factorhengineering What I was suggesting was doing all your Clojure/Script development on WSL2 so you could avoid "Windows-isms" but I don't know how you will use Emacs on Windows to talk to a Clojure setup on WSL2. VS Code has a "Remote-WSL2" extension that means you can use VS Code on Windows and have your entire dev setup on WSL2.

seancorfield 2021-05-01T05:37:48.328600Z

I suspect with Emacs, you'll need to run it on WSL2.

seancorfield 2021-05-01T05:39:01.328800Z

And, yes, figwheel-main should give you the live-update experience, and yes you can run figwheel-main using just the Clojure CLI / deps.edn -- see the figwheel-main docs.

FHE 2021-05-01T05:40:26.329Z

Hmm...yes, I guess I'm not just changing files. Emacs and the program are going to be interconnected more than that. Ooof. I hope getting it set up all over again in Linux will not be difficult.

seancorfield 2021-05-01T05:40:51.329200Z

Do you like Emacs? What other editors are you familiar with?

FHE 2021-05-01T05:41:12.329400Z

I didn't realize I was signing up for moving everything over to WSL2. There isn't even a GUI in it, and I only just figured out how to even see the file system.

seancorfield 2021-05-01T05:41:48.329600Z

Clojure sort of expects you to do everything from a terminal 🙂

FHE 2021-05-01T05:42:24.329800Z

I've used NotePad++, but I'm getting familiar with Emacs again after using it just a bit a long while ago. It's supposed to be the best for this, isn't it? I mean I even like just taking notes on this (HUGE) set-up-my-dev-environment project in org-mode.

seancorfield 2021-05-01T05:42:53.330Z

As I said above, if you're comfortable using VS Code on Windows, it has an extension that makes the whole WSL2 thing seamless.

seancorfield 2021-05-01T05:43:16.330200Z

I haven't used Emacs for five or six years now (but used it on and off for about twenty years prior to that).

FHE 2021-05-01T05:43:37.330400Z

Clojure does, OK, but installing other things (Doom Emacs) from terminal? Did not think I was headed in that direction. It's fine though, if it's required. I want the best set-up.

seancorfield 2021-05-01T05:44:59.330600Z

Pretty much everything in the Clojure world assumes you're either on macOS or Linux. If you're using Windows, it's painful.

FHE 2021-05-01T05:45:06.330800Z

...and I was just starting to get comfortable with Doom Emacs, and hoping I could finally, you know, write some code. Ha 😭

FHE 2021-05-01T05:45:36.331Z

I thought at least my text editor and my browser could still be in Windows. Guess not?

FHE 2021-05-01T05:46:02.331200Z

If I had known that, I might have just set up dual-boot instead of WSL2.

seancorfield 2021-05-01T05:46:38.331400Z

You can use VS Code on Windows and have your whole dev env running on WSL2 ¯\(ツ)

FHE 2021-05-01T05:46:45.331600Z

What is the advantage of WSL2, then? Just being able to alt-tab to Windows stuff completely unrelated to the task of programming?

seancorfield 2021-05-01T05:47:17.331800Z

WSL2 means you can do all your development on Linux while keeping your familiar Windows UI and apps.

FHE 2021-05-01T05:47:54.332Z

If VSCode can do it, why can't Emacs? Isn't it all-singing, all-dancing when people want it to be, and wasn't it the first best for doing Clojure dev?

seancorfield 2021-05-01T05:48:16.332200Z

Because the VS Code bridge to WSL2 is modern and Emacs is not modern?

FHE 2021-05-01T05:48:40.332400Z

Well anyway, I guess I've done all the set-up except installing Doom Emacs. I should find out how difficult it is.

seancorfield 2021-05-01T05:48:50.332600Z

Your choice 🙂

FHE 2021-05-01T05:49:12.332800Z

I really wish the Ubuntu in WSL2 was the standard GUI kind. Why would be a stripped-down CLI-only thing??

FHE 2021-05-01T05:49:32.333Z

Does it have to be?

seancorfield 2021-05-01T05:49:49.333200Z

Linux (and Unix before it) were all originally non-GUI. GUIs are way over-rated.

FHE 2021-05-01T05:50:49.333400Z

I'm find with CLI for a few CLI commands, like just running a program, but I would rather run that from within a GUI window with a CLI in it, in a GUI OS.

seancorfield 2021-05-01T05:51:05.333600Z

I'm on recent Windows Insiders builds now and have the updated WSL2 that supports X11 GUI apps out of the box. You could always install VcXsrv (Xlaunch) or X410 on Windows to run your X11 GUI apps from WSL2 🙂

FHE 2021-05-01T05:51:26.333800Z

Seems like a bait-and-switch to even call the OS in WSL2 (or that 'app') 'Ubuntu' when it's missing a huge chunk of it (all the GUI stuff).

seancorfield 2021-05-01T05:51:56.334Z

It's not really missing anything.

FHE 2021-05-01T05:51:58.334200Z

Why would it not just look like the other 3 or 3 times I've used Ubuntu?

FHE 2021-05-01T05:52:05.334400Z

3 or 4

seancorfield 2021-05-01T05:52:16.334600Z

Windows just didn't support WSL2 GUIs until these recent Insider builds.

FHE 2021-05-01T05:52:43.334800Z

A Ubuntu live CD will boot directly into a GUI, from my experience. Why would the WLS2 version be different?

seancorfield 2021-05-01T05:53:02.335Z

They're not even comparable.

FHE 2021-05-01T05:53:09.335200Z

strange. They should at least have a modified name for it. ...Ubuntu-CLI

seancorfield 2021-05-01T05:53:25.335400Z

WSL2 runs user-mode Linux distros. Not just Ubuntu.

FHE 2021-05-01T05:53:39.335600Z

user-mode?

seancorfield 2021-05-01T05:54:46.335800Z

I've never run a GUI on Linux. I've never seen the point. And when I got started with Unix flavors, they mostly didn't have GUIs at all.

FHE 2021-05-01T05:56:51.336300Z

I don't really mean GUI apps. I just mean the basic GUI OS. You know...like a file explorer, and a start-menu-type thing?

seancorfield 2021-05-01T05:57:11.336500Z

That's a window manager/shell. It's just an app.

seancorfield 2021-05-01T05:57:22.336700Z

The "OS" doesn't have a GUI.

FHE 2021-05-01T05:57:49.336900Z

Oh wait...I see an actual desktop there. Would not have called that an 'app'.

seancorfield 2021-05-01T05:58:32.337100Z

That article shows the Windows desktop, running several Linux GUI apps. Not a Linux window manager/desktop.

FHE 2021-05-01T05:58:41.337300Z

To me, 'apps' are things you can launch from a CLI or by picking something from a start menu or double-clicking an executable in a file manager.

FHE 2021-05-01T05:59:08.337500Z

I would never have considered the actual menu or file explorer 'apps', but I guess one could.

FHE 2021-05-01T05:59:18.337700Z

Oh. OK

FHE 2021-05-01T05:59:41.337900Z

Sounds like they're almost there. Ha.

seancorfield 2021-05-01T06:00:15.338100Z

The latest builds have full sound and video integration between Linux and Windows. It's pretty impressive.

seancorfield 2021-05-01T06:00:59.338300Z

I have Google Chrome (Linux) installed and it behaves just like a Windows app in terms of launching it from Windows -- or from Linux.

seancorfield 2021-05-01T06:01:29.338500Z

I run Reveal from my Clojure REPL and it pops up as a (Linux) GUI.

FHE 2021-05-01T06:02:00.338700Z

I set up the cljs quickstart thing. Is there a browser I can launch in WSL2 (while stuck on the clojure CLI!) to see my process? A browser on Windows can't see it, it seems like.

seancorfield 2021-05-01T06:02:09.338900Z

But I like having VS Code as a native Windows experience, but having all my files, REPLs etc running on WSL2 -- because I can avoid the problems with Windows command-line.

seancorfield 2021-05-01T06:02:37.339100Z

That article explains how to install Google Chrome or Microsoft Edge on WSL2.

FHE 2021-05-01T06:02:38.339300Z

...though I would have guessed maybe something like localhost:9000 in WSL2 might be visible in Windows too.

seancorfield 2021-05-01T06:02:59.339500Z

(but you'll need to be on recent Insider builds)

FHE 2021-05-01T06:03:35.339700Z

OK. Something else to attack tomorrow, after trying to install Doom Emacs. Ugh...I took so long to get that set up. Like...days. I took lots of notes though. Here's hoping. 😕

seancorfield 2021-05-01T06:03:35.339900Z

Or, as I said earlier, install X410 or VcXsrv/Xlaunch and you can run X11 apps on WSL2 and the GUI will appear "on Windows".

FHE 2021-05-01T06:04:34.340100Z

Wait a minute...so you're saying with a WSL2 installation from just a few months ago there is NO WAY to get it live-updating a browser?

seancorfield 2021-05-01T06:04:37.340300Z

ClojureScript starts Google Chrome (on WSL2) for me -- either via the quick start or figwheel or shadow-cljs

seancorfield 2021-05-01T06:04:53.340500Z

No, I'm not saying that.

FHE 2021-05-01T06:05:01.340700Z

I mean assuming I'm using Emacs and not that specific VSCode functionality.

FHE 2021-05-01T06:05:18.340900Z

The quickstart isn't doing it.

seancorfield 2021-05-01T06:05:22.341100Z

I have no idea how to get Emacs-on-Windows to talk to the WSL2 filesystem.

FHE 2021-05-01T06:05:33.341300Z

I just ran

FHE 2021-05-01T06:05:34.341500Z

clj --main cljs.main --compile hello-world.core --repl

seancorfield 2021-05-01T06:05:48.341700Z

Of course it isn't: you don't have an X Windows server running on Windows to support GUI apps on WSL2 do you?

seancorfield 2021-05-01T06:07:31.341900Z

Months ago -- long before this latest Wayland stuff -- I was using VcXsrv on Windows to support WSL2 GUI apps and had Google Chrome installed (on WSL2), and the live-update-in-the-browser thing works fine with that.

FHE 2021-05-01T06:07:37.342100Z

I'm not worried about the editor just yet.

FHE 2021-05-01T06:07:53.342300Z

I've set up the quick start stuff just using vim on WSL2

FHE 2021-05-01T06:08:22.342500Z

So I also tried this (since no browser auto-opened), but how can I launch one?

FHE 2021-05-01T06:08:25.342700Z

If you are running Linux and the REPL does not start, try disabling browser auto-launch and opening <http://localhost:9000> manually:

clj --main cljs.main --repl-opts "{:launch-browser false}" --compile hello-world.core --repl

seancorfield 2021-05-01T06:08:50.342900Z

Because from the Windows side, WSL2 is not "localhost", it has it own IP address.

FHE 2021-05-01T06:08:55.343100Z

How can a person launch anything when the CLI has been taken over by a REPL anyway??

seancorfield 2021-05-01T06:09:16.343300Z

Run multiple terminal windows?

FHE 2021-05-01T06:09:21.343500Z

That makes sense. But what about a WSL2 browser?

FHE 2021-05-01T06:09:33.343700Z

Seems like one was supposed to auto-launch with the first command.

seancorfield 2021-05-01T06:09:34.343900Z

Microsoft's new Terminal has tabs which is what I use.

seancorfield 2021-05-01T06:09:45.344100Z

Do you have an X11 server installed on Windows?

FHE 2021-05-01T06:10:24.344300Z

I did install that, but it is only offering me PowerShell, Command Prompt, or some Azure thing....no WSL2 as promised.

seancorfield 2021-05-01T06:10:34.344500Z

As I said above: months ago I was running Google Chrome on WSL2 with VcXsrv on Windows and the quick start worked fine, starting Google Chrome on WSL2.

FHE 2021-05-01T06:10:40.344700Z

Install Terminal, I mean.

FHE 2021-05-01T06:10:49.344900Z

No idea about an X11 server.

FHE 2021-05-01T06:11:11.345100Z

VcXsrv...ok

seancorfield 2021-05-01T06:11:25.345300Z

When I installed it, Ubuntu (WSL2) was available in Terminal. I edited the Terminal config to make it the default.

FHE 2021-05-01T06:12:26.345500Z

I just found this. I might try it tomorrow:

seancorfield 2021-05-01T06:12:59.346Z

Here's my new tab menu in Microsoft Terminal:

FHE 2021-05-01T06:14:24.346200Z

But OMG the goalposts just keep moving on me. It's demoralizing. New, unexpected tasks: (1) Figure out how to get a second WSL2 CLI (when Terminal isn't offering it). (2) Figure out how to get a browser running in WSL2. (3) Figure out what X11 is an how to get that going. (4) Figure out how to get Doom Emacs installed on WSL2.

seancorfield 2021-05-01T06:15:22.346400Z

Life as a software developer. Always new hills to climb.

FHE 2021-05-01T06:15:23.346600Z

I could almost swear I had that same top menu item (Ubuntu) in my Terminal right after I installed it....but it's not there now.

seancorfield 2021-05-01T06:16:10.346800Z

Pretty much every week I find new stuff I have to learn how to do -- and I've been at this professionally for 40 years 🙂

FHE 2021-05-01T06:16:54.347Z

I wouldn't mind new hills to climb to do more advanced stuff, but at this point I'm weeks and weeks in and still just trying to get a single line of code to take shape in a browser.

FHE 2021-05-01T06:18:16.347200Z

I don't doubt that this way will eventually be 'better' than the Windows-centric way I did my first little webpage program, but it is so far 20x the work to set up.

seancorfield 2021-05-01T06:18:53.347400Z

Clojure isn't easy to work with. None of its tooling is designed to be easy. And Windows just makes things harder.

FHE 2021-05-01T06:19:34.347600Z

If all of those things on my to-do list don't come easily, I might just give up on WSL2 and just set up dual boot with standard Ubuntu.

FHE 2021-05-01T06:20:04.347800Z

I'm not seeing any point of sticking with Windows now

seancorfield 2021-05-01T06:20:17.348Z

If you're comfortable using Ubuntu "natively" that might well be easier. Last time around you seemed pretty resistant to using Linux at all and you seemed determined to stay on Windows.

seancorfield 2021-05-01T06:21:05.348200Z

If you're happy to move off Windows for Clojure development, it would all be easier. Both Linux (native) and macOS are much more common in the Clojure world and so it's much easier to get everything to work on those platforms.

seancorfield 2021-05-01T06:21:28.348400Z

I would never have considered Windows as a development platform if it wasn't for WSL.

FHE 2021-05-01T06:21:45.348600Z

I wouldn't say I was ever determined to stay on Windows. I just had made a program from within Windows and really just wanted to get into something with some good project management features and live browser updating. I did not expect it to take such a change to get that.

FHE 2021-05-01T06:21:50.348800Z

...or does it have to?

seancorfield 2021-05-01T06:22:01.349Z

But I want a non-Linux desktop OS because the UX is just so much better than Linux's weird window managers etc.

FHE 2021-05-01T06:22:38.349200Z

I thought it would be as simple as shadow.cljs (or Leiningen and figwheel-main) and Emacs+CIDER and good to go.

seancorfield 2021-05-01T06:23:16.349400Z

When I use Linux, I use the terminal only. It's what I originally liked about OS X: nice, modern GUI OS with modern apps but a full *nix terminal under the hood. And that was how I had my Macs setup back in the System 6 / System 7 days too.

seancorfield 2021-05-01T06:24:07.349600Z

On macOS or Linux, yes, it would be that simple / good to go. But very few Clojure tools are designed to work on Windows because very few Clojure developers use Windows.

FHE 2021-05-01T06:24:24.349800Z

Some people just use those from within Windows without WSL2, don't they? Or are there really zero people who have ever made a program more advanced than mine from within Windows without WSL2?

FHE 2021-05-01T06:24:56.350Z

I think you just answered my question while I typed it.

seancorfield 2021-05-01T06:26:22.350200Z

From the 2021 State of Clojure survey results:

FHE 2021-05-01T06:26:31.350400Z

Kind of unbelievable that Windows has the market share it has and comes preinstalled on so many computers but is not supported well for programming. The situation is an unfortunate barrier to entry to programming.

seancorfield 2021-05-01T06:26:47.350600Z

Windows was designed for consumers, not programmers.

FHE 2021-05-01T06:26:52.350800Z

Hey 4.77%. I wonder what they do?

seancorfield 2021-05-01T06:27:11.351Z

Microsoft are doing great work these days making Windows viable for programmers.

raspasov 2021-05-01T06:27:16.351200Z

Well, I assume it’s decently supported for C# stuff? (I have never used C# professionally, that’s just an assumption)

seancorfield 2021-05-01T06:27:40.351400Z

Sure, with fancy button-clicking UI-based IDEs.

FHE 2021-05-01T06:27:56.351600Z

I'm not married to Windows. I've had (secondary) computers running only Ubuntu before (GUI though). My opinion regardless.

FHE 2021-05-01T06:28:39.351800Z

Yeah maybe it's just my dumb luck I came down to a programming language that is extra hostile to Windows.

raspasov 2021-05-01T06:29:31.352Z

If I were you, I’d use Ubuntu (I have used it in the past); I bet most things there with JVM + Clojure should “just work”

FHE 2021-05-01T06:29:59.352200Z

I've been meaning to dual boot for ages anyway. But before I go to that. Does this sound like the full list of doable things I have left to get going with WSL2? (1) Figure out how to get a second WSL2 CLI (when Terminal isn't offering it). (2) Figure out how to get a browser running in WSL2. (3) Figure out what X11 is an how to get that going. (4) Figure out how to get Doom Emacs installed on WSL2.

raspasov 2021-05-01T06:30:19.352400Z

Also, I’m biased, but if you also use IntelliJ + Cursive, then things will also “just work”; Been using Cursive since ~2014 and I am a very happy user.

FHE 2021-05-01T06:30:29.352600Z

Well I'm going for ClojureScript, not Clojure. Does that matter?

raspasov 2021-05-01T06:30:42.352800Z

I’ve seen the “problems” most other people run with in other editors and I just shake my head 🙂

raspasov 2021-05-01T06:30:47.353Z

Yes, that’s supported also.

FHE 2021-05-01T06:31:17.353200Z

And you're running that on just a GLinux machine?

seancorfield 2021-05-01T06:31:21.353400Z

I can't speak to Cursive -- I don't like IntelliJ at all (and I've tried a lot of different releases of it). Editors are very subjective.

raspasov 2021-05-01T06:31:22.353600Z

MacOS

FHE 2021-05-01T06:32:00.353800Z

Ah. Same thing when it comes to all these programming tools, though, yes? *nix?

raspasov 2021-05-01T06:32:01.354Z

@seancorfield What specifically do you not like about it? (I realize, it needs a fast computer with a lot of RAM)

seancorfield 2021-05-01T06:32:08.354200Z

Yeah, macOS is far and away the easiest setup for Clojure and ClojureScript. Pure Linux is probably second easiest. Windows is just hard.

seancorfield 2021-05-01T06:32:42.354400Z

@raspasov I'm not much of a fan of IDEs at all and I just find IntelliJ to be slow and bloated and weirdly organized.

FHE 2021-05-01T06:32:58.354600Z

That's sad if true. Most difficult OS to get is the easiest to use for this?

seancorfield 2021-05-01T06:33:17.354800Z

I've never liked its UI. I preferred Eclipse over IntelliJ (and I don't like Eclipse much either).

seancorfield 2021-05-01T06:33:31.355Z

macOS is easy to get. It's just expensive 🙂

FHE 2021-05-01T06:33:43.355200Z

Should I just try to run MacOS instead of Ubuntu on this ThinkPad? LOL

raspasov 2021-05-01T06:34:02.355400Z

Yea I agree it’s bloated… I don’t use 99% of it’s stuff, but the Cursive stuff just works for me. Also, run very minimal UI for it:

seancorfield 2021-05-01T06:34:54.355600Z

Although the recent shift to M1 chips means quite a few things don't work yet I believe. Not the first time Apple's done this. I started on 680x0 chip Macs, went through the RISC chip switch, then went through the Intel chip switch.

raspasov 2021-05-01T06:35:28.355800Z

MacOS on ThinkPad…. I can sense that can be another week-long project 🙂

FHE 2021-05-01T06:35:35.356Z

Yeah I'm on a nvm-e drive here, so no go for MacOS?

raspasov 2021-05-01T06:35:39.356200Z

(I would say no, unless you’re just keen on tinkering)

FHE 2021-05-01T06:36:00.356400Z

'week-long' would be a fantastic relief at this point. 😕

FHE 2021-05-01T06:36:50.356600Z

So anyway, how long should I give that to-do list above before throwing in the towel on WSL2 and just dual-booting?

raspasov 2021-05-01T06:37:43.356800Z

Yes, I heard M1 had some problems, but anecdotal reports say most things work already; But I have no first hand experience (yet).

FHE 2021-05-01T06:37:51.357100Z

Is my list about right? No more surprises? ...at least until after I try to do something more advanced than hello world in a browser through WSL2? lol

raspasov 2021-05-01T06:38:41.357300Z

Sorry, I can’t really judge or make a call about Windows/WSL2. Never tried it. But my recommendation about Ubuntu, in general, still stands, given your current hardware.

seancorfield 2021-05-01T06:38:59.357500Z

Here's what my Clojure dev looks like on Windows/WSL2 with Reveal:

seancorfield 2021-05-01T06:39:51.357700Z

That's VS Code native on Windows, Reveal running as an X11 app and a Socket REPL started from the command-line in Ubuntu.

FHE 2021-05-01T06:40:09.357900Z

Reveal? New terms today: x11, vxm..whatever that term was, and reveal.

seancorfield 2021-05-01T06:40:28.358100Z

https://github.com/vlaaad/reveal/

seancorfield 2021-05-01T06:40:48.358300Z

I used Cognitect's REBL before that for visualizing results of evalutions.

FHE 2021-05-01T06:40:54.358500Z

WOW...it got late. Will probably have kids waking me up in two hours. Better go. Thanks for the help so far. Will definitely check this space again tomorrow, and update you on my fight.

2021-05-01T07:50:48.362900Z

Hi everyone. I've been trying to use lmax disruptor in a Clojure project, where as I understand publishing to the ring buffer requires deep copying objects to pre-allocated slots on off-heap memory. How can I achieve that with Clojure collections (map, vectors, etc) ? Thanks in advance.

2021-05-01T09:25:08.363Z

The disruptor I think is meant to be used with mutable objects to save on object allocation

2021-05-01T09:25:44.363200Z

So I don't think you can use it with Clojure immutable data-structures

2021-05-01T09:30:04.363400Z

Though you could create an event that has a Clojure Map as a field on it, but make sure you clear it after use like it says in the user guide

2021-05-01T09:45:12.363600Z

@didibus If I create a class with clojure data structures as its field : • does the pre-allocation work correctly ? • when I set that field with some clojure collection, are they copied onto the off-heap location ? or is it merely their reference that is passed ?

2021-05-01T09:46:14.363800Z

@didibus Also what did you mean by "clearing it after use" ? did you mean to clear the offsets on the ring-buffer ?

2021-05-01T09:46:22.364Z

Thank you @didibus

2021-05-01T09:58:24.364400Z

The data isn't copied off heap

2021-05-01T09:58:56.364600Z

It's more like an EventPool similar to having a ThreadPool

2021-05-01T09:59:51.364800Z

So if your ring buffer has 1024 slots, it'll pre-allocate 1024 events. That means it'll create all event objects when creating the RingBuffer and store them all in it.

2021-05-01T10:01:18.365100Z

When you publish to the Ring Buffer, you reuse the event objects already in it, so they have to be mutable

2021-05-01T10:03:26.365300Z

If you set a field on them with a Clojure collection, after you consume the event, the event object will continue to point to the Clojure collection and so it won't be garbage collected. So you need to clear it, after you consume the event you have to set the field back to null.

2021-05-01T10:05:52.366200Z

If you want to avoid even the GC pressure of creating Clojure collections, you can choose to put your own data off heap and set on the event the offset into your off heap byte buffer

zackteo 2021-05-01T10:06:21.367Z

Has anyone ever encountered such a problem before when trying to interop with a Java library?

1. Caused by java.lang.IllegalArgumentException
   Mismatched return type: defineConstraints, expected:
   [Lorg.optaplanner.core.api.score.stream.Constraint;, had:
   org.optaplanner.core.api.score.stream.Constraint
There's no such thing as Lorg.optaplanner.core.api.score.stream.Constraint in Optaplanner. So I am not sure where that Lorg came from

2021-05-01T10:06:30.367100Z

But you're not dealing with Clojure data-structures at this point, you've got your own custom memory layout and structure.

2021-05-01T10:06:57.367300Z

Or you can use only primitive fields on your Events.

2021-05-01T10:18:54.367500Z

[L means it's an array of org.opr...

zackteo 2021-05-01T10:20:52.367700Z

hmmm the exact code is

(defn ^ConstraintProvider -&gt;make-provider []
  (reify ConstraintProvider
    (^Constraint defineConstraints [this ^ConstraintFactory cf]
     (object-array [(room-conflict cf)
                    (teacher-conflict cf)
                    (student-group-conflict cf)]))))

2021-05-01T10:21:10.367900Z

So defineConstraints expected an array of Constraints but you gave it a single instance of Constraints instead

zackteo 2021-05-01T10:21:29.368200Z

right hmmm

zackteo 2021-05-01T10:22:01.368400Z

What should the type hinting be then ? 😮

zackteo 2021-05-01T10:23:19.368600Z

Like how do I translate this type Constraint[] ?

2021-05-01T10:24:09.368800Z

Exactly what the message says

2021-05-01T10:24:24.369Z

^[Lorg....

zackteo 2021-05-01T10:24:52.369200Z

You mean

(defn ^ConstraintProvider -&gt;make-provider []
  (reify ConstraintProvider
    (^Lorg.optaplanner.core.api.score.stream.Constraint defineConstraints [this ^ConstraintFactory cf]
     (object-array [(room-conflict cf)
                    (teacher-conflict cf)
                    (student-group-conflict cf)]))))

zackteo 2021-05-01T10:24:54.369400Z

right?

zackteo 2021-05-01T10:25:28.369600Z

That was what I tried previously. Just executed it again and got

1. Caused by java.lang.ClassNotFoundException
   Lorg.optaplanner.core.api.score.stream.Constraint

2021-05-01T10:26:09.369800Z

Hum... ok ya that was a guess of mine haha

2021-05-01T10:26:20.370Z

I think you might not need a hint

2021-05-01T10:26:37.370200Z

But you need to use the array function that takes a class

2021-05-01T10:27:00.370400Z

into-array I believe

zackteo 2021-05-01T10:27:08.370600Z

No worries 🙂 understanding the L part was helpful! May I know how you knew about it? Or just something to remember

2021-05-01T10:28:01.370800Z

https://clojure.org/reference/java_interop See Aliases it briefly mentions it and links to the Java doc for the various letters following [

zackteo 2021-05-01T10:28:25.371Z

the issue is that object-array will end up getting java.lang.Object same for into-array

zackteo 2021-05-01T10:29:43.371200Z

On that note ... is this a typo on that page For example, byte arrays (byte-array []) have a type of "[B".

zackteo 2021-05-01T10:29:56.371400Z

it is { instead of L

zackteo 2021-05-01T10:30:43.371600Z

wait no, seems to be a different thing ... i think

2021-05-01T10:30:55.371800Z

[B is array of bytes ya

2021-05-01T10:31:05.372Z

[L is array of reference to an object

2021-05-01T10:33:01.372300Z

Try this syntax: ^"[Lorg....Constraints;"

zackteo 2021-05-01T10:34:10.372500Z

It works! wow

zackteo 2021-05-01T10:34:58.372700Z

But I don't really know why

zackteo 2021-05-01T10:35:25.372900Z

But thanks! 🙂 I did think about changing it to a string when you gave that solution

zackteo 2021-05-01T10:36:44.373400Z

Thanks!!

2021-05-01T10:37:01.373600Z

Apparently that's the default syntax, and all others are actually a short-hand to this one. I learned that as well, so thanks for asking

zackteo 2021-05-01T10:38:05.373800Z

Hahaha tho not too sure this is level of interop with java is not the most common

zackteo 2021-05-01T10:39:22.374Z

Also, by any chance do you know what function I might want to use when a class I want to create has more fields than the constructor. Am currently using deftype

zackteo 2021-05-01T10:39:38.374200Z

Am doing

(deftype ^{PlanningEntity true} Lesson [^Long id ^{PlanningId true}
                                        ^String subject
                                        ^String teacher
                                        ^String studentGroup
                                        ^{PlanningVariable "timeslotRange"} ^:unsynchronized-mutable ^Timeslot timeslot 
                                        ^{PlanningVariable "roomRange"} ^:unsynchronized-mutable ^Room room]
  ILesson
  (getId [this] id)
  (getSubject [this] subject)
  (getTeacher [this] teacher)
  (getStudentGroup [this] studentGroup)
  (getTimeslot [this] timeslot)
  (setTimeslot [this t] (set! timeslot t))
  (getRoom [this] room)
  (setRoom [this r] (set! room r))
  
  Object
  (toString [this] id))

zackteo 2021-05-01T10:40:12.374400Z

But the equivalent part of the Java code is ...

@PlanningEntity
public class Lesson {

    @PlanningId
    private Long id;

    private String subject;
    private String teacher;
    private String studentGroup;

    @PlanningVariable(valueRangeProviderRefs = "timeslotRange")
    private Timeslot timeslot;
    @PlanningVariable(valueRangeProviderRefs = "roomRange")
    private Room room;

    public Lesson() {
    }

    public Lesson(Long id, String subject, String teacher, String studentGroup) {
        this.id = id;
        this.subject = subject;
        this.teacher = teacher;
        this.studentGroup = studentGroup;
    }

zackteo 2021-05-01T10:40:52.374600Z

So i shouldn't have timeslot and room in the constructor which I understand is what deftype will do

2021-05-01T10:44:21.374800Z

Hum... I don't know. Generally when I'm using a Java framework that expects me to pass it a Java class that derives from some of its class, Intend to just write it in Java and have it delegate to a Clojure namespace manually for cases where it gets hairy like this

zackteo 2021-05-01T10:45:43.375Z

Right :thinking_face: how does that work. I write the code as .java files?

2021-05-01T10:45:45.375200Z

Your case is even worse haha cause the framework seems to expects annotations

2021-05-01T10:45:51.375400Z

Yup

zackteo 2021-05-01T10:46:02.375700Z

Am following this https://quarkus.io/version/1.7/guides/optaplanner

2021-05-01T10:46:39.376100Z

Well, so normally you can have a separate source folder for Java source, and then you need your build setup to compile the Java sources

zackteo 2021-05-01T10:46:52.376300Z

Do I need to do any configuration in lein? Or can I just import the .java code hmmm

2021-05-01T10:46:57.376500Z

But... I remember seeing a Clojure.lib that could be nice for this.

2021-05-01T10:47:02.376700Z

Ya you do

zackteo 2021-05-01T10:49:01.377200Z

Wow, this is quite an undertaking ... let me try this out hmmmm

zackteo 2021-05-01T10:49:14.377400Z

But thanks for the link and for the help!! 🙂

zackteo 2021-05-01T10:49:51.377600Z

How one might want to do it within clojure still remains to be a question hmmm

2021-05-01T10:51:18.377800Z

You can look here too, so this is how in the Java shim you'd call to Clojure: https://github.com/puredanger/clojure-from-java/blob/master/java/cfj/Support.java

2021-05-01T10:51:34.378100Z

Using the Clojure Java API

2021-05-01T10:52:28.378300Z

So the Java code is just a shell to please your Java framework, and then in the implementation for its methods you'd use the Clojure Java API to call into one of your own Clojure functions inside your own namespace.

zackteo 2021-05-01T10:53:11.378600Z

Right hmmmmm

zackteo 2021-05-01T10:54:49.378800Z

pretty intense stuff 😅

2021-05-01T10:58:50.379100Z

Ya, sometimes some .framework have other ways not annotation based that are http://easier.to use.

2021-05-01T10:59:32.379400Z

Not sure if Quarkus would. The downside is tutorials in Java tend to always show the annotation based approaches.mostly

2021-05-01T11:00:15.379600Z

I can't seem to find the library I was thinking, it was basically a deftype that let you generate weirder Java classes

zackteo 2021-05-01T11:01:13.379800Z

Right right hmmm

zackteo 2021-05-01T11:01:33.380Z

I was considering wrapping this library actually - at least for my own project purposes first ...

zackteo 2021-05-01T11:01:59.380200Z

but seems like it is quite an endeavor and quite beyond my current skill level i think hmmm

2021-05-01T11:02:51.380400Z

Oh it was this: https://github.com/athos/JiSE but it seems it doesn't support annotations

2021-05-01T11:03:25.380700Z

Ya, that level of interop starts to require more knowledge of Java I think

2021-05-01T11:03:50.380900Z

And Clojure as well hehe

zackteo 2021-05-01T11:04:30.381100Z

Both of which I lack 😅 at least for now ... hahaha

2021-05-01T11:04:38.381300Z

Thanks This helped a lot

valerauko 2021-05-01T11:11:45.381500Z

I use (into-array LibraryClass my-vector)

zackteo 2021-05-01T11:14:48.381700Z

How does LibraryClass work o: what is it?

zackteo 2021-05-01T11:18:33.381900Z

@didibus also for such reasons, sometimes I wonder if I should take a deep dive into Java first to get a good foundation to do Clojure

valerauko 2021-05-01T11:20:00.382100Z

I use this where the java interop requires LibraryClass[] and my vector is only instances of that class. (LibraryClass is just my filler name, https://github.com/valerauko/iny/blob/49cbe8266bd23eec1cbd5259244badee97a05426/src/iny/http2.clj#L57-L65)

zackteo 2021-05-01T11:52:43.382600Z

Hmmm ... i see i see

zackteo 2021-05-01T14:10:53.382800Z

Am proud to say I managed to get it working @didibus https://github.com/zackteo/optaplanner-clj

👍 1
valtteri 2021-05-01T16:32:25.387100Z

I’m looking for a “smart way” to transform [0 2 5 10] into [[0 2] [2 5] [5 10]] where the tuples are always the “first and second”, “second and third”, “third and fourth” and so on. I’m pretty sure there’s some pretty way to accomplish this with core functions but so far I’ve only come up with ugly ways.

valtteri 2021-05-01T16:33:02.387200Z

Vector is not a necessity

yuhan 2021-05-01T16:35:24.387400Z

(partition 2 1 xs)

yuhan 2021-05-01T16:36:21.387600Z

or perhaps (map vector xs (rest xs))

valtteri 2021-05-01T16:37:09.387800Z

🙏 thanks!

valtteri 2021-05-01T16:39:25.388Z

TIL different arities of partition . Very handy

dpsutton 2021-05-01T17:25:57.389100Z

Read the doc strings of partition and partition-all carefully

valtteri 2021-05-01T18:18:19.389300Z

Yep. I’ve used partition previously for chunking but somehow missed how versatile it really is.

valtteri 2021-05-01T18:18:50.389500Z

Docstring tells it all… As usual 😉

dpsutton 2021-05-01T18:26:56.391200Z

Partition all will allow for smaller chunks at the end of you don’t have enough elements for a full partition. Very important if not dropping some elements is important

sova-soars-the-sora 2021-05-01T19:48:24.391700Z

@qythium could you please explain this use of map vector ... ? I don't really understand how it works

gorjusborg 2021-05-01T20:47:10.393300Z

got a silly clojurescript question... why is there a need for (.field) and (.-field)? I though interop docs would explain the reason, but I still don't get it

phronmophobic 2021-05-01T20:57:18.396100Z

One is calling the method named field and one is doing a field lookup. It's a cljs only feature since there's no similar ambiguity for interop on the jvm.

(.field obj)
;; equivalent js
;; obj.field()

(.-field obj)
;; equivalent js
;; obj.field

gorjusborg 2021-05-01T22:46:38.397500Z

thanks