Fork me on GitHub
Martynas Maciulevičius06:06:10

Today I found a use for update-keys function. Finally.

(user-login-info-by-email [_ email]
        {:email email})
This code replaces keys such as :user_name to :user-name and the map db-to-non-db-attr-names contains this:
{:user_name :user-name}

👋 2


Martynas Maciulevičius08:06:44

Actually the update-keys may be faster in some places where I know that the updated map is almost always has less entries than the upadted key count. Because these are the same operations but rename-keys works by iterating through the renamed key map and not the item itself :thinking_face: But other than that there is little difference in my current usecase :thinking_face:

Martynas Maciulevičius06:06:47

Well... I tried. But update-keys uses transient code at least. And no, I didn't want to change my keys dynamically. I know what they are.

Ashwin Bhaskar07:06:08

hi all, has any one used this library for consuming from Kafka? I could not find an API in it to consume from a partition starting from a given offset. Maybe I missed it?


We’re using kinsky, which is just a wrapper for the java api so you may have more luck there


Looks like you have to use seek to specify offset for the consumer

👍 1
🙏 1
Ken Allen20:06:54

we heavily use kafka from clojure at work and we don’t bother with any of the wrappers. less stuff to learn if you just use the kafka api directly. embrace the platform!

👍 1
Noah Bogart12:06:47

Clojure’s design question: why aren't evaluated symbols always specifying the Var? Which is to say, there’s the issue of referencing a function in a map that's bound to a var (with def) and then reevaluating the function definition, the map holds a reference to the previous definition, so to make it work intuitively, you use #' to reference the var instead. I haven’t tried, but i suspect this applies not just to functions but to all types.


I suspect the performance consideration is at play. Every time you call a var, the var is first deref'ed and then the resulting function is called.

Noah Bogart13:06:51

Yeah, that is probably the reason. I wonder if it would be possible, with the help of hindsight, to implement it such that there's no deref necessary for vars

Joshua Suskalo15:06:53

in order to allow you to perform repl-driven updates to values there must be a pointer deref in there somewhere. Doing it with vars just makes it controlled and allows it to interact well with the namespace system. I don't think that you could realistically have your cake and eat it too with lower indirection but also more reloadability by default without doing graph tracking to re-evaluate all code that depends on a var when you re-evaluate the var definition.

Noah Bogart16:06:14

yeah, i'm not sure exactly. I thought common lisp was able to handle this, but I don't have cl set up on this machine so I can't test it out

Joshua Suskalo16:06:32

The CL situation is actually strikingly similar to Clojure, except that instead of storing values and functions on vars, they store them on symbols, which are interned in CL like keywords are in Clojure. Symbols are container objects that store a value and a function on them and are associated with a specific package, and so in cases where you want to pass a function that will be updated, you just pass the symbol. You then grab the function by calling symbol-function and then call funcall on that object. In places where code doesn't take symbols and just takes function objects you return the function object with #' and it has the exact same problem as Clojure does with stale definitions.

Noah Bogart16:06:10

ah okay, interesting. I thought common lisp did a better job with redefinitions

Joshua Suskalo16:06:12

In general CL it is much more annoying to deal with higher order functions because there's additional ceremony introduced by it being a lisp-2

Joshua Suskalo16:06:25

CL does do a better job with redefinitions, but not for function objects.

👍 1
Joshua Suskalo16:06:00

It does better with object objects, by allowing you to redefine classes at runtime and it will walk the full graph of live objects and change any that are of the old class to be valid (but perhaps unconstructable) instances of the new class.

👍 1
Noah Bogart16:06:23

so because it's interned, when you change the definition of a non-function symbol, the value is propagated?

Noah Bogart16:06:45

very interesting, thank you for the information

Joshua Suskalo16:06:57

Yes, evaluating code that refers to a symbol does a lookup the same way as it does in clojure


I suspect this would break referential transparency. If you always deref the var, you're sensitive to the var being redefined. Then you're working with references, and not values. And we tend to like values when working with clojure!


So our company had a new dev and while setting him up we encountered something bizarre with his JVM. This does not work for him (for context we're using OIDC and Keycloak for security):

(slurp "")
But this does, where we replace with localhost:
(slurp "")
What's truly bizarre is that this issue doesn't affect anyone else. Does anyone have an explanation for this phenomenon other than "the JVM router is finicky?"


FWIW I wouldn't expect for to work in any context where you make a request, as opposed to making something listen to it (which results in listening to all IP addresses on the host). But apparently, it can be used, although it's not well defined. So I would use it for requests even if it works on most machines.


> So I would use it for requests even if it works on most machines. You mean not use it for requests?


*would not Yeah, sorry.


You can make it work by routing to localhost in /etc/hosts file, at least you used to - no idea if it's used anymore in macOS/Linux/etc


but that's not the best idea to be honest

Joshua Suskalo16:06:19

yeah what's the rationale behind using instead of the loopback address?


IIRC it was because Docker would sometimes fail to expose ports on localhost instead of @U06872G6L (who set up most of the Keycloak/OIDC at our shop) likely has a deeper insight into this.


Yeah, because Docker for Mac cannot do host networking, not sure about Windows, so your server running in a container has to bind to for the routing to localhost to work

Joshua Suskalo16:06:06

ah, so it's container shenanigans. Fun.


But still - notice how it's important for binding, not for making requests.

👍 1
jumar16:06:07 can have multiple meanings - the most common is “listen on all network interfaces”. As they already said, don't use this as a hostne fir requests


Yep, that’s where the confusion came from, it’s strictly for binding, though I’m still not sure why it ever worked on our macs, as we’re not routing to localhost.


yeah, you shouldn't - only servers have a need to bind to the loopback interface

Kris C14:06:56

Is there a list of all known future clojure-related conferences? IOW, how can I find out where and when will the next clojure conference take place?


There's #events with some announcements, but no clue whether it has them all.

👍 1
delaguardo14:06:48 incomplete list but something that one can call "official"

👍 1