off-topic

https://github.com/clojurians/community-development/blob/master/Code-of-Conduct.md Clojurians Slack Community Code of Conduct. Searchable message archives are at https://clojurians-log.clojureverse.org/
dominicm 2020-11-13T04:19:21.429500Z

https://ferd.ca/you-reap-what-you-code.html this is a really nice article. I can see many overlaps with Clojure-y things here (and some that are just things I learned through Clojure, rather than being actual Clojurey things) > If you're not able to replace everything, consider framing things as adding it to your system rather than replacing. It's something you add to your stack. This framing is going to change the approach you have in terms of teaching, maintenance, and in terms of pretty much everything that you have to care about so you avoid the common trap of deprecating a piece of critical technology with nothing to replace it. If you can replace a piece of technology then do it, but if you can't, don't fool yourself. Assume the cost of keeping things going.

1
telekid 2020-11-13T20:56:28.448600Z

I just read about cloudflare's Durable Objects (https://blog.cloudflare.com/introducing-workers-durable-objects/) – they seem very cool. It would be interesting to create an IRef-able based on this.

2020-11-13T21:45:28.449800Z

it's really hard to do transaction safe refs like clojure has with distributed state

2020-11-13T21:48:08.450200Z

actors are much messier, but they are a better fit as an abstraction over distributed state

2020-11-13T22:25:34.450900Z

nah, atom like constructs using compare and set like operations are very doable in distributed settings

emccue 2020-11-13T22:26:11.451400Z

IRef is kinda a boring interface in some ways

2020-11-13T22:26:32.451700Z

IAtom is the thing

emccue 2020-11-13T22:27:04.451900Z

more or less just IDeref with callbacks

emccue 2020-11-13T22:27:25.452400Z

and IDeref just lets you use @ to get the current state

emccue 2020-11-13T22:27:52.452900Z

so its not as if there is some grand abstraction that this can fit under right now

2020-11-13T22:28:08.453300Z

IAtom

2020-11-13T22:29:01.454100Z

IRef is all stuff I don't care about or use often if at all (validators, watches, etc)

2020-11-13T22:29:05.454300Z

I thought they specifically meant IRef - I agree that atom is doable, ref reaches for a lot more

2020-11-13T22:29:14.454600Z

IAtom is the good stuff

borkdude 2020-11-13T22:29:59.455200Z

I also like IAtom2, the sequel

emccue 2020-11-13T22:30:01.455400Z

Apparently IAtom doesn't extend IDeref

emccue 2020-11-13T22:30:14.455700Z

oh god the what?

emccue 2020-11-13T22:30:32.456Z

why does this exist

borkdude 2020-11-13T22:30:42.456400Z

it's for swap-vals, etc.

2020-11-13T22:31:48.457700Z

@emccue clojure interfaces tend to work by composition not inheritence

dominicm 2020-11-13T22:31:50.457800Z

I did not expect that to be real

emccue 2020-11-13T22:32:47.458900Z

The "woulda been nice to have had default methods" interface

emccue 2020-11-13T22:33:12.459200Z

anyways

emccue 2020-11-13T22:33:31.459500Z

Shopping cart: An online storefront could track a user's shopping cart in an object. The rest of the storefront could be served as a fully static web site. Cloudflare will automatically host the cart object close to the end user, minimizing latency.
    Game server: A multiplayer game could track the state of a match in an object, hosted on the edge close to the players.
    IoT coordination: Devices within a family's house could coordinate through an object, avoiding the need to talk to distant servers.
    Social feeds: Each user could have a Durable Object that aggregates their subscriptions.
    Comment/chat widgets: A web site that is otherwise static content can add a comment widget or even a live chat widget on individual articles. Each article would use a separate Durable Object to coordinate. This way the origin server can focus on static content only.

emccue 2020-11-13T22:33:52.460200Z

their use cases for this are interesting

emccue 2020-11-13T22:34:15.461Z

its a mix between "per user caching" and "you can emulate live view!"

2020-11-13T22:34:16.461100Z

And I believe also the "go to some lengths to avoid breaking any existing 3rd party code that extended IAtom before" approach.

borkdude 2020-11-13T22:35:02.462Z

@andy.fingerhut I don't think adding methods to interfaces breaks Clojure code, only Java I think right?

borkdude 2020-11-13T22:35:22.462700Z

barring aot

emccue 2020-11-13T22:35:25.462800Z

eh, clojure being dynamic means someone has dug into every corner of the internals

emccue 2020-11-13T22:35:36.463300Z

and AOT is still considered afaik

2020-11-13T22:35:50.464Z

it doesn't break java code, it breaks the java compiler

2020-11-13T22:35:59.464200Z

Not sure -- couldn't it break someone who used deftype to implement IAtom, but not the new methods in IAtom2?

2020-11-13T22:36:12.464900Z

no

borkdude 2020-11-13T22:36:19.465500Z

@andy.fingerhut I think that keeps working, since you don't have to implement every method

