beginners

Faizan Siddiqui 2025-07-22T05:04:35.581769Z

Hi I am looking to build a simple web app (rest) to get started and familiarize myself with clojure world. Any url or idea or a youtube video that can help me? I would be looking to use 1. Ring 2. Jetty 3. Compojure Thanks

Faizan Siddiqui 2025-07-25T11:11:46.154729Z

@gaverhae what do you suggest, if not Compojure ?

Faizan Siddiqui 2025-07-25T11:12:14.341269Z

I am currently exploring so any ideas are welcome

p-himik 2025-07-25T11:53:22.109399Z

I'm using Reitit, quite happy with it. Never tried Compojure - didn't like some things years ago when I myself was evaluating which libraries to use, but don't remember what exactly. Used Bidi initially but it's rather hard to debug when something goes wrong.

Faizan Siddiqui 2025-07-25T13:15:10.301409Z

@p-himik thank you, I'll explore Reitit and get back to you!

👍 1
gaverhae 2025-07-25T15:12:32.955099Z

I think the biggest practical downside to compojure vs. more modern alternatives like reitit — besides the very subjective aesthetic aspect of compojure's macro language — is that since you compose your "route handlers" using macros and functions, routes themselves are not reified, meaning you don't easily have a "single source of truth" that allows you to manage routes in both ways - i.e. compojure gives you handlers for specific routes, but you then have to build out routes yourself (e.g. when making a link), whereas with something like reitit you have a single, reified, data definition of your routes, which you can then use to derive both "route handlers" and "link makers", if that makes sense. That said, I've pretty much always used compojure and that's never been a problem. I think it mostly depends on ow many routes you end up having and how often they change.

p-himik 2025-07-22T06:26:05.904799Z

The bare minimum is Ring + Jetty (or any other web server for which there's an adapter for Ring). So I'd suggest following through any resource that helps you with Ring, and then going through Compojure docs. An example of such Ring + Jetty article: https://www.baeldung.com/clojure-ring

1
2025-07-22T06:28:34.515449Z

I found pedestal guide super helpful https://pedestal.io/pedestal/0.7/guides/hello-world.html

👍 1
p-himik 2025-07-22T06:30:48.346569Z

Pedestal is not Ring though.

1
gaverhae 2025-07-22T12:55:53.960329Z

I'd also caution a tiny bit about Compojure. It's great, and I've been using it pretty much since it came out, and I like it quite a bit, and it's still the routing library I reach for because it does everything I need so I never felt the need to really look at other ones. But, it is pretty old, and that means there are a few things that make it not a great example of "modern" Clojure good practices, such as: • It uses macros quite a bit, whereas more modern routing libraries use data. • It has its own destructuring syntax, which is not entirely in line with core Clojure destructuring, which can get confusing, especially as a beginner.

👍 1
🆗 1
seancorfield 2025-07-22T13:10:51.783589Z

You might find this useful as an example https://github.com/seancorfield/usermanager-example The README also links to a version that uses reitit for routing instead of Compojure, for comparison of the two libraries.

1
2025-07-22T06:08:22.496579Z

Hey everyone! I'm running the command clj -Spath with the following minimal deps.edn

{:paths ["src"]
 :mvn/repos {"clojars" {:url ""}}
 :deps {buddy/buddy-auth {:mvn/version "3.0.323" :exclusions [org.clojure/clojure]}
        buddy/buddy-oauth2 {:mvn/version "1.9.0" :exclusions [org.clojure/clojure]}}}
But everytime I run the command, I receive the following error message:
Error building classpath. Could not find artifact buddy:buddy-oauth2:jar:1.9.0 in central ()
Is there a way to force the CLI tool to search for the dependencies using clojars repository?

p-himik 2025-07-22T06:20:29.352789Z

No need for that :exclusions - Clojure version is not picked up from your dependencies. If you don't specify it in your deps.edn, it will be taken from clj itself. As for buddy/buddy-oauth2 - where did it come from? It doesn't exist in Clojars, and I can't find anything relevant.

p-himik 2025-07-22T06:21:41.069199Z

Also, Clojars is searched, no need for that :mvn/repos. It's just that the error reports only Maven Central - maybe because it's being checked last, I don' tknow.

gaverhae 2025-07-22T12:58:08.497479Z

https://github.com/funcool/buddy is presumably the authoritative list of buddy libraries, and it does not mention a buddy-oauth2.

seancorfield 2025-07-22T13:12:59.470989Z

I suspect @petrisrf got that deps.edn from ChatGPT and it hallucinated the library name...?

2025-07-22T13:14:15.997509Z

I think @seancorfield is right. Since I'm new to the ecossystem, I was searching for libraries using ChatGPT...

2025-07-22T06:30:18.539989Z

Hi! Can someone please help me translate this into HoneySql:

["SELECT id, name  FROM plugins
        WHERE tsv @@ plainto_tsquery('english', ?)
        ORDER BY ts_rank_cd(tsv, plainto_tsquery('english', ?)) DESC
        LIMIT ? OFFSET ?"])
struggling with ORDER BY ts_rank_cd(tsv, plainto_tsquery('english', ?)) got as far as:
{:select [:id :repo :description]
      :from [:plugins]
      :where [atat :tsv [:plainto_tsquery 'english q]]
      :order-by [[:%ts_rank_cd [:tsv :plainto_tsquery 'english q]] :desc]
      :limit limit
      :offset offset})))

p-himik 2025-07-22T06:33:57.761359Z

(require '[honey.sql :as sql]
         '[honey.sql.pg-ops :as pg-ops])

(let [q ""
      limit 10
      offset 0]
  (sql/format
    {:select   [:id :repo :description]
     :from     [:plugins]
     :where    [pg-ops/atat :tsv [:plainto_tsquery [:inline "english"] q]]
     :order-by [[[:ts_rank_cd :tsv [:plainto_tsquery [:inline "english"] q]] :desc]]
     :limit    limit
     :offset   offset}))

2025-07-22T06:35:26.890589Z

Oh, I see now. Thank you very much!

👍 1
adi 2025-07-22T13:18:01.575199Z

For queries that stump me, I like to incrementally build up the HoneySQL syntax using the helper functions... https://cljdoc.org/d/com.github.seancorfield/honeysql/2.7.1310/api/honey.sql.helpers As I go along, I also visually inspect the string version, by toggling honey.sql/format "on and off" (using #_). Once done, I typically copy the generated HoneySQL and use that directly in my code. Optionally, the helper code that was built up can also stay in code, except as a comment block for later reference. Gradually, intuition builds about how to mentally map HoneySQL syntax and compiler rules to the equivalent raw SQL query versions.

(-> {}
    (select :a :b :c)
    (from :table)
    (where [:= :id 42])
    #_(sql/format))

👍 1
2025-07-22T13:23:58.996189Z

Nice trick! I am finding quite intuitive, just getting used to nesting.

👍 1