Fork me on GitHub
Micah Redding00:02:35

I’m trying to switch from Cegdown (a Clojure wrapper for Java Pegdown) to (the Java library recommended to replace it). The relevant Java import looks like this: import com.vladsch.flexmark.html.HtmlRenderer; I can only get Flexmark to load in my dependencies, if I include “flexmark-all” as such: :dependencies [[com.vladsch.flexmark/flexmark-all "0.62.2"]] But I cannot figure out how to require it successfully in the relevant contexts. Here’s what I’m trying: (:require [com.vladsch.flexmark.html.HtmlRenderer :as md2]) Here’s the error I get: Could not locate com/vladsch/flexmark/html/HtmlRenderer__init.class, com/vladsch/flexmark/html/HtmlRenderer.clj or com/vladsch/flexmark/html/HtmlRenderer.cljc on classpath. Obviously, I’m missing how something here fits together.


com.vladsch.flexmark.html.HtmlRenderer is a java class. your ns should have an import declaration: (:import com.vladsch.flexmark.html.HtmlRenderer)


If you're not familiar with java interop, you may want to check out

❤️ 2

I've been using flexmark to render my blog posts. It's worked well for me. You can check out if you'd like to see an example of using flexmark from clojure. My code is not* well documented, but maybe you'll find the example useful.

❤️ 2

How do I best create a backend API call to return edn from a ring backend (back to a clojurescript webapp)? Can I just put edn in the `:body` of a route? That gives me some errors. Do I wrap it in a string like `"{:test [\"test\"]}"`


@zackteo I searched for ring edn middleware and saw this: -- and in the examples it looks like they are just doing :body (pr-str data) (the library seems focused just on decoding EDN from the request body).


And I guess just calling pr-str on Clojure would produce EDN so maybe it is just that simple.


Perhaps a silly question but is edn not the standard that is used for a clojure stack?


