Fork me on GitHub

What is the current state of building serverless apps in clj/cljs? Do people use cljs->node.js to speed up the cold starts? Or do they use graalvm to compile clj into binaries?


@U6SEJ4ZUH Some people build serverless stuff with #nbb (CLJS interpreter on Node.js) as well. See Also see for an extensive example. It works on Google Cloud as well, #babashka is also used, e.g. on #holy-lambda. #nbb and #babashka are good for prototyping, when you want to optimize further you can use compiled CLJ(S) and GraalVM native-image.


I am now seeing a weird error:


Try evaluating (ns-unalias 'user 'log) before running "Load current file...".


I wonder why I shall do that


Also, make sure there's only one require in the user namespace that uses the log alias.


Difficult to say for sure, but one possibility is that you've previously required e.g. [app.logging :as log] and now [something.else :as log].


ns-unalias will remove the current alias mapping.


I found out this only happens after I performed a repl/refresh


This happened to me as well. Worked around it by removing the path containing user.clj from refresh-dirs. This works fine for me so haven't thought about it enough to figure out why it happens.


I ended up adding the following at the top of the user.clj file

(doseq [sym '[main log]]
  (ns-unalias 'user sym))


As usual, I'll take this opportunity to say "Don't use refresh/reload -- develop better REPL habits instead where you eval every single change as you make it so the REPL is always up to date!". These sorts of weird problems are exactly why I tell people not to use this stuff: when it works, it's "magic" -- when it breaks, it's an impenetrable mess.


Yeah, a big +1 to avoiding refresh/reload.


Do you take care to unalias vars when you rename a function? In my experience old names leads to more annoyances than using reload.


How often do you rename functions? 👀


> How often do you rename functions? During development, I don't always think of the best name on the first try. I try to settle on a good name before others have a chance to rely on the name, but not necessarily before a feature is fully implemented. Is that not normal?


@U7RJTCH6J Sounds about right to me, so function names become an API that generally doesn't change once you have "clients" in the code that depend on them. I will occasionally clean out a ns and eval it again but I find that's fairly rare and I just have a couple of Clojure snippets bound to a hot key for that in my editor. It's a localized "reset" just on that one ns that doesn't actually remove the ns -- and therefore doesn't break any code that depends on (which the reload/refresh stuff does).

👍 3

Only happens for the dev/user.clj


It is triggered when I run calva load current file and dependencies


How to you align the clojure data struct in log file? Mine is cluttered on the console:

Ben Sless12:02:59

Do you want text logs or structured logs?


Better text logs with structured json if any. Else structured logs

Ben Sless15:02:44

It's one or the other I'm afraid. If you do structured logging (just log data structures) then you can pipe the output to another process which can pretty print it. JSON in jq, edn in jet, etc


I know about Datalog / Datomic, but it's not what I'm looking for here. With MySQL / Postgres, we have: the database & the query language (SQL). Is there something similar (open source / free for commercial use) where the query language is clojure/scheme-ish. The DB does not have to be relational (i.e. something built on kv store, document stores, mongodb, dynamodb, ... are fine too.) The main idea is that: • there is some persistent store of state • we type in some query in a Clojure/scheme-ish langauge • the query read from /modifies the persistent store • the persistent store is the only 'data' on heap; i.e. the query, after running, does not leave other state on the heap (that is not part of the persistent store) -- in particular, we can capture all state by capturing the persistent store


The problem definition is not clear. What exactly do you mean by "Clojure/Scheme-ish language"? Datalog can be expressed using Clojure data structures/functions, but it doesn't suit you. SQL can be expressed using Clojure data structures/functions, but it doesn't suit you as well.


Datahike? Datascript? Datalevin?


you can query with EQL (edn query language) using a library called, but you have to bring your implementation for your own data store. For instance, is for sql databases.


In a deps.edn project, I tried do include:

io.github.shrynx/circle-packing {:git/sha "5e00fd45e6b6c03a6ffc5af0703231c88962bdc6"}
when I try to start the repl, I get:
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: Error building classpath. Manifest type not detected when finding deps for io.github.shrynx/circle-packing in coordinate #:git{:sha "5e00fd45e6b6c03a6ffc5af0703231c88962bdc6", :url ""}
note that that repo is not on clojars, but reading the deps.edn guide it didn't seem that was a prerequisite. What's the true prerequisite to be able to import a library this way? Does the library have to be a deps.edn project too?


Apart from the sha, you must specify the URL.


The sha itself doesn't point to anything - it needs a context, which is the repo.


By which I mean, deps.edn is capable of inferring that from the fact that io.github.shrynx/circle-packing is of this specific form?


Huh, you're right! I didn't know about that convention.


Yes, I just found out too, reading the guide; and also, from the error message, you can see that deps.edn knows about the URL. Which confuses me, I don't understand the manifest type not detected part


> Does the library have to be a `deps.edn` project too? Ah, I believe so, yes. Or pom.xml.


yes, indeed; thank you @U2FRKM4TW!


Right, that links confirms that. No problem, and thanks for teaching me about that convention. :)

🙌 1

Is there a fork-join (aka S' combinator aka Pheonix Compinator) in clojure.core? basically h f g a-> (h (f a) (g a)) ?


The closest thing that comes to mind is (apply h ((juxt f g) a)).

Noah Bogart17:02:35

You can make your own with juxt: (fn [h f g a] (apply h ((juxt f g) a)))

Noah Bogart17:02:42

Damn, too slow lol

😄 2

haha nice! Thanks for the replies. I always forget about juxt!


Well, if the amount of functions is fixed, then spelling it out would probably be better (and shorter, in the case of just 2 functions).


yeah, that is what I was doing initially.


Just thought there might be something in core already.


In the java world forkjoin refers to a mechanism for executing tasks on multiple threads


yeah kinda the same idea. fork-join is what I know it by from Rxjs.


I think the “fork” terminology might’ve been borrowed from APL? Don’t quote me on that