Fork me on GitHub
#clojure
<
2021-12-03
>
fabrao02:12:50

anyone did some pipeline in Azure devops for Clojure?

emccue05:12:36

What are the pros/cons of using deps.edn aliases and tools for doing infra and build type work vs babashka

phronmophobic05:12:07

One of the big questions I have is how easy will it be to run these build scripts 5 or 10+ years from now. Clojure has a very good track record for stability, but a lot of the clojure deps tools are still new and, in some cases, still alpha. For babashka, there's a lot of questions for how easy it would be to update or continue running the same script 5+ years from now.

phronmophobic05:12:48

For some projects, that's not really a concern, but I've recently been updating some 10+ year old projects so it's fresh on my mind.

seancorfield06:12:51

Cons: startup time (JVM vs babashka). Pros: the CLI has a well-defined way to deal with any dependencies (whereas not all libraries work with bb). Just off the top of my head. For us, at work, we're not too worried about JVM startup time, even for scripts in infra/ops stuff and we vendor the CLI scripts/JARs into our repo so we can deploy specific versions via the same machinery as everything else in our repo. We have no platform-specific code in our repo right now, which is always a bit of a concern for me with native binaries.

borkdude07:12:58

In any case it should be easy to port babashka scripts to Clojure since a main goal of it is to be compatible with JVM Clojure. So even if you run into limitations, you should be able to port with minimal effort.

borkdude07:12:04

Another point: babashka can be used to launch Clojure. In that sense it’s not a replacement but something that helps you keep track of the various things you can run in your project with its task runner. Some people use Make but you can do this with bb‘s task runner.

borkdude07:12:44

So to your question: it’s not deps.edn aliases vs bb: it can be both: https://book.babashka.org/#tasks

1
lread12:12:19

Everyone is different but personally I like the startup speed and ergonomics of bb tasks. I have trouble remembering how to get a list of available tasks with tools.build but for bb it is bb tasks which presents me with a tidy list of what I can do including brief help. That said, I also do use tools.build, but I do use bb tasks as my front end. And of course, I also use deps.edn.

amithgeorge13:12:04

Yeah, use both. bb task calls alias defined in deps.edn which invokes build-clj to do the uberjar creation. As others mentioned, I like the discovery/ease of bb tasks.

borkdude13:12:56

The main goal of babashka is to replace the scripts that one would normally write in bash or python. But it’s gotten pretty far in supporting existing Clojure libraries.

emccue13:12:00

the biggest library requiring thing we would need would be to do aws automation

emccue13:12:24

and of the aws libraries out there we are partial to https://github.com/cognitect-labs/aws-api

emccue13:12:05

the reason i would lean toward clojure tools is mainly that i know stuff like this would work

borkdude13:12:48

@U3JH98J4R Babashka supports this API via https://github.com/babashka/pod-babashka-aws If startup time matters, then you could use that. If it doesn't matter, just use the JVM.

borkdude13:12:25

There is an in-progress port of this project to babashka from source here: https://github.com/grzm/yaaws-api/

emccue13:12:28

and regardless i could use babashka as a more general frontend to this stuff

emccue13:12:56

bb some:task -> clj -T build create-aws-thing :arg arg

borkdude13:12:24

yes, indeed

emccue13:12:29

and the short term benefit to that is i think 1. the commands get aliases 2. listable with bb tasks

borkdude14:12:21

The task runner can also be used to spawn multiple jobs at once. I've used this to set up my dev env: 1. One Clojure JVM app nREPL 2. One JVM process for building CLJS 3. One JVM process for building SASS

borkdude14:12:38

And then all I need to have them all three is: bb dev

😎 1
amorokh06:12:05

@fabrao We have a bunch of ADO pipelines at work

danielgrosse08:12:31

How can I take each entry of a row a group the columns? Like

[[a b c] [d e f]] => [[ad] [be] [cf]]

Ben Sless08:12:28

map can take multiple arguments. apply can be used to take the row apart Which function would you map over the entries to transpose them?