(I've only ever dealt with sending/receiving JSON since I have a Clojure backend but our frontend is JS)


@zackteo Clojure has clojure.edn/read-string but there's no (`clojure.edn`) print-string because (`clojure.core`) pr-str does the job. I don't know what folks do for a MIME type when send EDN back to the browser?


I see I see! Yeap looks like it really is that simple read-string and pr-str


I've used edn for communication between front end and back end, but I used for serialization since that's what it's purpose is


It probably doesn't matter too much if you're not exchanging a lot of data


When will you use transit tho? I know people also use . But won't this only be used if say the frontend needs to receive JSON? :thinking_face:


I haven't used chesire. here's the rationale for transit:


Thanks! But wow seems like a lot to take in


read-string and pr-str work well too. It can be something to look into if you'd like to improve the edn serialization.

Enrico Teterra01:02:16

i have a list of lists [["bob" 17]..] and a record (defrecord person [name age]), question: how do i convert all items in the list to the record? map ->person ,,, doesn't seem to do it since it passes the whole list as an arg


(apply ->person data) will convert an individual vector.


so (map #(apply ->person %) list-of-lists) should do what you need @enrico.teterra


user=> (defrecord person [name age])
user=> (def list-of-lists [["Bob" 17] ["Sean" 58] ["Jay" 60]])
user=> (map #(apply ->person %) list-of-lists)
(#user.person{:name "Bob", :age 17} #user.person{:name "Sean", :age 58} #user.person{:name "Jay", :age 60})

👏 2
Enrico Teterra01:02:09

ahh i knew there was a simple way =) thanks Sean


Working with hugsql in Calva, and CLJ-Kondo keeps giving me this error even though the docs for the function prove it wrong, has anyone encountered this and know how to fix it?


Resolved. I just deleted the .clj-kondo folder containing it’s cache and it seems to be fine now


FYI this is a perfectly reasonable channel to ask such questions, but if in future you have questions that might be specific to clj-kondo there is also a #clj-kondo channel that is likely to hit active users (and even its developer).

👀 2

Thanks for that 🙂


@U01D4A7PJG7 the reason clj-kondo doesn’t know about this var is that is generated by some macro it doesn’t understand. You can configure clj-kondo to ignore these vars. If you delete the entire .clj-kondo dir with also the config in it you will get less information from it


I didn’t delete the config. Although the issue only happened with one specific var generated from the macro and not all of them, which was why I was confused.


After clearing the cache it worked and didn’t complain any more


Ok, I think it will start to complain again though after you have visited the hugsql related namespace since kondo thinks it knows all about the vars in that namespace. See this conversation on how to ignore this ns.

SoV404:02:28 I want to turn a website that mainly serves html and also serves javascript... into a phone app. What's the state of the art in the clojureSphere for native apps?


React Native


But that would not be as simple as “turning html+javascript into a phone app”… to use React Native you pretty much have to start from scratch


If you do start with React Native, there’s react-native-web, which can allow you to serve/create a website from the same codebase (I haven’t used it myself)


yes that would be the ideal ... one source code folder to rule them all


it's like we just didn't see multiple screen sizing coming xD


Is it possible somehow to access the previous element in the map function (I guess I could use map-indexed and get)


one trick is to utilize map 's extra args:

(let [xs (range 5)]
  (map (fn [a b]
         [a b])
       xs (next xs)))
;; ([0 1] [1 2] [2 3] [3 4]) 

👍 5

Ah.. yes because fn receives one element from each collection. neat.


Good morning everyone! I'll be livestreaming another coding challenge at 9:45 AM EST today if you'd like to join. Today's challenge comes from another Eric Normand newsletter, you can find it at the bottom of this blog post: And here is the link to the livestream: Have a nice Wednesday 🙂

clj 2

I'm just finishing up a Reagent tutorial and we use Chrome's lighthouse to check performance. The tutorial shows him getting an 88% but I'm getting a 69% and it is saying it is because I haven't removed unused js. But we use Shadow CLJS and the tutorial says the release command compiles it using Google Closure to do DCE and tree shaking for us. The tutorial's lighthouse assessment doesn't give that "unused js" warning so not sure why I didn't get the performance benefit.


What tutorial are you doing?


Jacek Schae's Reagent Pro course. It's been great. I'm excited to move on to his other one's now too.


lighthouse to check performance... interesting... don't know what that is -- thanks for the keywerd


I have noticed that compiling into cljs has some "sweet spots" where sometimes everything lines up perfectly under the little surgical switchblades of the compiler and it: compiles very fast, and the size is very small. then you add one character or one variable and suddenly it takes the standard time and the file size is bigger by a lot... which is usually not a problem because it's still lightning fast, but yeah, it's weird that there are resonant nodes in the compile process but also not that weird.


Yeah Lighthouse is part of Chrome dev tools. Just right click on any webpage, click inspect, and it's the last tab. Pretty cool. The reagent site had great Accessibility, "Best Practices", and SEO score btw. Pretty cool as it doesn't seem we did anything purposely to get those good scores.


I'm just bummed at the bad performance rating even though tbh, I don't notice anything while I'm actually using the site.


try it on the slowest device you have


Not sure if this is the place to ask, but I'm doing a little bit of research in order to ... not have to write a SPA, and I came across this: Is there anything stopping me from using that with a Clojure back end producing HTML? Does anyone here have any experience with it?


You can use it with any backend.


That's an interesting tool...


I've seen some people experiment with this. I think one of them was @U050RCD9L. @U11SJ6Q0K also did related work to this.


yeah, I have made ripley which tries to be a similar experience to writing reagent but on the backend


Theres a couple of libraries wrapping turbo and stimulus made by @UG9U7TPDZ, dunno how ready they are yet, haven't had time to check


I'm using them currently but I still need to write some more documentation.


Which will probably be my weekend project 🙂


Also working on a project to wrap this all together (kind of like Hotwire) to make it easy to use in Clojure


Which is this: But it has no documentation at all and I'm probably going to change a lot in the near future.


cool, I didn’t know about liveview-clj


seems most clj solutions are in various stages of alpha


comparable to the beginning of React times where we had several competitors: Quiescent, Rum, Reagent, Om, ...


ripley is also a side project, but I’m hoping to use it in actual work someday (hopefully soonish)


liveview-clj not even in alpha stage. it was build as a 1-day prototype/POC


I'll be happy if we can just get out of SPA hell 😄


yes, it’s good to have multiple different solutions and people exploring the solution space in different ways


I also have a great aversion to the JS/npm ecosystem born through pain that I’d like to get away from


that said, React is a mature and feature rich piece of software that can’t be trivially replaced


It's very hard to avoid javascript in frontend development though


Usually when I need a bit of JavaScript, the desire for React grows after 10 loc....


Yeah writing raw JS is terrible. And react / reagent has made it easier. I do think Hotwire has done a good job in solving this in a SSR manner. So I'm looking forward to properly releasing these projects 🙂


btw, liveview-clj is using this library for writing lisp-like javascript expressions -


What's the purpose of using this? So that the JS isn't bloated? (like it would be with CLJS)


Maybe a convenient way of writing JS instead of sending those raw JS forms by hand?


just a syntactical convenience probably


my use case: • need a way to generate and inject small portion of javascript code on server side • should not be expressed as string manipulation function • must be possible to parameterize outcome • ideally but optional, code should be maintainable scriptjure fit really well into those constraints


maybe you can also send some CLJS to the client and interpret using sci... this will add more bloat to your bundle size (~ 120kb gzipped) and will be less performant, but it's a fun idea ;)


but I guess the idea of this liveview setup is to not need any CLJS / JS tooling at all anymore right


I find it an interesting old/new approach


idea of liveview is to manage the state on backend side by managing web-socket connection everything on top (like “generating html on backend and send it to client” or “remove js from frontend”) are an extension to that model


it sounds cool, but it also sounds like it can get complicated, like the server has to manage the state of all connected clients. what if it gets out of sync? that can get really messy I assume


there is enough control to prevent it getting out of sync + the state is implemented as an abstraction, it is always possible to keep the data somewhere else like DB. but as I said this lib is nothing more than just a POC


forgot to mention — under “enough control” I mean there is a way to use CRDT to manage state changes on backend side, I’m working on that in my fork


That talk is gold.


The microservices part is interesting-funny, how Rails did it back in ~2008 and saw how bad it goes and removed it ( and then the whole industry jumped on them.


I went to bed after writing this, and I was really surprised to see all of these different projects. This is very interesting! Thanks :)


So it looks like we are stuck with the DOM -- browsers love the dom, i don't know of any alternatives. Then, we need a dynamic way to intercept user events, modify the css of the dom, and connect with a server.... I am surprised there is not something cleaner than JS to serve this purpose yet. But again, we have the DOM... if there were a more generalistic way to make applications that could be mobile/desktop/tablet that would be great, but i suppose a lot of mobile manufacturers (android, apple) would probably not want unrestricted access to interception of events... a new standard would be hard to get adopted, but i wonder if there is a better way.