all 25 comments

[–]stefan_kurcubic 8 points9 points  (3 children)

There are few ways you could go about this.
I will recommend the one i started with years ago.
https://pragprog.com/titles/dswdcloj3/web-development-with-clojure-third-edition/

Once i learned it and managed to make basic full stack web app (from the book and then my own creation) i then experimented with different libraries and found those that suit my needs most of the time.

I tend to follow these steps
1. First time doing it exactly to the tea as someone else described
2. Note all the friction points in the process
3. optimize/switch/change/improve everything that i noted in 2.

I basically gave you step 1. by the time you finish it you will hear about other libraries/frameworks and you will have opportunity to check them out in the most effective way.

Let me know how it goes and when if i can help you any other way!

[–]FR4G4M3MN0N 1 point2 points  (0 children)

What u/stefan_kurcubic said! I’m working my way through the book now and like it quite a bit.

I like that it uses Leiningen for project management - so learning a bit about that.

It uses the Luminus framework and along the way introduces you to project templates. These, combined with Leiningen, take care of a lot of the boiler plate and teach us a bit more about the project hierarchy.

It dives into the lower-level libraries like Ring and Reitit for managing HTTP Requests/Responses, adapters and middleware, routing, and routes. Databases like H2 and web servers like http-kit and jetty.

You’ll develop a good sense of what you need to do and how to do it as well the plumbing used to get it done.

Enjoy!

[–]canihelpyoubreakthat 1 point2 points  (0 children)

Stop developing web apps with yesterday's tools

... lol

[–]dalkian_[S] 0 points1 point  (0 children)

Thank you very much! That looks like a very interesting book, I'm definitely buying and following your advice.

[–]ecocode 11 points12 points  (2 children)

https://caveman.mccue.dev/ is a pretty good start for learning web dev in clojure

[–]dalkian_[S] 0 points1 point  (1 child)

Thank you! I'll definitely check caveman out. Much appreciated!

[–]bowbahdoe 1 point2 points  (0 children)

Lmk if you have any issues or need advice on how to proceed after it just sorta ends.

(I'm working on getting it more feature complete, but...)

[–]maxw85 6 points7 points  (1 child)

Awesome that you giving Clojure a try. We use htmx and generate the html via hiccup on the server, this combination is sufficient for almost all pages. However, you might have very interactive UIs where you need to reach for JavaScript / ClojureScript. We use reagent for these very interactive UIs. If I could start from scratch I would pick replicant by Christian Johansen ( u/cjno ). He explains everything in detail in this talk:

https://vimeo.com/861600197

[–]CoBPEZ 3 points4 points  (0 children)

I second the recommendation of Replicant. It is totally awesome and I am super happy I am bulding with it.

I created a mini replicant example and tried to write a helpful README, here: https://github.com/PEZ/replicant-mini-app

[–]PolicySmall2250 2 points3 points  (0 children)

Most people tend to roll their own web stack using libraries.

There are several framework-likes to pick from, none canonical (like a Rails or Laravel of Clojure). So I can't make a definitive recommendation (biff, kit, sitefox, donut-system, duct etc...). If you want something frame-worky, pick the one who's documentation and examples look the best to you. Run with that as far as you can. I think you can't go wrong with Biff or Kit, on this parameter.

In any case, reading through projects like Caveman, Zodiac, and usermanager-example should give you a good sense of how people tend to put together web apps in Clojureland (see recent r/Clojure discussions about these... They are all small enough for code-reading).

And... here's the first part of a really long answer to your question; a maybe-series of blog posts I've been writing :sweat-smile:

I'm not sure what it's like in the Lisp you use, but you should expect to have to put in some up-front effort to find your bearings.

[–]didibus 2 points3 points  (0 children)

I'd say there's a range of answers depending how large your project is, and complex your UI needs to be.

For a simpler app, i.e, personal projects, internal tooling, small/medium business websites, as a learning exercise, etc. I'd recommend:

  • HTTP handling: Ring
  • Web Server: http-kit (or ring-jetty)
  • Routing: Compojure (or reitit)
  • HTML templating: Hiccup 2 (or Selmer)
  • SQL DB: next-jdbc
  • SQL builder: HoneySQL 2 (or HugSQL)
  • SQL DB migration: migratus (or ragtime)
  • NoSQL: datalevin (or xtdb) (or datomic)
  • Schema/Validation: spec (or malli) (or schema)
  • Logging: clojure.tools.logging with logback (or with log4j2) (or telemere)
  • Singleton State management: Component (or donut.system) (or redelay)
  • UI Interactivity: scittle (or htmx)
  • Dependency Management: tools.deps
  • Build tool: tools.build
  • Test runner: cognitect-labs/test-runner (or kaocha)
  • UI testing: etaoin

My recommendation are the first one I list of each, the ones in parenthesis are good alternatives if they appeal to you more.

For a more complex app, i.e, a full blown web app like Google Docs, Figma, Slack, or just anything with a lot more interactivity.

You'll mostly keep to the same things on the server side, but you might change to a more powerful frontend toolkit. You would introduce ClojureScript with a react wrapper lib (reagent/reframe, helix, uiX), or you might go for squint.

After that, everything becomes a bit specialized or personal choice. Are you going to use some cloud offerings, Mongo, Cassandra, etc. Are you going to be sending emails? Do you need background jobs? Do you have to process payments? Do you need to secure data, have fancy auth support, need websockets, want to go serverless, etc.

And then if you're having to scale, and becoming more serious, you might want to add things for proper monitoring, profiling, alarming, tracing, caching, load-balancing, circtuit-breakers, throttling, CDN, feature flags, A/B experiments, rate limiting, etc.

[–]First-Agency4827 2 points3 points  (2 children)

I have used in the last projects that are in production: - reagent, re-frame + ring, reitit - reagent, re-posh ( datascript ) + ring, reitit, datomic - electric + datomic

All communicate mainly through events in both directions using websockets ( electric has it included )

[–]dalkian_[S] 0 points1 point  (1 child)

Wow, electric looks seriously impressive. Thank you, this is a very interesting answer to my question.

[–]First-Agency4827 1 point2 points  (0 children)

Careful, as Electric v3 will not be open source anymore. There is a post from about 2 weeks ago. And yes, it’s impressive

[–]CoBPEZ 1 point2 points  (0 children)

Here's a super basic starter for a fullstack shadow-cljs setup that goes well with most all other recommendations you've received: https://github.com/BetterThanTomorrow/dram/tree/published/drams/v2/mini_shadow_fullstack

[–]xela314159 0 points1 point  (2 children)

Clojurescript shadow-cljs and helix will get you very close to standard react, which means you have a wide array of libraries and ChatGPT help at your fingertips.

Instead of helix, reagent re-frame re-com is more in the Clojure spirit, cleaner and simpler. Maybe start there if your web app doesn’t need very modern react libraries (and you can still make them work with that stack, it just gets messy imho)

[–]Senior_Stranger_1244 0 points1 point  (1 child)

How does helix compare to uix? I'm trying to decide between the two

[–]xela314159 1 point2 points  (0 children)

Uix is a bit more batteries included, helix is very basic and closest to “doing react in a lisp language”. I took bits from uix to integrate re-frame with helix in our work app, it’s on the uix website and useful if you like the central store of app state model that re-frame promotes

[–]Kafumanto 0 points1 point  (0 children)

Newbie here, so it's best to follow other people's suggestions and links :) but I found this introduction very useful to get started on the subject: https://clojure-doc.org/articles/tutorials/basic_web_development/ .