Fork me on GitHub
#babashka
<
2023-04-25
>
mjhika04:04:05

Just wanted to share this with y'all

🎉 4
❤️ 2
pesterhazy07:04:30

Observation (not sure if this is a bug or intended behavior) In Clojure vectors have a contains method

user=> (.indexOf [100 101 102] 101)
1
user=> (.contains [100 101 102] 101)
true
In bb
user=> (.indexOf [100 101 102] 101)
1
user=> (.contains [100 101 102] 101)
java.lang.IllegalArgumentException: No matching method contains found taking 1 args for class clojure.lang.PersistentVector [at <repl>:3:1]

borkdude07:04:56

@U06F82LES We can add this, issue welcome

borkdude07:04:19

but usually I recommend using "pure" clojure and no interop on what might be implementation details

borkdude07:04:13

Not all of this interop is enabled by default to save binary image size

pesterhazy08:04:12

I went with some now

grav12:04:18

So this works:

$ echo '{"@foo":"bar"}' | jet --from json --keywordize
{:@foo "bar"}
but this crashes:
$ echo '{"@foo":"bar"}' | jet --from json --keywordize  | jet
Exception in thread "main" clojure.lang.EdnReader$ReaderException: java.lang.RuntimeException: Invalid constituent character: @
...

grav12:04:33

Is that expected? Ie that jet can output some edn that it cannot consume?

borkdude12:04:05

yes, in general it's possible to produce EDN in Clojure that you cannot read back, this is not specific to jet

👍 2
grav12:04:54

I guess I could keep keys as strings ... just surprised that @ is not "kosher" in edn

borkdude12:04:21

@ is not allowed in symbols and keywords as it expands to (deref ...) in normal Clojure

grazfather18:04:02

I am certainly playing both sides here (I like janet) but have you guys seen this post about using janet for shell scripting? https://janet.guide/scripting/ Maybe borkdude can get some ideas from it

👍 4
Frank Henard19:04:59

I have a friend who's real into Janet. I got him into lisp so I'll take some credit. He loves to build games with it. Do you use it for game programming?

escherize19:04:01

@U06BQ07JS do you know what he is using besides janet? raylib? I know tic80 has support for janet now, too.

Frank Henard19:04:55

https://alectroemel.com/ looks like tic80. I don't know what that is though

🙏 2
Frank Henard19:04:58

He mentions fennel, but maybe he's switched from that

escherize19:04:14

Ah yeah, looks like he didn’t blog about his janet project yet. his pancake simulator is hilarious: https://alect.itch.io/pancake-simulator

😀 2
grazfather19:04:13

I actually use it for much right now, but I did advent of code using it in 2021

borkdude20:04:39

babashka process has a similar $ macro but it faded away into the background as I found it too magical, just use process/shell , process/process and ->

borkdude20:04:42

I don't think it's great to shell out to thing like sed etc as babashka tries to encourage cross-platform scripting (scripts I write should work on mac, linux and windows)

👍 10
curtosis20:04:04

^^ avoiding the problem with “oh, your version is slightly different from the GNU version or default BSD version”

curtosis20:04:59

which devolves, distressingly often, into “just rub some autoconf on it”, and then it’s a whole Thing, and no longer a nice lil script.

grazfather21:04:35

yeah, that sed example is contrived though, he mentions PEGs right after

grazfather21:04:00

i agree that in both cases you want to do more of the logic, especially parsing, in lisp land

joakimen13:04:49

seems like it strikes an interesting middle-way, like it sits in-between shell-scripts and langs like python. personally I try to shell out as little as possible, so it kinda defeats the purpose for me.. But if I were to build my workflows around lots of different, unrelated cli tools then it looks like it'd be a good glue

grazfather13:04:14

I mostly use babashka for this niche, actually. Wrangling stuff into e.g. some curl invocation