Fork me on GitHub
#clojure
<
2021-05-25
>
kosengan04:05:00

is there any interest in the community to port clojure to webassembly? I know clojure is deeply tied to java ecosystem but being able to write clojure could that compiles to wasm can drive a lot growth and opportunities for both clojure and wasm for now, rust is the go to wasm supported language and that will probably remain forever c# is coming up as the 2nd good language with blazor - the huge push from Microsoft golang will probably end up next; if Clojure can try, it could take that space! people can mention clojurescript but that will miss the whole point!!

markaddleman04:05:38

Does webassembly support garbage collection? I think there are proposals for it but I'm not sure if it's implemented

kosengan04:05:05

yeah.. not sure but the area seems active https://github.com/WebAssembly/gc

seancorfield05:05:18

(the former initially asks about cljs/wasm interop but some of the responses speak to the more general issue of transpilation to wasm)

seancorfield05:05:43

The main benefits to Clojure/Script (and ClojureCLR) is that they bring with them access to vast, established ecosystems of libraries — I’m not sure how much of that you’d end up sacrificing to target WASM?

seancorfield05:05:17

Seems like (the lack of) multithreading and GC in WASM would be big obstacles to porting Clojure to it. Also “A June 2019 study from the Technische Universität Braunschweig analyzed the usage of WebAssembly in the Alexa top 1 million websites and found the prevalent use was for malicious crypto mining, and that malware accounted for more than half of the WebAssembly-using websites studied.” 👀 — from https://en.wikipedia.org/wiki/WebAssembly#Security_considerations

Aron06:05:21

Any good tech is always used first by criminals, this is just expected at this point. Especially if it's low cost, low risk, high potential value. If anything, that quote from the wiki is a statement about how bad the browser is that it allows installation of such software without any real help to the average person using a browser to analyse what is installed and deal with it. Of course, such tools would first have to be developed not for the browser but for the OS, and there are lots on the market, but I am not sure I can trust them to such high degree as it would be necessary here.

kosengan08:05:25

If you are seeing 'targeting wasm' as a sacrifice and most of what wasm is about crypto and the security problems that are associated with it, I have to take that, this topic has don't have much relevance here

seancorfield16:05:31

I thought it was mostly an interesting note about the tech -- I haven't really looked at WASM so @UJMU98QDC’s made me curious and the links above were just the first few things that I turned up, mostly relating to suitability for Clojure. I was genuinely surprised to see that statement on the wiki! 😐

fmnoise12:05:38

Hi everyone, maybe stupid question, but is there any way to force certain namespace to reload each time when using clojure.tools.namespace.repl/refresh? My case is: I have a edn file and I'd like that any changes in this file to force reload in namespace which reads this file.

delaguardo12:05:22

with pure clojure.tools.namespace you can use refresh-all. But this function will unload and load back everything tracked so far.

delaguardo12:05:16

You can try to use some library to manage dependencies (like integrant) to achieve what you want. But this will affect for sure your project structure

borkdude12:05:45

@fmnoise I am not using tools.namespace refresh stuff, but you can force a reload using the :reload option in require

Joel14:05:13

If i have a string such as "alias/keyword" how can i create a keyword with the namespace of the alias?

Alex Miller (Clojure team)14:05:36

you can use the ns-whatever functions to resolve aliases

Alex Miller (Clojure team)14:05:21

look it up in the map returned from ns-aliases etc

👍 3
zendevil.eth18:05:13

Hi I’m trying to create a function that does the following: input: [[1] [1 2]], output: [[1 1] [1 2]] input: [[1 2] [2] [1 2]], output: [[1 2 1] [2 2 1] [2 2 2]] input: [[1 2] [1] [1 2]], output: [[1 1 1] [1 1 2] [2 1 1] [2 1 2]] This is what I have so far:

(defn match-meta-pattern
  [metapattern]
  (loop [result [] metapattern metapattern]
    (if (seq metapattern)
      (recur
       ;;;;;;;;;;;;
       (do (prn "meta" (first metapattern))
           (prn "->" result)
             (if-not (seq result)
               [[(nth (first metapattern) 0)]]
               (map (fn [next-pattern] (map (fn [running-pattern]
                              (conj running-pattern next-pattern)) result))
                (first metapattern))))
       ;;;;;;;;;;;;
       (rest metapattern))
      result)))

dpsutton19:05:54

(defn cartesian [set & sets]
  (if (seq sets)
    (for [x    set
          tail (apply cartesian sets)]
      (conj tail x))
    (for [x set]
      (list x))))

(cartesian [1] [1 2])
(cartesian [1 2] [2] [1 2])
(cartesian [1 2] [1] [1 2])

🚀 3
dpsutton18:05:32

can you explain the logic?

zendevil.eth18:05:02

Each subvector represents the various values of the branch

hiredman18:05:13

you list a single input for each example, but your function takes 2 arguments

dpsutton18:05:30

i did not understand the logic explanation 🙂

hiredman18:05:02

yeah, that too, and I don't see a pattern between input and output at all, so hard to say

emccue18:05:28

i see the pattern

emccue18:05:54

[[a b c] [d e]] -> [[a d] [a e] [b d] [b e] [c d] [c e]]

emccue19:05:15

terminology is wierd though

emccue19:05:21

this is a combinatorics thing

dpsutton19:05:27

it's just a cross product?

hiredman19:05:43

none of the inputs have a 3 element vector as the first element

dpsutton19:05:24

oh yeah, it's just a cross product

zendevil.eth19:05:45

@dpsutton it’s not a cross product because a cross b is defined only when length a = length b

hiredman19:05:32

cross product with padding

dpsutton19:05:05

that's not true

dpsutton19:05:56

𝐴×𝐵={(𝑥,𝑦)|𝑥∈𝐴,𝑦∈𝐵}

zendevil.eth19:05:46

@dpsutton that’s the operation, but it’s not called cross product

hiredman19:05:46

a cross join

dpsutton19:05:49

cartesian product is the technical term i guess. maybe i misremembered but i thought there were largely interchangeable

hiredman19:05:03

vectors and sets

dpsutton19:05:27

i went back to halmos naive set theory to check. been a while since my set theory days. i was wrong and apologies

max minoS23:05:05

I'm trying to set my m2 repo location using profiles.clj, what is the difference between the :local-repo and the :repositories "local" here? https://wiki.archlinux.org/title/Clojure#m2_repo_location