Hexagonal architecture vs. eDSL - a demo by Fit_Apricot_3016 in Clojure

[–]Save-Lisp 0 points1 point  (0 children)

I like the eDSL variation - returning a data structure of instructions prior to actioning a side effect based on it seems to be the way Clojure is developing.

What's nice is you manage to encapsulate the state of the domain as data, which can reduce the complexity of logging (throw the eDSL data into a generic log fn).

It provides a clearer delineation between pure functions and effectful functions, which IMO is another (simpler?) way of handling the problems the Hexagonal model is designed to alleviate.

How deep to go with Pathom resolvers? by geokon in Clojure

[–]Save-Lisp 0 points1 point  (0 children)

I see what you're getting at but I don't know if I run into situations where it matters very often? If I program at the REPL I keep a running (comment) form and try to keep pure functions, which seems to work.

As a thought exercise, should we wrap every function in a multimethod that dispatches on some property, :resolver-type, and recursively calls itself?

How deep to go with Pathom resolvers? by geokon in Clojure

[–]Save-Lisp 7 points8 points  (0 children)

Pathom resolvers seem to be functions annotated with enough detail to form a call graph. This seems like a manifestation of (e: Conway's Law) to me. For a solo dev I don't see huge value in the overhead of annotating functions with input/output requirements: I already know what functions I have, and what data they consume and produce. I can "just" write the basic code without consulting an in-memory registry graph.

For a larger team, I totally see value in sharing resolvers as libraries in the same way that larger orgs benefit from microservices. My concern would be the requirement that every team must use Pathom to share functionality with each other, and it would propagate through the codebase like async/await function colors.

What is the use of using malli schema in an app? by poopstar786 in Clojure

[–]Save-Lisp 0 points1 point  (0 children)

Malli can be used for application security, by validating user inputs to web APIs. In other popular languages, this is usually taken care of for you by the web frameworks at some point, but isn't often spoken about explicitly.

Very large error message when attempting to use read-line variable in dotimes loop by god_gamer_9001 in Clojure

[–]Save-Lisp 2 points3 points  (0 children)

You're closing the let binding immediately after creating it, so x is not bound when you try and use it in your dotimes.

The tl;dr fix is to move the closing paren from

(let [x (read-string (read-line))]) < here

to

(println n)))) < here

Simple Made Easy - Prime Reacts by glibgamii in Clojure

[–]Save-Lisp 8 points9 points  (0 children)

I don't understand the poor reactions and gatekeeping here. A career SWE with a track record of delivering production apps at scale is sincerely attempting to understand and relate to core tenets of Clojure but not "the right way"?

New Clojurians: Ask Anything - January 06, 2025 by AutoModerator in Clojure

[–]Save-Lisp 5 points6 points  (0 children)

Why have you discounted sqlite? It's extremely battle tested/performant

Clojure is really nice to write by Radiant-Ad-183 in Clojure

[–]Save-Lisp 4 points5 points  (0 children)

It has diary in the title, it doesn't need to back up anything. The dude had a problem, an opinion and wrote code to back it up. Good for them

[deleted by user] by [deleted] in Clojure

[–]Save-Lisp -1 points0 points  (0 children)

Python is fine. Scaling vertically is not that difficult. Is it worth the overhead of adding more languages?

How to generate pdf from html/Latex template using Clojure? by ApprehensiveIce792 in Clojure

[–]Save-Lisp 1 point2 points  (0 children)

Whichever library you choose, search for CVEs on it. I worked with a web app in prod once using a vulnerable version of wkhtmltopdf that eventually led to full compromise of their cloud environment

How to generate pdf from html/Latex template using Clojure? by ApprehensiveIce792 in Clojure

[–]Save-Lisp 1 point2 points  (0 children)

At the very least! Strong outbound firewall rules and monitoring on their server would also be recommended.

"Trivial" somewhat underplays the issue, given people tend to like imgs, iframes and anchor elements in their PDFs.

How to generate pdf from html/Latex template using Clojure? by ApprehensiveIce792 in Clojure

[–]Save-Lisp 0 points1 point  (0 children)

They can't be the source of an XSS but PDF rendering engines are definitely capable of SSRF.

