This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (2)
- # aws-lambda (14)
- # babashka (8)
- # beginners (66)
- # clojure (113)
- # clojure-spec (9)
- # clojure-uk (7)
- # clojurescript (24)
- # data-science (12)
- # datomic (45)
- # docker (2)
- # emacs (1)
- # fulcro (48)
- # jobs-discuss (22)
- # kaocha (7)
- # keechma (3)
- # luminus (7)
- # off-topic (7)
- # re-frame (6)
- # shadow-cljs (43)
- # spacemacs (18)
- # tools-deps (2)
- # vim (1)
- # vscode (2)
- # yada (11)
is there a way to indent and lint the clojure code which read from stdin and write to stdout ?
@nxtk seems interesting, but how can i do indentation read from stdin -> stdout ?
Hi. How do you actually deploy a Ring app on a server? In other words, how to deploy an uberjar.
It depends a bit on your setup. Does this help? https://github.com/ring-clojure/ring/wiki/Setup-for-production
I have been able to make the jar run on my linux server. Just wondering what if there is some problem or the whole operating system reboots? How to make it so that it starts up again.
You can set up a system service which keeps it up. Checkout systemd, systemctl etc
I am struggling a bit with the anonymous functions. I am trying to make two identical functions, the one with # works, but the one using the longer notation lambda (fn) doesnt.
see, you want to have a function that accepts an argument x and increments it by inc-by
in your long form you have nothing to do the same job as % in your short form, get it?
Hey, I just trying out the re-frame templete with cider. Did
lein new re-frame yeah +cider and tried to jack in, but got the following error
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11). missing instance
lein devruns fine
it worked fine for me. Did you get an option for which build to use and you chose
also, this project has two build systems. I saw that in lein it just calls out to shadow so when CIDER asks me which build it should use i just said shadow
and you're receiving that error message after choosing shadow and then app as the build?
nevermind now I see what you meant, I thought you meant the CLJS repl type. That was actually the error.
Hello, I'm messing around with
deftype and wondering if it's possible to create a variable that all the methods will have access to. Basically I'd like it to look something like this:
Where both methods will have access to that
(deftype ManagementApi [endpoint] ManagementApiProtocol ;; (let [api (make-api endpoint)] (get-connection [this params] ;; Do something with the outer api ) (delete-connection [this params] ;; Do something with the outer api )
apivariable (not sure what the syntax would be)
i don't believe so. What you can do is pass that in and make a function that takes the endpoint and returns the deftype with both items bound. Ie,
(defn management-api [endpoint] (->ManagementApi endpoint (make-api endpoint)))
I have a somewhat conceptual question. So I come mostly from a Ruby background where a lot of ORMs are available. As far as I noticed, Clojurians do not seem to like ORMs. So how do you structure your persistency logic then? Do you just write specialized SQL queries for each API request? Do you have open source examples how you structure your database logic where there are more than one or two tables?
Or is it possible to have a somewhat generic set of functions which you use to build the persistency logic? When I try thinking about how this could be achieved, it seems really hard e.g. when it comes to joining tables or other complex queries
@christian.paling For basic CRUD, you can just read and write hash maps, and update/delete by example (using a hash map) against the database using
clojure.java.jdbc or a few others). For more than simple CRUD, you can either write the SQL (and use any of those JDBC wrappers) or you can look to some of the DSLs out there like HoneySQL, Walkable, etc.
Thanks for the links ! I will take a look at them ! So people do not use something like lightweight repository objects or anything. But actually just write the SQL queries they need
I‘m sorry if these questions sound confusing, I‘m just used to having something like
And whenever I implement a system, even if I don‘t use a ORM library, I somehow have the urge to abstract my persistency logic, i.e. implement my own mini ORM
User.where(...).joins(...) maps over to something like HoneySQL's DSL:
(-> (select :a) (from :user) (where ...) (join ...)) to produce the data structure that represents the query. Then you call
(jdbc/execute! data-source (honeysql/format dsl-data))
Clojure's way is all about "simple", rather than "easy". ORMs can seem "easy" but they are definitely not "simple".
And where do you put your queries? Do you put them next to the API endpoints that need them? Or do you group them in namespaces like all user queries go into a user namespace?
I've used a bunch of ORMs over the decades, including Object Databases when those were a thing, and I do think they're over-engineered but they're also problematic in so many ways.
Heh, years ago, I even gave a conference talk about the problems with ORMs 🙂 Have you read Ted Seward's piece (from years ago) arguing that ORMs are the "Vietnam" of Software Engineering?
As for where to put the queries, it really depends on how big/complex your app is. There are lots of ways to structure code and Clojure isn't very opinionated about that. The only guiding principle is to try to keep side effects at the edges and write as much of your code as possible as simple, pure functions that are easy to test/reason about.
This one? http://blogs.tedneward.com/post/the-vietnam-of-computer-science/ I have not read it yet 🙂
I haven't spoken at any conferences now for nearly seven years. I was a fairly regular speaker around the world before then for Macromedia/Adobe-related tech (where I worked 2000-2007).
I see. Well, thanks for your time and input. I’ve got a lot to read now ! For my next application I‘ll try out the Clojure way of working with the database 🙂
If you have any Qs about SQL/JDBC stuff there's a #sql channel and there's also a #honeysql channel if you go that way.
https://cljdoc.org/d/seancorfield/next.jdbc/1.0.13/doc/getting-started and https://cljdoc.org/d/seancorfield/next.jdbc/1.0.13/doc/getting-started/friendly-sql-functions will give you an overview of how most folks work with JDBC in Clojure