Fork me on GitHub
Alex Miller (Clojure team)00:08:41

I think the version on the site is an older version of Clojure, like 1.4 or 1.5 so you may find a few differences like this


oh right you can't use transducing arities on 4clojure, I always forget


I suspected that, but it doens’t say which version is using, do you guys have any good vids for transducers, read the docs, and watched rich’s video, but i’m having a hard time wrapping my head around how to use/implement them


awesome thx!

Sy Borg15:08:18


Alex Miller (Clojure team)00:08:16

the 95% use case is chaining transducers together with into and comp

Alex Miller (Clojure team)00:08:17

such that (->> (range 100) (filter odd?) (map inc) (take 10)) can be rewritten w/transducers as (into [] (comp (filter odd?) (map inc) (take 10)) (range 100))

Alex Miller (Clojure team)00:08:01

the former is lazy, potentially infinite, and makes 3 intermediate sequences

Alex Miller (Clojure team)00:08:16

the latter is eager (and thus can't be infinite), and does the work in a single pass

Alex Miller (Clojure team)00:08:06

if you get that much, you can probably defer understanding other uses or how it works for much later down the line

Alex Miller (Clojure team)00:08:33

and I would not worry at all about implementing your own, that's rarely needed


ok, in that sentence the transducer would be this part right? (comp (filter odd?) (map inc) (take 10))

Alex Miller (Clojure team)00:08:53

yeah - that's just a function, which has the same shape as (filter odd?) or (map inc)

Alex Miller (Clojure team)00:08:23

that is, essentially a fancy reducing function


cool thx, another question, a “stateful transducer” would be a fn like the one on reduce which accumulates the state ??


a stateful transducer holds some mutable object (often a volatile) to track internal state that isn't pure / reflected in args and return values

Alex Miller (Clojure team)01:08:06

for example, partition-all will collect state until it can build and emit a partition


oohh ok, i see

hamid tsh05:08:42

hi, how can i make two websocket with different path and same port in with http-kit?


what JVM supports REBL? I tried to install many with SDKMan but does not work with Caused by: java.lang.ClassNotFoundException: javafx.application.Platform


Maybe javafx doesn’t come with non-Oracle JVM?


It has

Available Java Versions
 Vendor        | Use | Version      | Dist    | Status     | Identifier
 AdoptOpenJDK  | >>> | 12.0.1.j9    | adpt    | installed  | 12.0.1.j9-adpt      
               |     | 12.0.1.hs    | adpt    |            | 12.0.1.hs-adpt      
               |     | 11.0.4.j9    | adpt    |            | 11.0.4.j9-adpt      
               |     | 11.0.4.hs    | adpt    |            | 11.0.4.hs-adpt      
               |     | 8.0.222.j9   | adpt    |            | 8.0.222.j9-adpt     
               |     | 8.0.222.hs   | adpt    |            | 8.0.222.hs-adpt     
 Amazon        |     | 11.0.4       | amzn    |            | 11.0.4-amzn         
               |     | 8.0.222      | amzn    |            | 8.0.222-amzn        
 Azul Zulu     |     | 12.0.2       | zulu    |            | 12.0.2-zulu         
               |     | 11.0.4       | zulu    |            | 11.0.4-zulu         
               |     | 10.0.2       | zulu    |            | 10.0.2-zulu         
               |     | 9.0.7        | zulu    |            | 9.0.7-zulu          
               |     | 8.0.222      | zulu    |            | 8.0.222-zulu        
               |     | 7.0.232      | zulu    |            | 7.0.232-zulu        
               |     | 6.0.119      | zulu    |            | 6.0.119-zulu        
 Azul ZuluFX   |     | 11.0.2       | zulufx  |            | 11.0.2-zulufx       
               |     | 8.0.202      | zulufx  |            | 8.0.202-zulufx      
 BellSoft      |     | 12.0.2       | librca  |            | 12.0.2-librca       
               |     | 11.0.4       | librca  |            | 11.0.4-librca       
               |     | 8.0.222      | librca  |            | 8.0.222-librca      
 GraalVM       |     | 19.2.0       | grl     |            | 19.2.0-grl          
               |     | 19.1.1       | grl     |            | 19.1.1-grl          
               |     | 19.0.2       | grl     |            | 19.0.2-grl          
               |     | 1.0.0        | grl     |            | 1.0.0-rc-16-grl     
       |     | 14.ea.10     | open    |            | 14.ea.10-open       
               |     | 13.ea.33     | open    |            | 13.ea.33-open       
               |     | 12.0.2       | open    |            | 12.0.2-open         
               |     | 11.0.2       | open    |            | 11.0.2-open         
               |     | 10.0.2       | open    |            | 10.0.2-open         
               |     | 9.0.4        | open    |            | 9.0.4-open          
 SAP           |     | 12.0.2       | sapmchn |            | 12.0.2-sapmchn      
               |     | 11.0.4       | sapmchn |            | 11.0.4-sapmchn      


Javafx isn't packaged on Java 8 that isn't Oracle or Zulu


If you want to use REBL on 8, try Zulu


Otherwise I recommend AdoptOpenJDK 11

👍 4

tried all - the same 🐛


So Oracle java 8 should do?


Did you read the wiki? @badod I'll find a link

👍 4

On Java 11 there are a couple add'l steps


RTFM worked :face_with_hand_over_mouth: Thank you ☺️


REBL does not even have *ns* defined. altho in-ns worked...


can anybody help me with clojurescript interop for this? `myElement.attr({ x: position_x, y: position_y });`


(.attr myElement (clj->js {:x position_x :y position_y}))

Godwin Ko14:08:26

how can I solve “manifest type not detected” error when I try to load a github dependency in my deps.edn?


do you control the dependency on github?

Godwin Ko14:08:21

nop, but I need the latest commits which fixed a bug that I encounter

Godwin Ko14:08:13

there’s no deps.edn nor pom file in the project…


tools.deps needs to statically understand the project you're referencing. It needs either deps.edn or a pom file I believe

Godwin Ko14:08:55

so the only choice I have is fork it and add deps.edn myself :thinking_face:


if its a lein project you can run lein pom i think.

Godwin Ko14:08:53

let me try it out, thx a lot

Godwin Ko14:08:22

solve the manifest problem after adding a pom file, but still can’t locate the file in classpath 😢

Alex Miller (Clojure team)14:08:30

you could clone it and refer to it as a local dep

Alex Miller (Clojure team)14:08:46

and use lein pom to make it workable

Alex Miller (Clojure team)14:08:06

just a temporary approach, short of cloning

Godwin Ko14:08:31

add a deps.edn works

Godwin Ko14:08:52

add a pom instead can solve the manifest detection issue, but still can’t find the class

Godwin Ko15:08:25

it complains can’t find xxx.class, xxx.clj, xxx.cljc in the classpath

Alex Miller (Clojure team)15:08:54

clj -Spath will tell you what your classpath is if that helps track it down

Godwin Ko15:08:47

can’t spot anything strange in the classpath, project did checkout under ~/.gitlibs and included in classpath

Godwin Ko15:08:13

but since deps.edn works, I’ll stick to it at the moment, many thanks 🙇:skin-tone-2:


hi, what should be used to update a map if update is not available?


Assoc. or you could copy and defn update


the idiom before update existed: (assoc m k (f (m k)))


bonus, you can operate on multiple keys in one assoc call


right, though I see that update-in does exist, weird, I guess the shorthand was added later


question with assoc i need to get the value before if I want to manipulate it right??


(f (m k)) right!!!!


no, it's immutable


so the order doesn't matter


I know, but I meant if I'm producing the new value from what was in the key before


right, sure, but it's not like you have to order the operations - you want the old value, you read it in the function producing the new one


cool, yeah!! thanks!!


hello all, I just curious to know, is it a bad thing if i interop java? is there any best practice to do it (more idiomatic)?

Alex Miller (Clojure team)19:08:33

interop exists because it is a useful and pragmatic way to leverage the host ecosystem, so IT'S ALL GOOD


wow, thats great! i worried about it sometimes. when some library isn't enough for my purpose, i interop some java library to achieve it, and the big question getting on my head "am i doing good or bad?"

Alex Miller (Clojure team)19:08:16

you are using Clojure in the way Rich intended :)