danielgrosse08:12:22

I'm not really sure how to use this. So as vector the input above is meant? So I end with map on every entry with this?

Ben Sless08:12:21

If you think about it like transposing a matrix (which it is), a matrix is a vector of vector, you want to create a vector of new vector where every element corresponds to a cross-section of the other vectors So we want a function to take the nth element from every vector, meaning we have to (map ??? v1 v2 v3) Since the vectors are in a vector, we need to use apply (apply map ??? [v1 v2 ... vN]) Then, ??? will receive N elements, in order, and needs to return them in a vector Which function does that? vector

borkdude09:12:49

Are you doing Advent of Code? ;)

danielgrosse21:12:07

Yes. And I use babashka for it.

🎉 1
hiredman08:12:38

(partial apply map vector)

Carlo13:12:32

what library would you use to parse the incoming midi stream from an electric piano?

borkdude14:12:36

@UCFG3SDFV mentions MIDI in the README of binf but I'm not sure if it has built-in support

Adam Helins15:12:08

I worked a lot with MIDI from CLJC, yes 🙂 The Java API works but is a bit cumbersome. If platform doesn't matter, I recommend the WebMidi API in the browser because it's very minimalistic. You plug your input device, add a callback, and receive your MIDI events as raw Uint8Arrays. For parsing those binary MIDI message, I use https://github.com/helins/binf.cljc Actually, MIDI was one of the primary reasons behind writing this lib! It's CLJC + Babashka friendly. It implies knowing a bit the MIDI 1.0 protocol but it's really not that hard, especially since you often only need to deal with only a few type of events. Studying that will take you further than using the Java API which is more convenient at first but then shows its limits. I tried writing a MIDI lib but it's quite hard to come up with something that is truly generic given the wide variety of apps you might want to write. Just for fun, an animation written in Clojure I did some time ago: https://www.youtube.com/watch?v=XlEnrs0MDes

👍 4
p-himik15:12:28

One small thing to note about Web MIDI API is that it's still experimental and not all modern browsers support it.

borkdude15:12:12

web midi also works with Node and it could possibly be used from #nbb :)

Adam Helins15:12:39

Yes, unfortunately only Chromium-based browsers support it. But the API has been kind of stable for a long time, probably because it is so minimalistic (and will most likely remain so).

Carlo19:12:33

thanks for all the answers! ☺️

mateus.henrique.brum17:12:13

Hello people. Can someone tell me why this does not work in a lein project?

(defn -main [& _]
  (map println [1 2 3]))
lein run Thanks !!!!!

dpsutton17:12:12

@mbrum there’s a #beginners channel that could probably walk you through this better

mateus.henrique.brum17:12:53

Cool, I will post there, but do you know why @dpsutton ??

dpsutton17:12:05

i sure do. and i’ll tell you in #beginners

😄 6
vncz17:12:46

Is there a quick function that does if 0 then 1 else 0 ?

🎄 3
Ben Sless18:12:07

#(- 1 %)

👏 4
vncz17:12:50

Basically swapping 0 for 1

vncz17:12:53

and viceversa

ghadi17:12:04

define "quick function"

vncz17:12:13

Something included in Clojure, that’s what I meant :)

ghadi17:12:03

(fn [arg] (if (zero? arg) 1 0)) (get {0 1} arg 0)

p-himik17:12:19

#(bit-xor % 1)

👍 2
☝️ 1
vncz17:12:13
replied to a thread:define "quick function"

Something included in Clojure, that’s what I meant :)

Stuart18:12:46

({1 0 0 1} 1) => 0
({1 0 0 1} 0) => 1

nbardiuk19:12:32

#([1 0] %) vector can be used as a function from index to value. So just [1 0] should work

borkdude21:12:04

#(mod (inc %) 2)

ryan22:12:45

#(* -1 (dec %))

Jelle Licht23:12:57

Anybody aware of a proxy that supports adding (Runtime) annotations to the generated class? Asking for a lost soul dealing with enterprises Java frameworks that uses a lot of these