beginners

Christoph 2025-08-14T07:26:24.032339Z

Hi everyone 👋 What is the use case for qualified keywords ? According to https://github.com/nufuturo-ufcg/clj-smells-catalog?tab=readme-ov-file#namespaced-keys-neglect it's bad, but it doesn't say how. If I look at this https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj it looks to me like unqualified keywords are used everywhere. Do you think it's a code smell ? I don't, but maybe there is something I don't know here..

2025-08-14T08:52:59.447769Z

This is a frequently asked question. See https://ask.clojure.org/index.php/10380/when-to-use-simple-qualified-keywords

1
daveliepmann 2025-08-14T09:08:16.318839Z

That code smells repo was written for non-Clojure languages and ported to Clojure (as far as I know, without any experienced Clojurians involved). Most of it isn't exactly wrong but I would view it with significant skepticism.

👍 3
daveliepmann 2025-08-14T09:11:44.485019Z

I disagree with this supposed code smell specifically. Namespaced keywords are great but unqualified keywords are perfectly reasonable in a lot of scenarios.

☑️ 1
daveliepmann 2025-08-14T09:24:16.743319Z

Qualified keywords shine when they will travel far within a Clojure system, and when there are a lot of keywords competing in the same semantic space. In contexts where the keyword will mostly stay within a particular namespace (or a small handful), or if it's fairly unique, using a namespace feels far less necessary.

1
daveliepmann 2025-08-14T09:25:18.971429Z

The benefit of keywords is that they're self-describing. Sometimes they don't need a namespace to do that. Sometimes a namespace really helps.

☑️ 1
Christoph 2025-08-14T09:35:31.028629Z

thank you both! I'll keep on preferring unqualified then 🙂 and consider it when it competes with other keywords. for example so that their :id doesn't replace or misrepresent my :id (or vice versa) I'd use my-namespace/:id in that scenario.

seancorfield 2025-08-14T14:08:15.726839Z

I'll give a concrete example of where qualified keywords are important: next.jdbc -- if you do a SQL JOIN across two tables, say person and address, that both have a primary key column called id, you want to be able to tell them apart in the result. That's why, by default, next.jdbc returns result sets where the keys are of the form :table/column, so you'd get :person/id and :address/id.

➕ 2
1
Christoph 2025-08-15T10:52:12.969129Z

tysm for the guidance and swift responses 🐎

Gent Krasniqi 2025-08-14T09:36:42.249949Z

From what I see you can spec string keys in malli. Is there some inbuilt support for that in spec too? I'd like to avoid keywordizing keys from a JSON object I'm consuming, as I'm wary of any edge cases in the string -> keyword -> string conversion.

Alex Miller (Clojure team) 2025-08-14T11:47:40.667329Z

Not easily without keywordizing

Alex Miller (Clojure team) 2025-08-14T11:49:22.819679Z

How much control do you have over the json key space ?

Gent Krasniqi 2025-08-14T12:15:21.322419Z

None in this case. But thanks, I just wanted to check if I'm missing something obvious before deciding on the way to go about this.

Jonathan Bennett 2025-08-14T21:48:32.159199Z

I'm having a bit of trouble using java-http-clj to create a websocket server, probably because I'm misunderstanding something fundamental. I think, as I look at the example code, that what I'm creating there is a client, but what should the code look like for the server? Do I need another library? The code I'm looking at is here: https://github.com/schmee/java-http-clj?tab=readme-ov-file#websockets

Emma Griffin (OST) 2025-08-14T21:54:43.708299Z

Not familiar with the library but this would be my guess: https://github.com/schmee/java-http-clj/blob/master/src/java_http_clj/websocket.clj#L35-L66

Emma Griffin (OST) 2025-08-14T21:57:45.884729Z

And I think these are the relevant javadocs for the interop this library is wrapping: https://docs.oracle.com/en/java/javase/22/docs/api/java.net.http/java/net/http/WebSocket.Listener.html

Emma Griffin (OST) 2025-08-14T22:04:23.928649Z

It looks like syntax is that it takes a single map as an argument with on-binary on-close on-error on-open on-ping on-pong on-text as keys you can pass in for as functions for how to handle various input types

Jonathan Bennett 2025-08-14T22:06:25.136959Z

Fantastic, thank you. And then if I'm experimenting with this on my own computer, I just spin them up on two separate ports and they can talk to each other. I'll see how far this takes me and come back if I get lost!

👍🏻 1
1
2025-08-14T23:12:35.200459Z

you said "create a websocket server" but the linked code looks like a client library