Alex Miller (Clojure team)19:08:34

I will leave you to judge that as good or bad :)


thanks for the feedback 😁


@ragil.rynaldo I think you might like this too Call it like


(defwrapper "my-pred")

(apropos "my-pred-") ;; to find the functions now available


awesome! what i've done just plain , no wrapper. but this is good advice to do some interop


I do a ton of java interop for my job, we have a futures trading platform written in Java that I interop with a ton. defwrapper has saved me a ton of time


so the point is not "good or bad", but most likely how we achieve our need, am i right?


However, I'm very comfortable with the . special form, which I think is important to know so that your fundamentals can still be leaned on when you need them


Hey guys, in other languages I would avoid doing:

return 5;
preferring instead:
The clojure code base I'm currently working in has cases of the former strewn about. Since I prefer not to perpetuate bad habits, is just leaving in a constant value like that the norm for clojure? What is the typical naming convention for const values and where do you put them (separate file, top or bottom of the same file, etc)?


all values are considered const unless explicitly shown otherwise


if you mean magic numbers, sure, use a def


Yeah, I mean things like magic numbers/strings


(def code-unable-to-connect 5)


that's the normal way to do it


or (def error-codes {:unable-to-connect 5 ... ...})


and then look up the code by name


except I wouldn't bother with HTTP codes - I assume anyone qualified to work on http code either knows them or has them ready to look up


