Fork me on GitHub
Ben Sless12:08:35

This is nice, JVM performance debugging mindmap

👍 5
👌 3

love the credits


What do you all think about locals “shadowing” in Clojure: code smell yes/no?

Lennart Buit12:08:27

we tend to avoid it, especially its tempting to vector-destructure first/rest, and then be surprised that your first fn no longer works:

(let [[first & rest] coll]

Lennart Buit12:08:08

oh thats shadowing clojure.core in particular

👍 3
Ben Sless13:08:28

Depends on a lot. I don't mind shadowing name and type most of the time


Yeah, (let [{:keys [name type]} record]...) does seem to crop up a lot 🙂


I think scope has a lot to do with it: while I also tend to avoid shadowing, I think it's OK if it's only for a few lines. That way you don't need to remember that name was shadowed by some binding a few screens up. But if we write short functions (as we should), that's usually not a problem. So, yes, to me shadowing is a slight smell, but using a shadowed symbol incorrectly is a bigger smell that your function/form is probably too long.

Tomas Brejla14:08:29

What about imports? I often see :as strand am not sure whether it's fine or not. It does work, but still..

(ns some-ns
  (:require [clojure.string :as str]))

(str 1 2 3)
;; => "123"
(str/upper-case "abc")
;; => "ABC"
(type str)
;; => clojure.core$str


That one specifically also confused me a bit when I started, but then I realized that it's not really shadowing at all: you can't refer to a ns alias like that directly


(require '[clojure.edn :as edn])
(type edn)
; (err) Unable to resolve symbol: edn in this context


So I just got used to it 😛


The str alias for clojure.string is very widespread and safe: namespace aliases only take effect in qualified names so they don't shadow locals.


One can just use “string” i think


What slightly bothers me is that “set” doesn’t have a nice alias


@U01EFUL1A8M Oh, you mean for a local to not shadow clojure.core/str? I tend to just use s (I'm a fan of short, mnemonic names)


What if you have set string and spec? :D


That’s not a hypothetical, I have a little program that uses all of them


An alias for clojure.spec.alpha :as s doesn't interfere with a local named s.


I meant aliases for the set, string and spec libs


So my aliases in such a situation would be str (`clojure.string`), set (`clojure.set`), and s (`clojure.spec.alpha`).


I meant that I use s for a local name for something that is a string.


I love the fact that idiomatic names are not just allowed, but recommended in Clojure


I’m not a huge fan of short names, although I think it’s fine for things that are commonly accepted (like idx for “index”, etc). But put a few of unconventional ones in a slightly more complicated function, and it becomes a PITA to keep their meanings in the head while also deciphering the function. I subscribe to an old adage from cognitive science: “knowledge in the world is better than knowledge in the head”. As for shadowing, I’m a bit dissonant. I think it’s fine, yet go out of my way to avoid it.


Clojure has a ton of cool, high level options for querying unordered data. I'm looking for inspiration around tools that enable querying sorted data. Specifically I'm looking to do in-memory queries somewhat like this:

select * from table where x=a  and y=b and time between then and now;
in an efficient manner, starting from as high a level as possible, and preferably cljc if possible. I found Which looks really cool but falls short when it comes to querying multiple dimensions. Any libraries or articles come to mind relating to this?


Some links I've gathered that should be relevant to some extent. Alas, can't really filter them for your specific need since I haven't looked deeper into them. • maybe alongside with


Oh, that helped me find another link:

👍 3

I'm currently workshopping a datalog engine for autonormal-like maps that would be able to express your query like:

(q '[:find (pull {?e [*]})
     :in $ ?a ?b ?then ?now
     [?e :x ?a]
     [?e :y ?b]
     [?e :time ?time]
     [(<= ?then ?time ?now)]]


asami is probably a pretty good starting point for something to use today


@U064UGEUQ what's the distinction between "querying unordered data" vs. "querying ordered data" meant? are you just saying you want something that would take advantage of the ordering of the data for performance?


Thanks all, these are super useful! I was aware datahike could act as a sorted k/v store but i didn't realize it had efficient predicate filtering as well. As for asami, I wasn't aware that it could range queries like that


Yes exactly I need it it be as performant as possible


basically sorted sets/maps are working well for me but I'm looking for more expressive power. So I can just shove everything that has a time index into one big sorted map, and then later use something like group-by but more efficient


i'm not sure how efficient datahike or asami would be, since they're going to decompose your data into tuples and probably lose a lot of the sorted-ness of your data


I need it to be pretty fast and in browser because the data is coming in fairly fast and going to a web ui, but otherwise I'd be happy to use a db if possible


Though maybe I should look into IndexedDB a bit


And autonormal with sorted-sets


autonormal with sorted-sets is an interesting idea


thinking-face using a sorted map for storing entities thinking-face

thinking-face 3

would involve patching some of the core code I think


fwiw I've found the avl sorted maps ( particularly nice in that they allow chaining operations , ie avl/subrange is like clojure.core.subseq but returns a new sorted thing rather than just a seq


I don't think it supports sub-linear range queries though. I think data Levin does but only for the kv store, which doesn't really offer any higher level querying vs a regular sorted map


Just found which looks kinda interesting


Can someone recommend good entry-level resources for creating generative art? Clojure-specific would be ideal, but is not necessary.


Quil site has some tutorials, intro material, and examples:


Thanks. I know of Quil, but unfortunately their materials, while having plenty of "what to write", are lacking in the "how to think" department.


Does p5js/processing go into the right direction? I think there is also a pretty cool and entertaining youtube channel that I peeked into a couple of times. But I haven’t used it.


oh, quil is also based on processing I see

escherize21:08:25 is in clojure + talks about how to think


actually it’s in js or something. But I know Tyler uses clojure 🙂


What a wonderful site!


daniel shiffman's the nature of code is a great it's processing so you can use quil. He also has a youtube channel where he explores and expands on the ideas and thinking.


I recommend watching talks and performances by Joseph Wilk (of REPL Electric). More about creative programming in general and possibly more inspirational than informative but I’ve really enjoyed watching his talks.

javi21:08:06 has a lot of curriculum related to creative coding from processing to openframeworks to AI etc..with teachers from unis like Goldsmiths

javi21:08:18 is from keith peters bit-101 one of the original creative coders in the flash scene and he explores like particles, attractors, flow fields etc... sources easily portable and on github


and the libs from are always a great source of inspiration.


another good book that explores the thinking behind the code…


Recently saw a few based on it's Python through.


I stumbled upon recently which is clojure focused


Thank you all for the links, I'll check them out!


There are some good Insta feeds out there with some links to code. This is one of my favourites:


Also, Zach Lieberman’s stuff:

Ivar Refsdal12:08:29

Flow fields looks awesome, thanks @U051GFP2V! I really like the images created by _hrrld on instagram: I came across _hrrld via skija: There is a long youtube video explaining Skija (java bindings for graphic stuff) from the Sci Cloj-yotube user/group: Skija is backed by JetBrains. Maybe not exactly generative art, but for banners/logos I think opentype.js + rough.js is kind of neat: Some years ago I did a bunch of charts that were somewhat nice looking (according to me): in that repo I'm integrating with opentype.js to trim the margins as much as possible to get a really tight look without having to adjust pixels manually myself. Not sure you could call that generative though, I don't know. Re quil: It does not support java 11 yet and requires the old jdk/jvm 8 IIRC

Bobbi Towers21:08:37

Does anyone know what this letter is?

Bobbi Towers21:08:22

You might be right! I'm used to seeing that as a little circle with a slightly tilted axis but it does look like the Modern Greek version.


Indeed, that's φ (phi)