Fork me on GitHub
#babashka
<
2019-10-26
>
borkdude22:10:40

Babashka v0.0.22: support for reader conditionals: https://github.com/borkdude/babashka#reader-conditionals

sogaiu22:10:14

seems to work here on linux:

$ ./bb examples/reader-conditionals.clj 
babashka doesn't support in-ns yet!

borkdude22:10:35

glad to hear!

sogaiu22:10:15

is the message in the example a hint? 🙂

borkdude22:10:34

this feature was built because Mauricio needed in-ns for his Chlorine editor

sogaiu22:10:47

ah, that's pretty cool

borkdude22:10:54

but bb can just ignore it because it hasn't got real namespaces yet

sogaiu22:10:16

so other clojures will ignore the :bb in reader conditionals?

borkdude22:10:19

there's also :default so you can do: #?(:bb 1 :default 10)

sogaiu22:10:04

yes, i learned about :default when doing clojure clr stuff -- and i also see it in some of your other code with :cljs first and :default later so possibly clojure clr support can work later, right? 🙂

borkdude22:10:44

if needed, of course 🙂

borkdude22:10:53

I've never really used it before

sogaiu22:10:29

i've used it a few times for some things that work for clr, jvm, js clojures

borkdude22:10:35

btw, sci and edamame also support reader conditionals now (via configuration)

borkdude22:10:52

so maybe we could also showcase this in sci.web

sogaiu22:10:18

ah, that sounds good

sogaiu22:10:26

on a related note, have you seen that clr clojure uses the pipe |?

sogaiu22:10:35

just wondering what the parsing might end up being like

borkdude22:10:47

I think that's a valid function name

sogaiu22:10:55

it isn't afaik

sogaiu22:10:04

there was a discussion recently about that

sogaiu22:10:16

at least it's not supposed to be according to alexmiller iirc

borkdude22:10:23

user=> (defn |? [])
#'user/|?

sogaiu22:10:40

what i'm saying is that it might happen to work, but it isn't officially supported

borkdude22:10:47

I don't see what's wrong with it

sogaiu22:10:12

well, it's already used in clojure clr for other purposes

borkdude22:10:26

do you have an example?

sogaiu22:10:28

look for text "Vertical"

borkdude22:10:31

> ClojureCLR extends the reader syntax I see, that's nonstandard. I wonder if tools.reader supports this

sogaiu22:10:45

i doubt it

sogaiu22:10:57

but there is a clr tools.reader iirc -- not sure how up to date it is

sogaiu22:10:22

iiuc, alexmiller is pretty aware of this state though based on a recent conversation

sogaiu22:10:25

here's a tools.reader for clr -- it's from some years back, but might have useful bits perhaps: https://github.com/clojure/clr.tools.reader

borkdude22:10:13

yeah, but if you're doing reader conditionals, all the readers should support the same features

borkdude22:10:30

for example, normal Clojure barfs on this:

user=> (read-string {:read-cond :allow} "#?(:bb 10 :cljr |System.Collections.Generic.IList`1[System.Int32]|)")
Execution error at user/eval143 (REPL:1).
Feature should be a keyword: 1

borkdude22:10:43

bb also barfs on it

borkdude22:10:10

so if you want to make programs .cljc compatible, they should not contain things that confuse the readers of other platforms

borkdude22:10:40

I think a string would maybe have been a better choice than the delimited pipe

borkdude22:10:55

maybe even a string with a reader tag

borkdude22:10:37

