This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-05
Channels
- # announcements (1)
- # babashka (5)
- # beginners (151)
- # calva (43)
- # clj-kondo (23)
- # cljdoc (1)
- # cljs-dev (6)
- # cljsrn (10)
- # clojure (60)
- # clojure-australia (1)
- # clojure-europe (26)
- # clojure-gamedev (14)
- # clojure-nl (1)
- # clojure-spec (10)
- # clojure-uk (80)
- # clojurescript (66)
- # clojureverse-ops (4)
- # community-development (7)
- # conjure (8)
- # datomic (15)
- # deps-new (1)
- # docker (27)
- # emacs (2)
- # fulcro (13)
- # honeysql (13)
- # java (5)
- # jobs-discuss (43)
- # lsp (121)
- # luminus (13)
- # malli (1)
- # off-topic (73)
- # pathom (12)
- # polylith (29)
- # practicalli (4)
- # re-frame (35)
- # reagent (44)
- # remote-jobs (5)
- # rewrite-clj (2)
- # sci (7)
- # shadow-cljs (125)
- # sql (4)
- # tools-deps (9)
- # xtdb (5)
This is nice, JVM performance debugging mindmap https://shipilev.net/talks/devoxx-Nov2012-perfMethodology-mindmap.pdf
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]
...)
Nice, just found this issue https://github.com/clj-kondo/clj-kondo/issues/646
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.
What about imports? I often see :as str
and 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
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.
@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)
An alias for clojure.spec.alpha :as s
doesn't interfere with a local named s
.
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
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?https://github.com/cnuernber/tmdjs is cool as well
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
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)]]
,,,)
@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
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
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
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 https://github.com/techfort/LokiJS 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: http://www.quil.info
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.
https://tylerxhobbs.com/essays/2020/flow-fields is in clojure + talks about how to think
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.
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
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
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
and the libs from https://thi.ng/ are always a great source of inspiration.
another good book that explores the thinking behind the codeā¦ https://mitpress.mit.edu/books/code-creative-medium
Recently saw a few based on https://github.com/abey79/vsketch it's Python through.
I stumbled upon https://github.com/Clojure2D/clojure2d recently which is clojure focused
There are some good Insta feeds out there with some links to code. This is one of my favourites: https://www.instagram.com/shedrawswithcode/
Also, Zach Liebermanās stuff: http://zach.li/
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
Does anyone know what this letter is?
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)