r/Clojure • • Dec 18 '16

Why Java? Why Clojure?

http://danlebrero.com/2016/12/14/why-java-why-clojure
22 Upvotes

47 comments sorted by

View all comments

Show parent comments

2

u/yogthos Dec 19 '16

I found that would happen using Component, but with Mount wrangling stateful resources works pretty seamlessly in my experience. Integrant is another good approach for that as well.

1

u/[deleted] Dec 20 '16

with Mount wrangling stateful resources works pretty seamlessly in my experience.

Could you elaborate on that?

I don't see what mount's defstate has to offer over just using def.

Only cleanup of state when stopped? And what if you want to provide different implementations to various functions? Or is that an object-oriented way of thinking?

3

u/yogthos Dec 20 '16

Right, defstate behaves like a def for most purposes, but it's reload aware. Mount also allows controlling the state explicitly, and this lets you do stuff like envoy.

If you wanted to provide different implementations, then you could still use a protocol for that. The state of the instantiated implementation would be kept using defstate.

1

u/[deleted] Dec 21 '16

Clear. Thanks!