Fork me on GitHub
#babashka
<
2023-11-01
>
Stephan Renatus12:11:03

heya. I’m trying to play with juji-io/editscript in bb, and I quickly ran into this error that I don’t understand

user=> (require '[editscript.core :as e])
clojure.lang.ExceptionInfo: defrecord/deftype currently only support protocol implementations, found: IPersistentCollection [at editscript/util/pairing.cljc:68:1]
would this be a bb shortcoming, or am I using a too-old version of something…? 😵

borkdude12:11:48

This is a bb being a subset of clojure problem

Stephan Renatus12:11:14

(😳 rereading my first question — I didn’t mean “shortcoming” in a derogatory way. I like using bb a lot.)

borkdude12:11:58

bb has clojure.data.priority-map built-in so if you can convince editscript to move to that, it might work :) or you can maybe patch editscript in userland by using alter-var-root or something to swap in that implementation

borkdude12:11:04

hehe, that's ok ;)

borkdude12:11:41

what you could try is add this file to your :paths and then rewrite that priority-map function to use clojure.data.priority-map

borkdude12:11:59

and if they are willing to have that in their project, they could add that as a .bb file which bb always loads first

borkdude12:11:08

oh it's .cljc already anyway

borkdude12:11:41

ah never mind, they use a heavy typed approach elsewhere in the code too

borkdude12:11:45

not going to work right now

borkdude12:11:05

there is a library by #C1DV21X9P which kinda does the same thing and it does work in bb

Stephan Renatus12:11:41

yeah I’ve noticed that one, I’ll give it a try. thanks again!

borkdude12:11:42

or deepdiff2

anovick15:11:26

Is there a GUI toolkit/library that can be used from babashka? a tk wrapper maybe?

borkdude15:11:56

do you really want a GUI or is TUI also fine?

borkdude15:11:04

in that case I would recommend bblgum

anovick19:11:22

Hi @borkdude! yes, I was thinking about GUI specifically... the interaction I thought about has: • an image/canvas • a slider control for tweaking the image • a button for OK/cancel and TUI doesn't support images (non-ASCII) or a slider control...

borkdude20:11:41

I'm not aware of any such tool, but perhaps a webview would do?

anovick22:11:41

@borkdude a WebView would certainly do... Not sure about generic tools (GNU?) that can create WebView windows, but maybe there's some Node.js library that can do that, and offer a Tk-like API for some minimal GUI functionality on the WebView. (In that case of interfacing with Node.js it'd be nbb instead of bb)

borkdude22:11:39

you could use scittle in a webview: https://twitter.com/borkdude/status/1581616844607086592 not sure exactly what is a good way to launch a webview though, perhaps something on Node.js indeed, or maybe bun or so: https://github.com/theseyan/bunview

borkdude22:11:07

(linked project doesn't seem to be very active)

Ingy döt Net16:11:10

This isn't a bb question specifically but for projects like bb that create binaries for multiple OSes... What are some good suggestions/resources for figuring out how to get everything working for WIndows?

borkdude16:11:27

run a test suite under Windows :)

Ingy döt Net16:11:22

Do you use a VM to run windows?

borkdude16:11:57

No, just CI mostly

borkdude16:11:20

I do have a Windows machine for testing, but when I didn't have it, I used to run a VM

Ingy döt Net16:11:31

I'm not just thinking about clojure fixes, but what environment to work in. What shell to use etc

Ingy döt Net16:11:30

Maybe I should get a cheapish WSL laptop...

borkdude16:11:40

Yeah I run WSL on my test machine

borkdude16:11:58

shell: I try to stick to just cmd.exe, I kinda dislike Powershell because it have too much "stuff"

borkdude16:11:20

I mean, for testing, not for developing like someone who would actually use Windows

Ingy döt Net16:11:57

I've actually shelled into a tmate session running in a GHA workflow before

Ingy döt Net16:11:08

but it was kind of a pita

borkdude16:11:31

If you can get windows running on CircleCi you might be able to log in while CI is running

borkdude16:11:36

You can also rent Windows desktops in the cloud, I believe that is how Alex Miller sometimes tests stuff

👀 1
Ingy döt Net16:11:26

@borkdude I assume you added windows support after linux and mac. how long did it take to get it working?

borkdude16:11:45

Not so long

lread16:11:35

I use GitHub Actions for my Windows CI. I use virtual machines for local Windows verification and troubleshooting. When I was on macOS I used Parallels, but now that I'm on Linux I use VirtualBox.

lread16:11:12

FWIW, my VM is Windows 10 and that seems good enough for now.

Ingy döt Net16:11:21

@borkdude do you find it easier to use cmd rather than Bash in WSL

borkdude16:11:13

No but to test Windows I don’t want extra tools to blur problems

Ingy döt Net16:11:17

@UE21H2HHD does WSL work in the vm?

lread16:11:23

For OS support, in gneral (forgetting native image) I find that macOS and Linux are similar enough that I sometimes skip macOS, but Windows is different enough that it is always worth testing.

Ingy döt Net16:11:42

My build system is rather complex and completely Makefile driven so I'd really want to build in the bash environment. But I'd also do stuff in cmd as it made sense.

lread16:11:44

> @UE21H2HHD does WSL work in the vm? I did try it once, but can't remember why I stopped the experiment, might be because my dev box is aging. So I just use plain old Windows usually with cmd.exe but if I need to troubleshoot something powershell specific, powershell.

Ingy döt Net16:11:07

I've never tried powershell

lread16:11:17

I use bb tasks instead of a make for cross-platform.

