babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
pez 2021-04-15T08:45:13.176200Z

babashka.fs has file-name but no dir-name or am I missing something?

borkdude 2021-04-15T08:47:17.176600Z

@pez

$ bb '(fs/file-name (fs/real-path "."))'
"babashka"
file-name just means the name part of a path

borkdude 2021-04-15T08:51:04.176800Z

The docstring also says that: Returns the name of the file or directory.

pez 2021-04-15T08:51:54.177200Z

Yeah, so it is like basename, right?

borkdude 2021-04-15T08:52:18.177700Z

This naming is also used by the java.nio.file package itself: https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html#getFileName() The functions in babashka.fs are usually named after those

borkdude 2021-04-15T08:53:08.178600Z

I have seen different implementations of basename. Sometimes they do what fs/file-name do, but sometimes they also strip the extension. I follow java.nio.file as much as possible in babashka.fs.

pez 2021-04-15T08:56:28.180Z

I’m looking for the equivalent to dirname. Given a full path it returns the directory part of it:

$ dirname /Users/peter/Projects/my-proj/README.md
/Users/peter/Projects/my-proj

pez 2021-04-15T08:58:12.181600Z

(Given a path to a directory it returns the parent directory. So seems like it uses the same semantics as babashka.fs/file-name)

borkdude 2021-04-15T09:03:34.181800Z

@pez

$ bb '(fs/parent (fs/real-path "."))'
#object[sun.nio.fs.UnixPath 0x27773e47 "/Users/borkdude/dre/DocSearch"]

πŸ‘ 1
sh54 2021-04-15T09:16:21.185Z

@borkdude Thanks for getting all the things for https://github.com/babashka/babashka/issues/784 in so fast! I was about to add the aset-byte and related functions by myself but you were too quick. I was writing a few tests for them at the same time so could always submit that. But I guess testing stuff defined via copy-core-var is fairly low value right? There are assumedly tests on the core functions which cover the logic

borkdude 2021-04-15T09:18:03.185500Z

@slack1003 True. Unless you expect GraalVM to behavior potentially weird with these functions

sh54 2021-04-15T09:26:35.186900Z

Dunno the GraalVM limitations well at all. All its doing is calling setByte (etc) on Array which surely graal can handle alright.

borkdude 2021-04-15T09:27:05.187400Z

@slack1003 In #babashka-circleci-builds you can test the newest build from master

sh54 2021-04-15T09:28:48.188600Z

@borkdude i’ll give it a quick run. so 76e2a241e767de2f38ac64c6f8a7e58be92fdd71 includes the latest sci changes then? Guess it gets triggered when sci updates?

borkdude 2021-04-15T09:30:03.189100Z

@slack1003 it's triggered when I commit to babashka and I have committed the latest sci changes

sh54 2021-04-15T09:32:45.190100Z

@borkdude yup works for me! only tested aset-byte on macos but all the others all go on the same principle

πŸŽ‰ 1
pez 2021-04-15T09:45:16.193900Z

fs/parent seems to be what I was looking for.

bb '(str (fs/parent "/Users/peter/Projects/my-proj/README.md"))'
"/Users/peter/Projects/my-proj"

sh54 2021-04-15T10:04:47.198400Z

hmm some funky behavior around combining print and System/exit. This program produces no output on my machine: #!/usr/bin/env bb (print "hello world") (System/exit 0)

sh54 2021-04-15T10:05:19.198700Z

But will if println is used instead

sh54 2021-04-15T10:06:45.200Z

I have a case where I am just calling bb on a subprocess script and dumping output, err, and then exiting with the returned exit code

sh54 2021-04-15T10:07:03.200300Z

and noted I was not getting output if I was using print

sh54 2021-04-15T10:07:53.200700Z

though works fine if I call (flush)

sh54 2021-04-15T10:08:19.201300Z

I literally never use print so not sure if this is normal behavior or bb specific

borkdude 2021-04-15T10:15:39.201800Z

@slack1003 This is expected behavior, it behaves the same in Clojure

sh54 2021-04-15T10:17:00.202700Z

k nice. never really use it so don’t remember the behavior. I added a flush to my stuff

borkdude 2021-04-15T10:48:01.202900Z

babashka 0.3.5 https://github.com/babashka/babashka/blob/master/CHANGELOG.md

littleli 2021-04-15T11:01:20.204200Z

how much would including of java.security.SecureRandom add to a size of the babashka binary? DONE

borkdude 2021-04-15T11:01:33.204500Z

@ales.najmann I just added that in 0.3.5 :)

littleli 2021-04-15T11:01:57.205Z

πŸ˜„ cool

littleli 2021-04-15T11:05:32.205800Z

so hopefully, I'll have, in few days, an example of the partial homomorphic encryption scheme written for babashka

littleli 2021-04-15T11:06:04.206Z

but bear with me, I'm terrible coder.

borkdude 2021-04-15T11:07:20.206300Z

babashka doesn't care about your coding skills

borkdude 2021-04-15T11:07:34.206500Z

looking forward to it :)

borkdude 2021-04-15T11:10:09.207100Z

bb 0.3.5 somewhat simplified my work bb.edn, by allowing to invoke tasks in parallel using #{p1 p2}, thanks @maxp https://gist.github.com/borkdude/35bc0a20bd4c112dec2c5645f67250e3#file-bb-edn-L17

borkdude 2021-04-15T11:58:55.207700Z

Helins 2021-04-15T16:54:19.212500Z

To be more precise, @borkdude added support for ByteBuffer and all the typical classes that implement it. Hence this is more significant than just BinF. Just one example, @ericihli has recently announced a trie implementation that uses ByteBuffer. Well now who knows, maybe that kind of code can run in BB without any adaptation.

borkdude 2021-04-15T16:54:40.212700Z

Do you have a link to it?

Helins 2021-04-15T16:55:19.213Z

borkdude 2021-04-15T16:55:48.213300Z

ok, that probably doesn't run as bb doesn't have deftype

Helins 2021-04-15T16:56:58.214500Z

It was worth a shot πŸ˜› But point is, it probably opened the door for a new set of existing libs

borkdude 2021-04-15T16:57:10.214700Z

yep, that's always nice :)