Wouldn't you want (def ^:const unable-to-connect 5) instead? (or the obvious dictionary version)


no, that's not what :const is for, and you probably don't want it


this goes back to the first point, values are considered const


In this case I'm wanting to set the return value of -main and I want to attach some meaning to the value instead of having it be a magic number.


also there's no obvious dictionary version, the const annotation is not for values that are not primitives


Right, but I don't need to look them up at run time, this is purely for the programmer.


What’s wrong with just deffing the values?


but you don't do math on a return value


Nothing, though for minimal work it is faster.


that optimization does nothing here


the reason it's faster is the compiler avoids boxing, there's no such benefit for a signal value


I didn't know if the compiler would already optimize out the reference.


which is what I meant by "this isn't what :const is for"


it doesn't and also that reference lookup is cheap


it's the boxed math that makes things slow


you aren't doing math


It is, and in my current instance its an unnecessary micro optimization, just kind of wondering about best practices.


So what is ^:const intended for?


best practice is to put things in def, and not use unneeded metadata annotations


const is meant for values that can be inlined and unboxed in math heavy code


Is there a high cost for metadata annotations?


(at compile time)


it makes things harder to read


(for humans)


(lol, odd statement from 'noisesmith')


TBH when I see ^:const I usually think "this person probably doesn't know what they are doing but wants their code to be faster", but in a perfect world it would be a signal that some value is being used extensively in numeric code


ok, so I assume I should still avoid the magic numbers and put this in a def. Do you put magic number defs at the top or bottom?


In general you need to have things defined before use. You can use a “declare” expression (statement?) but you can run the risk of getting an uninitialized value of the def is used in another def of some other situations. Better to put at the top or perhaps in a config namespace if there are many such values


(declare x)
(def y {:a x})
(def x 3)
user> y
{:a #object[clojure.lang.Var$Unbound 0x4e3257c4 "Unbound: #'user/x"]}


yeah - my usages would usually have a hash-map from name to numeric code in a config or other auxilliary namespace


Awesome, thanks guys!

Mario C.23:08:08

What is wrong with my project.clj file? I am not getting any errors per-se but I cannot figure out why lein-env is not building out a .lein-env file. None of my environment variables are in the env map. Here is my project.clj file.

Mario C.23:08:20

I run the app with lein with-profile clj,dev


I think you want +clj,+dev


otherwise you use them instead of the task's target profile, and usually what you want is to merge not replace

Mario C.23:08:37

I've tried running it with +clj,+dev but no .lein-env file is being created.