This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # beginners (29)
- # boot (17)
- # calva (1)
- # cider (31)
- # cljs-dev (3)
- # clojure (169)
- # clojure-europe (1)
- # clojure-france (1)
- # clojure-russia (40)
- # clojure-serbia (3)
- # clojure-uk (42)
- # clojurescript (19)
- # clr (3)
- # core-async (7)
- # core-typed (3)
- # cursive (43)
- # datascript (4)
- # datomic (2)
- # dirac (4)
- # emacs (2)
- # fulcro (85)
- # funcool (1)
- # nrepl (5)
- # off-topic (14)
- # shadow-cljs (28)
- # spacemacs (5)
- # tools-deps (2)
Forgive a somewhat confused question from the perspective of someone who has been interests in lisps for a long time but only recently realized Clojure was a thing... the “data as code thing”. I’m curious (honestly so) about in what sense/senses that is true, or maybe more correctly relevant. Especially as compared to other relatively main stream languages...
It occurred me to consider this, as I suspect but haven’t verified that I probably can’t access Clojure code as actual data at runtime? If I can actually insert an sexpr into a function in runtime the question pretty much falls 😅
@mattias504 Code is just a series of lists and vectors etc. For example
(list 'def 'foo 42) produces
(def foo 42)
Macros are functions that are run on the code forms before they are compiled and run. So they are just transformations of data structures, that accept code as input and produce code as output.
for example, so
(defmacro make-foo [v] `(def ~'foo ~v))
which is then compiled and executed
(clojure.core/def foo 42)
If you said
it will produce
(make-foo (+ 40 2))
-- the arguments are "just code", not evaluated.
(clojure.core/def foo (+ 40 2))
There's a function
eval that you can pass data to at runtime and it will attempt to compile and run it.
In this case the argument is evaluated --
eval is a regular function -- and so it's the same as
(eval '(+ 40 2))
Very cool. Will need to take some time to digest this, thanks. On my mobile now so will be back later, wiser 😀
I need one gen-class for using a Java library from Clojure. I tried to find information where to call the compile function for that class in the application. Now using REPL is a bit problematic since when reloading all namespaces in REPL the gen-class is not found.
Can anyone recommend any content that provides a solid walkthrough of a web application using Clojure, deps.edn, scss, hiccup (or similar), that does not include anything to do with Luminus or Clojurescript? I'm looking for as basic as possible so I can get a grasp on the simple tooling things before stepping up into the more complex. It seems as though almost everything jumps straight into Clojurescript, Figwheel, Om, Re-frame, Luminus.... or it has a walkthrough but doesn't include things like scss, or even Garden for that matter. I've ran out of options in my google searching, I'm hoping something exists and I just missed it somehow. I can figure out the syntax of each library. My confusion lies in, for example, how to compile scss (or Garden, but would prefer scss) into a Clojure web app that doesn't use Clojurescript, Luminus or any of the other things I listed above that I'm not interested in at this time. Any suggestions to content would be appreciated... thank you.
@UAW40E21F I might be able to show an example if I can better understand what you are looking for: It sounds like you are not interested in a SPA of any kind and you just want to see what it looks like to serve up a simple server side web app with Clojure, yes?
That is accurate. Including compiling and pulling in scss, using deps.edn to build, and any other handy things you might see fit.
I found Edge to be helpful https://github.com/juxt/edge. It does an excellent job of showing a Clojure web app with all kinds of goodness using the latest and greatest. Be warned, there is a lot going on and knowing the bare minimum requirements is a little difficult if you are not familiar with Clojure. I found the basic tooling and project structure matched my own sensibilities so much so that I took some time to break down what I saw as the “core” components of Edge: https://github.com/tkjone/reveng-edge Its not done, and Edge has changed a bit since I did my first run through, but reveng-edge should provide some of the core things you are looking for. For example, if you want to see what at the most basic serving some text would look like, you would checkout https://github.com/tkjone/reveng-edge/tree/master/web-server. Once you see that, you might want to add the reloaded-workflow so you would check out the additions here: https://github.com/tkjone/reveng-edge/tree/master/web-server-reloaded. You may want to add server side rendered templates so checkout this https://github.com/tkjone/reveng-edge/tree/master/web-server-templates. If you do not want the reloaded workflow, just review web-server/reloaded-workflow and compare it to SSR-templates. The SSR Templates one might be more of what you want as it is clearer to see how you can 1. Add routes 2. serve HTML from the server and 3. add CSS to your html (I do not include CSS, but I can guide you through that in DM if you need)
I know you were looking for more of a guide/blog post, but I have not come across any outside of luminous. Most of what is available are example projects like Edge or https://github.com/robert-stuttaford/bridge
In case this is helpful: I've been trying out ClojureScript/Reagent by setting up a single page app with Leaflet, which is something I'd usually do with JS/React/Redux at work. The repo is here: https://github.com/kellyi/reagent-leaflet-sandbox
So far I have 1. set up development and production builds 2. set up using a JS-library, Leaflet, 3. set up some app-state Reagent atoms with a minimal thing to persist the map zoom level in local storage, 4. added some linting stuff using
I skipped doing re-frame for now because although I like it conceptually it feels like a lot to take on when just starting out.
Thank you for all the resources. Apologies for not responding sooner, got caught up running errands. Very appreciated to everyone that has responded so far. I'll take a look at all the links
Gen-classes are pretty nice way to create simple Java classes that are needed e.g. when using some Java library via Clojure/Java interop. The only major issue I had was how to use REPL effectively with gen-classes. My standard procedure to refresh everything: (do (require '[clojure.tools.namespace.repl :refer [refresh-all]]) (refresh-all)) (compile 'my-gen-class) ... didn't work with REPL - REPL used the older version of gen-class and I had to restart REPL every now and then which was a bit of a nuisance.
hi, people. It seems I can't find what is session lenght of ring-session and how can I set it to something
Looking through the source there may be two parts to adjusting session length: https://github.com/ring-clojure/ring/blob/95e4ca25d5b98c45f927b32b5c3c85c21c999d96/ring-core/src/ring/middleware/session.clj The first being :cookie-attrs which can have an
:expires date or
:max-age https://github.com/ring-clojure/ring/wiki/Cookies the second being the store you use which by default is the mem store.