This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-15
Channels
- # announcements (1)
- # babashka (21)
- # beginners (23)
- # biff (8)
- # boot (1)
- # cider (4)
- # clerk (21)
- # clj-kondo (31)
- # clojure (60)
- # clojure-brasil (5)
- # clojure-europe (20)
- # clojurescript (21)
- # datomic (14)
- # graalvm (10)
- # honeysql (1)
- # hoplon (4)
- # hyperfiddle (42)
- # introduce-yourself (1)
- # leiningen (1)
- # lsp (53)
- # pathom (4)
- # releases (2)
- # scittle (24)
- # shadow-cljs (3)
- # xtdb (4)
For somebody new to STM, could somebody explain to me how Atoms in Clojure allow us to do concurrent actions in a different way to Promises?
I'm currently reading the article about STM here: http://java.ociweb.com/mark/stm/article.html
From the article, it seems that Promises are a mechanism that performs serial execution of asynchronous tasks, by having them performed serially. In comparison, Atoms are a mechanism to share state between asynchronous tasks, without having them run serially, to potentially reduce the overall time. From the article: > There are two general categories of multithreaded software. In one category the goal is to divide the work involved in processing a single "job" into pieces and run the pieces concurrently in order to complete the job sooner. In the other category the goal is to coordinate the execution of multiple "jobs", allowing them to execute concurrently so that as a group they complete sooner than if they were run serially. In both cases there can be contention over the data being accessed. However, the issue is perhaps more common and harder to avoid in the second category.
So Promises are of the first kind, and Atoms are of the second kind of concurrent mechanisms described
Atoms are totally disticnt from STM. the reference type that participates in STM is ref
, and the update fns alter, commute
you can have any amount of promises you want using the same atom, so that would be a way in which they are different.
when a promise is resolved it can't change it's value, atoms can change their value at every deference
I am trying to use clojure deps to import a dependency that I have from github. https://github.com/lsevero/abclj
However, the project is not published with a deps.edn
and so, I'm getting this error
Error building classpath. Manifest file not found for io.github.lsevero/abclj in coordinate #:git{:url "
I'm not sure what I need to do to get past this. I'm very new, and I'm trying to use the documentation for the clojure cli tools and deps-new for project generation, but this package.clj seems to be from some older generation of cli tools if I am understanding correctly? But I don't see a whole lot of results coming up when searching.
for these i fork the repo, add a deps.edn, and typically things work. make sure you transfer the project.clj deps over accurately.
also, i'm not sure having a :tag, and :sha makes sense, i thought a tag referred to a sha
you can use this as a maven-style dependency to fetch from clojars rather than git... I think deps can only use deps and poms as manifest types
specifying a tag also requires at least a short SHA to ensure that the tag hasn't moved: <https://clojure.org/reference/deps_and_cli#_coord_attributes>
what Bob said is how it was explained to me
re: maven-style deps How can I do that, is there an example?
on that library's GH page, at the top of the readme, there's a clojars badge (gray and orange) - following that link provides coordinates in several styles, including a Clojure CLI/deps.edn format
I include this longish explanation because that clojars badge is fairly common, and I think it's a decent trick to know
oh thanks for pointing that out. I'll be sure to check that next time
Hi! I am very new to clojure and have general question: what is idiomatic way to handle errors in Clojure? I've read https://stackoverflow.com/questions/27742623/idiomatic-error-handling-in-clojure on it, and it turns out, what there are two main ways to do this: simply by exceptions like in Java or monadic way. Can you please share your experience on what and when each way is good and bad, describe some pros and cons of both? I persanally really love monadic error handling, but not really sure is it natural to Clojure or not.
A monadic way was popularized https://fsharpforfunandprofit.com/rop/ as "railway oriented programming" and works fine in Clojure. Another instance is Zach Tellman's "Manifold" library for Clojure, wherein the centerpiece, the "Deferred" thing, resolves to either a successful value or an error. Manifold thereby overcomes a weakness of host Exceptions, which is their rocky path to the interested client, which might be on another thread.