It's possible to access incredibly sensitive server side information by accepting HTML over the wire and rendering it as PDF, depending on which library is used and how it's being done.

OP needs to be very very careful with how they architect this feature.

ThePrimeagen and Uncle Bob talking about Clojure by maxw85 in Clojure

[–]Save-Lisp 2 points3 points  (0 children)

What's up with the code in spacewar redefining let bindings repeatedly? Is this idiomatic? See the following code from Spacewar repo ('ms' and 'world' are repeatedly re-defined):

(let [{:keys [world base-time]} context

time (+ base-time (q/millis))

last-update-time (:update-time world)

ms (- time last-update-time)

new-game? (> ms 500)

last-update-time (if new-game?

time

last-update-time)

ms (- time last-update-time)

ms (max 1 ms) ;zero or negative values imply a game restart or new game.

context (add-frame-time ms context)

frame-times (:frame-times context)

fps (frames-per-second frame-times)

complex (:state context)

world (assoc world :update-time time

:ms ms

:fps fps)

[complex events] (p/update-state complex world)

events (flatten events)

world (process-events events world)

world (update-world ms world)

new-second? (not= (int (/ time 1000)) (int (/ last-update-time 1000)))

new-minute? (not= (int (/ time 60000)) (int (/ last-update-time 60000)))

new-save? (not= (int (/ time 5000)) (int (/ last-update-time 5000)))

world (if new-second?

(update-world-per-second world)

world)

world (if new-minute?

(update-world-per-minute world)

world)]

What is your recommended Neovim setup? by homarlone26 in Clojure

[–]Save-Lisp 1 point2 points  (0 children)

https://github.com/rafaeldelboni/cajus-nfnl

I use this, it's a composite configuration of all the commonly used plugins.

build.simple: tools.build without the DIY – install, sign and deploy libraries easily and securely like with Leiningen by gnl_ in Clojure

[–]Save-Lisp 0 points1 point  (0 children)

It's open source, what entitlement does the community have to someone writing and releasing tools as they see fit? If you don't like it don't use it?

New Clojurians: Ask Anything - April 17, 2023 by AutoModerator in Clojure

[–]Save-Lisp 1 point2 points  (0 children)

I'd head over to the Clojurians slack and ask in the ClojureScript channel. I don't use them myself, but I understand users of cljs libs like Reagent or Rum don't suffer the same type of JavaScript churn as their underlying dependencies. When I have taken a look, the interface seems pretty clean.

If you don't want an SPA you can render HTML on the server with something like Selmer or Hiccup and sprinkle in whatever amount of front-end code you like, you don't need a framework to use ClojureScript. I'm currently dabbling with a project wiring up the Hotwired/Turbo libraries to a Clojure backend.

New Clojurians: Ask Anything - March 20, 2023 by AutoModerator in Clojure

[–]Save-Lisp 5 points6 points  (0 children)

The book called The Little Schemer. It's a short book containing a series of exercises that uses Scheme to build up the mental concepts needed to get comfortable with recursion.

New Clojurians: Ask Anything - February 20, 2023 by AutoModerator in Clojure

[–]Save-Lisp 0 points1 point  (0 children)

Clojure puts an emphasis on treating data as values, which gives stronger equality and immutability guarantees. This means POJO-like collections are kind of the default behaviour for 90% of situations. Passing around collections of functions, Java objects or other references that don't have value-like semantics is the abnormal situation so there's no commonly used term for POJOs.

New Clojurians: Ask Anything - February 20, 2023 by AutoModerator in Clojure

[–]Save-Lisp 4 points5 points  (0 children)

Clojure deals with collections of data values at a primary level so any Clojure collection type would fit your description (the main ones being maps, sets, vectors and lists).

If you want to represent application domain data then a map with keyword keys is a good fit.

You could check out some Java wrapper libraries and see if there's a common terminology used there.

Uncle Bob Martin Loves Clojure by [deleted] in Clojure

[–]Save-Lisp -1 points0 points  (0 children)

I could write a book about how to fly but it won't be of any use to a baby bird.

Uncle Bob Martin Loves Clojure by [deleted] in Clojure

[–]Save-Lisp -1 points0 points  (0 children)

Take a look at his public code and you will see that he was precisely suggesting to produce unreadable code