Fork me on GitHub
#off-topic
<
2021-08-05
>
Ben Sless12:08:35

This is nice, JVM performance debugging mindmap https://shipilev.net/talks/devoxx-Nov2012-perfMethodology-mindmap.pdf

šŸ‘ 5
šŸ‘Œ 3
sogaiu13:08:49

love the credits

raspasov12:08:09

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

walterl14:08:21

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

walterl14:08:38

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

walterl14:08:01

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

walterl14:08:28

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

walterl14:08:41

So I just got used to it šŸ˜›

seancorfield14:08:22

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.

dgb2314:08:15

One can just use ā€œstringā€ i think

dgb2314:08:42

What slightly bothers me is that ā€œsetā€ doesnā€™t have a nice alias

seancorfield14:08:11

@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)

dgb2314:08:43

What if you have set string and spec? :D

dgb2314:08:07

Thatā€™s not a hypothetical, I have a little program that uses all of them

seancorfield14:08:15

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

dgb2314:08:41

I meant aliases for the set, string and spec libs

seancorfield14:08:48

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

seancorfield14:08:11

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

walterl14:08:24

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

henrik18:08:49

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.

jjttjj20:08:44

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 https://github.com/wotbrew/idx Which looks really cool but falls short when it comes to querying multiple dimensions. Any libraries or articles come to mind relating to this?

p-himik20:08:47

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. ā€¢ https://github.com/wilkerlucio/pathom maybe alongside with https://github.com/walkable-server/walkable ā€¢ https://github.com/replikativ/konserve ā€¢ https://github.com/riverford/compound ā€¢ https://github.com/keechma/keechma-entitydb

p-himik20:08:35

Oh, that helped me find another link: https://github.com/threatgrid/asami

šŸ‘ 3
lilactown20:08:25

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
     :where
     [?e :x ?a]
     [?e :y ?b]
     [?e :time ?time]
     [(<= ?then ?time ?now)]]
    ,,,)

lilactown20:08:42

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

lilactown20:08:43

@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?

jjttjj20:08:50

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

jjttjj20:08:07

Yes exactly I need it it be as performant as possible

jjttjj20:08:54

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

lilactown20:08:44

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

jjttjj20:08:00

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

jjttjj20:08:20

Though maybe I should look into IndexedDB a bit

jjttjj20:08:28

And autonormal with sorted-sets

lilactown20:08:27

autonormal with sorted-sets is an interesting idea

lilactown20:08:10

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

thinking-face 3
lilactown20:08:38

would involve patching some of the core code I think

jjttjj20:08:37

fwiw I've found the avl sorted maps (https://github.com/clojure/data.avl) 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

jjttjj22:08:54

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

jjttjj22:08:24

Just found https://github.com/techfort/LokiJS which looks kinda interesting

p-himik20:08:12

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

cp4n20:08:44

Quil site has some tutorials, intro material, and examples: http://www.quil.info

p-himik20:08:14

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

dgb2321:08:09

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.

dgb2321:08:22

oh, quil is also based on processing I see

escherize21:08:25

https://tylerxhobbs.com/essays/2020/flow-fields is in clojure + talks about how to think

āœ… 3
escherize21:08:54

actually itā€™s in js or something. But I know Tyler uses clojure šŸ™‚

dgb2321:08:12

What a wonderful site!

javi21:08:58

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

jkxyz21:08:10

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. https://youtu.be/92s_loXgaCM

javi21:08:06

http://try.kadenze.com/creative-coder/ 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

https://www.youtube.com/user/codingmath 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

javi21:08:24

and the libs from https://thi.ng/ are always a great source of inspiration.

javi21:08:43

another good book that explores the thinking behind the codeā€¦ https://mitpress.mit.edu/books/code-creative-medium

gklijs21:08:39

Recently saw a few based on https://github.com/abey79/vsketch it's Python through.

phronmophobic22:08:42

I stumbled upon https://github.com/Clojure2D/clojure2d recently which is clojure focused

p-himik06:08:29

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

cassiel09:08:12

There are some good Insta feeds out there with some links to code. This is one of my favourites: https://www.instagram.com/shedrawswithcode/

cassiel09:08:00

Also, Zach Liebermanā€™s stuff: http://zach.li/

Ivar Refsdal12:08:29

Flow fields looks awesome, thanks @U051GFP2V! I really like the images created by _hrrld on instagram: https://www.instagram.com/_hrrld/ I came across _hrrld via skija: https://github.com/JetBrains/skija There is a long youtube video explaining Skija (java bindings for graphic stuff) from the Sci Cloj-yotube user/group: https://www.youtube.com/channel/UCaoZzhNzq-H7YiQczXKuXuw Skija is backed by JetBrains. Maybe not exactly generative art, but for banners/logos I think opentype.js + rough.js is kind of neat: https://observablehq.com/@radames/rough-js-make-your-own-text Some years ago I did a bunch of charts that were somewhat nice looking (according to me): https://github.com/ivarref/clj-simple-chart 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 https://github.com/quil/quil/issues/228

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.

pavlosmelissinos22:08:21

Indeed, that's Ļ† (phi)