(reify #cljr/type "System.Collection.etc" ...)

borkdude22:10:14

but not sure if that was feasible at that time

borkdude22:10:57

also #|foo| would maybe have been better, at least it doesn't mess with vars/values starting with the pipe character

sogaiu22:10:53

pipe use predates reader conditionals by a fair bit iirc -- but i don't know the details 🙂

sogaiu22:10:48

not sure what the cognitect folks thoughts are, but there was a podcast with the main dev of clojure clr david miller a bit back where he talks about how it came to be -- may be you heard it? it seems possible that when reader conditionals were proposed the pipe char existence and use may have been understood.

borkdude22:10:24

do you mean the defn podcast? I have heard it, but I can't remember this detail

sogaiu22:10:38

yes, i think it was that one.

sogaiu22:10:30

it's not like there was something on reader conditionals or pipes there -- just that clojure clr was a kind of "blessed" project by cognitect or at least rich hickey from its infancy.

borkdude22:10:57

I know one company in the Netherlands who have been using ClojureCLR for 4 years. It was quite a surprise to discover them. They did a presentation and I saw clojure.spec.alpha.dll on the screen in a Windows explorer window

borkdude22:10:17

But they are migrating all their stuff over to the JVM now

sogaiu22:10:26

yes, i think he is one of the main users -- i've seen his posts on the google groups for clojure clr going back some years 🙂

sogaiu22:10:30

i can understand that.

sogaiu22:10:54

although in coming years, i think dotnet is likely to be seeing some growth.

borkdude22:10:22

Clojure is already a niche. ClojureCLR is a bigger niche and the tooling story there is much worse due to lack of manpower

sogaiu22:10:43

yes, no disagreement from me on those points 🙂

borkdude22:10:20

having said that, Clojure is a very hackable and tangible language, so you don't need much tooling

sogaiu22:10:59

it helps to have a good conceptual understanding of things -- which doesn't seem trivial to come by imho

borkdude22:10:12

the guy who did the presentation didn't have nREPL, so he just did (require '[foo.bar] :reload) every time he made an edit

sogaiu22:10:36

i have tooling that works with the socket repl on clojure clr and arcadia

sogaiu22:10:46

i also wrote a plugin for atom and an extension for vscode

borkdude22:10:14

so if I have any questions about vscode extensions, I know where to find you 🙂

sogaiu22:10:20

i am waiting for david miller to release the next version -- as that will contain prepl

sogaiu22:10:47

well on that point...my designs on that end have revolved around externalizing as much as possible to avoid doing things in editors

sogaiu22:10:54

the external programs are much more reusable

sogaiu22:10:07

and the apis within the editors vary and are not fun to work with

sogaiu22:10:23

i think more people can benefit this way

borkdude22:10:02

I've made only one extension for VSCode but I didn't know what I was doing half of the time. like context.subscribe.push(client.start());... wat?

sogaiu22:10:17

i saw you used typescript

sogaiu22:10:27

iiuc a fair bit of calva is done that way

sogaiu22:10:32

i went the cljs route

borkdude22:10:44

I used typescript because the lsp-sample was written in that

sogaiu22:10:03

yes, translating the samples can be a bit tricky

sogaiu22:10:55

inside this: https://github.com/sogaiu/adorn there are multiple bits -- one of them is a vscode extension in cljs if you are interested

sogaiu22:10:06

the external program is done as native-image

sogaiu22:10:31

the external program is used from atom, vscode and emacs

borkdude22:10:03

is this similar to clojure-lsp maybe?

borkdude22:10:32

conceptually I mean. clojure-lsp also uses rewrite-clj to do refactorings

sogaiu22:10:29

there are some similarities -- however a major difference is that iiuc lsp is into having a server running that does many things

sogaiu22:10:52

the approach i favor is separate pieces that do one thing and then exit

borkdude23:10:10

like sort namespace etc?

sogaiu23:10:43

i haven't worked on refactorings, but it should be quite doable

sogaiu23:10:02

the adorn thing is mostly a poc -- it just adds and removes inline defs

borkdude23:10:28

aah right, that was it

sogaiu23:10:00

there is also this one: https://github.com/sogaiu/abridge and possibly a few others i haven't released

sogaiu23:10:22

my motivation for getting native image stuff for clojure working on windows is related to these things 🙂

borkdude23:10:49

it would be nice to have an example in the README to see what it does

sogaiu23:10:29

you are right on that account -- however, with the state of native-image on windows, i wasn't inclined to going around advertising the existence just yet 🙂

borkdude23:10:14

that's one benefit of an LSP server I guess. you could also maybe hook up an LSP server and then execute the functions in a JVM on Windows, while having binaries on other systems

sogaiu23:10:31

yes, that was a good idea.

sogaiu23:10:58

if you don't mind the running a server aspect, the lsp approach has a fair bit of merit i think.

sogaiu23:10:15

i'm not big on that because of my past experience with other tooling that took a similar approach 😉

borkdude23:10:30

can you tell more about it?