borkdude16:11:19

I avoid Makefiles and do everything with bb tasks which work in every OS

1
Ingy döt Net17:11:15

I'm unlikely to go that route, but makes sense for you of course

Ingy döt Net17:11:40

@UE21H2HHD Yeah I can't avoid macos as it is graalvm based.

👍 1
Ingy döt Net17:11:47

@UE21H2HHD I've never tried parallels. Did you like it? Did it work on aarch?

lread17:11:57

FWIW: For CI, I find GitHub Actions easier to setup. But I did spend some getting CircleCI creating native images on all 3 OSses for babashka process. So might be an interesting place to borrow from if you go for CircleCI.

lread17:11:00

Good question, dunno. I was happy with Parallels on my old 2013 intel based iMac.

Ingy döt Net17:11:09

I'll almost certainly stick with gha. done a lot of it.

👍 1
borkdude17:11:52

Note that GHA is fine for testing but you won’t be able to produce binaries for aarch64

Ingy döt Net17:11:31

I thought they added aarch support very recently

borkdude17:11:25

read the small letters

🙌 1
borkdude17:11:35

I go with Cirrus CI for aarch64 macOS

1
lread17:11:46

Also, we summarized some https://github.com/clj-easy/graal-docs/blob/master/doc/testing-strategies.adoc - probably worth a review if you haven't done so already.

👍 1
Ingy döt Net17:11:34

hmm parallels == $$

lread17:11:44

Oh ya, not free. I felt it was worth it at the time though. I might have been suffering some issues with VirtualBox, can't remember. Maybe try VirtualBox first if free is important. (I'm finding VirtualBox ok on Linux these days... so...)

lread17:11:40

@borkdude did you decide to buy the Windows box because you moved to an M1 mac?

jpmonettas17:11:52

interesting thread, what does people use to try programs on MacOS when you are on Linux?

borkdude17:11:22

@UE21H2HHD no I needed more CPU and ram than fit in any MacBook Pro at the time for work

👍 1
Ingy döt Net17:11:25

lol I got my old win11 vbox image running and password reset, then I went full screen and couldn't get out, so used the ctl+alt+F6 virtual terminal thing to kill vbox

Ingy döt Net17:11:12

I hate having to remember how to get vbox working reasonably well every couple years 😄

lread22:11:07

@U0739PUFQ I'm on Linux and am using VirtualBox to run macOS. But I think this is only technically legal if you are running on Apple hardware (which I am (long story (old hardware (deets on request)))). It was not easy to set up, and the macOS experience is not great, but I'm OK with it for small tests and troubleshooting. If you want to do serious dev work on macOS, I expect you should probably buy a Mac. If a Mac is your primary development box, an advantage is that you can set up VMs for Linux and Windows without too much trouble.

lread23:11:17

(or.. maybe this is not true anymore with M* macs!)

jpmonettas02:11:34

thanks @UE21H2HHD. I'm a debian user and just need a quick way of trying my open source work on macos when people report issues. I tried VirtualBox in the past but wasn't easy to get a macOS image and VBox params that worked

Ingy döt Net16:11:45

@borkdude, re https://github.com/babashka/babashka/releases do you end up paying bandwidth costs for these releases? I looked into this a bit yesterday and I saw there was a 1GB/mo limit. The graal native-image builds are kinda big so I was worried. Just dawned on me now to ask you about it wrt babashka

Ingy döt Net17:11:19

https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases#storage-and-bandwidth-quotas > Each file included in a release must be under 2 GiB. There is no limit on the total size of a release, nor bandwidth usage. That's good news. I think I must have seen the bandwidth usage re LFS.

ag18:11:34

At my new team we're using CockroachDB, I want to be able to send a query to CRDB server, e.g., cockroach sql --execute="SELECT * FROM blabla" and using babashka or jet convert the results to edn. What's the best way? Sadly, cockroach can't return results in json, it can in csv. also, AFAIK babashka has sqlite pod, but I'm not sure if that would work with Cockroach. Maybe I can send requests directly from bb script?

borkdude18:11:49

@U0G75ARHC nbb might be a good fit here, I'm sure there's a nice node.js library for cockroach, but if you want to do it using the cockroach CLI this can work too with bb.

(require '[babashka.process :as p])
(-> (p/shell {:out :string} "cockroach sql  --execute='SELECT * FROM blabla'")
    :out
    json/parse-string)

ag18:11:41

cockroach can't return json. It can do csv though

ag18:11:46

I'll try to find "nice nodejs library". I'm sure there'll be like 380 choices of which I could probably use two without hating myself. LOL

ag18:11:11

@borkdude you can't "embed" dependencies into your nbb script, so it can be shared as a single file, correct?

borkdude18:11:41

@U0G75ARHC no, you can't do this, but you can bundle it as a single file later

borkdude18:11:40

nbb bundle: https://github.com/babashka/nbb/tree/main/doc/bundle this packages the entire interpreter and yields about 1mb of JS. if you are looking for a smaller more lightweight solution, try #C03U8L2NXNC

borkdude18:11:07

you can create single files with squint too, using esbuild (similar to instructions in the nbb bundle docs)

ag20:11:01

whoa... you're like the White Rabbit, there's always some deep hole to fall into. LOL.

🐰 1
Ingy döt Net18:11:16

Is there a strategy for running bb on OSes not supported by graalvm? (freebsd etc)

borkdude20:11:13

unless you can get graalvm working on one of those OSes, there is an issue about this

borkdude20:11:30

you can run the uberjar but this is of course not optimal for startup time