emccue 2020-11-13T22:36:21.465600Z

I think you are able to leave off methods and it will just crash at runtime

2020-11-13T22:36:26.465800Z

deftype and the jvm itself are fine with missing methods for interfaces

2020-11-13T22:36:44.466200Z

javac tends to complain

borkdude 2020-11-13T22:37:04.466600Z

that's what I meant with breaking Java code (for which you typically use javac to compile)

2020-11-13T22:37:52.467500Z

the java is source compatibility and java binary compatibility

borkdude 2020-11-13T22:37:55.467700Z

I guess it's nice that it's backwards compatible, although I don't know a lot of examples in the wild that implement IAtom in Java. There could be.

2020-11-13T22:41:06.468300Z

They don't have to be open source, of course.

borkdude 2020-11-13T22:41:30.468500Z

true that

telekid 2020-11-13T22:45:18.469300Z

This conversation brings up a common issue I have when thinking about Clojure interfaces – namely, which one do I want and what does it do?

telekid 2020-11-13T22:47:08.470200Z

Are there any good resources out there that go over Clojure core protocols and interfaces?

borkdude 2020-11-13T22:47:52.470500Z

There's this one: https://github.com/Chouser/clojure-classes/blob/master/graph-w-legend.png

😳 1
2020-11-14T11:06:30.481700Z

@him I did a little bit of hacking in order to generate an updated figure for Clojure 1.10.1 here: https://github.com/jafingerhut/clojure-classes/blob/master/generate/graph-1.10.1.pdf

πŸ‘ 2
borkdude 2020-11-14T11:12:38.482100Z

Awesome! Maybe post in the issue for https://github.com/clojure/clojure-site/issues/17 ?

2020-11-14T12:08:06.482700Z

may be i should print out a poster-size version and put it on my wall πŸ™‚

borkdude 2020-11-14T12:16:46.482900Z

or we should make a game out of this: given an object, visit all the implemented interfaces as quickly as possible!

2020-11-14T12:24:45.483100Z

lol -- gamification at work i guess :)

2020-11-14T12:27:28.483300Z

this reminds me a bit of: https://gist.github.com/ghoseb/2049970 it was in an old talk by ghoseb

2020-11-14T12:32:10.483500Z

it was about deftype including an example: https://www.youtube.com/watch?v=iBUthApQQw4

2020-11-15T01:12:46.485100Z

I added a comment to to the clojure-site issue here with the latest auto-generated graphs: https://github.com/clojure/clojure-site/issues/17

πŸ‘ 2
2020-11-16T06:15:14.486700Z

I did some more hacking on that code, and now there are instructions in the README to generate such a graph from the REPL, but maybe more useful than generating the fairly large graphs that it does by default, is that you can give it a list of one or more classes as input, and it will generate and draw the graph for only those classes and the superclasses (and interfaces they implement), not for all Clojure classes. Smaller graphs can be useful when you want to focus on part of the implementation. You can also use the code from within your own project, in case you want to make drawings for classes outside of Clojure's.

2020-11-16T06:15:15.486900Z

https://github.com/jafingerhut/clojure-classes/

❀️ 1
borkdude 2020-11-16T12:04:09.487200Z

nice!

2020-11-13T22:48:34.471500Z

@him as an exploratory technique, I've looked at (supers (class x)) to see all the clojure interfaces something implements

2020-11-13T22:48:54.472100Z

then look at the methods defined by each interface to see which aspect of its behavior comes from each

borkdude 2020-11-13T22:49:00.472300Z

Also there's this issue at the clojure-site: https://github.com/clojure/clojure-site/issues/17

borkdude 2020-11-13T22:49:35.473Z

I usually just browse the code on github and ascend upwards until I find what I need

alexmiller 2020-11-13T22:49:53.473300Z

There a whole section in Clojure Applied that covers this fyi

alexmiller 2020-11-13T22:50:10.473600Z

(and the ebook will be 40% off over Thanksgiving fyi)

borkdude 2020-11-13T22:50:40.473900Z

this is the second edition right? I think I only have the first one

alexmiller 2020-11-13T22:51:04.474100Z

there's only one edition

alexmiller 2020-11-13T22:51:13.474300Z

if you've got the 2nd, please send it to me :)

πŸ˜„ 4
telekid 2020-11-13T22:52:42.474700Z

This diagram is great

telekid 2020-11-13T22:52:50.474900Z

could probably use an update though πŸ˜†

dpsutton 2020-11-13T22:53:48.476100Z

They aren’t queryable through cljs.repl/doc and apropos right?

borkdude 2020-11-13T22:56:44.477500Z

Github now has some code navigation features for Java code, which should make navigating through the interfaces a bit easier

dominicm 2020-11-13T23:03:40.478700Z

http://sr.ht allows you to upload your own :) I've been wanting to write a clojure thing for it that uses kondo to allow navigation of clojure code on http://sr.ht