Fork me on GitHub
#clojurescript
<
2022-01-13
>
Franklin12:01:03

there's a really nice clojurescript book, I read a while back hosted on a http://github.io subdomain but haven't been able to find it for a while because I don't remember its name. does anyone here know which book I might be talking about?

dsp14:01:35

thanks, I didn't know about this either! been digging my teeth in, I'm sure it'll help.

leifericf15:01:30

Hello, friends! As you might know, https://calva.io is the VS Code extension for Clojure/ClojureScript development. And it ships with an interactive tutorials on Clojure, which helps drive exposure and adoption of the language, seeing how popular VS Code has become. It lowers the barrier to entry significantly for a lot of people. Currently, 64% of Calva is written in TypeScript. There are some significant advantages to having more of this code (and future code) written in ClojureScript, instead of TypeScript. To that end, @brandon.ringe and @pez have made some valiant efforts, and stumbled upon some difficult problems. https://github.com/BetterThanTomorrow/calva/discussions/1455 summarizes the efforts made so far, and the specific problems discovered along the way. If you have some time to spare, we would greatly appreciate some extra eyeballs on these problems, so that we can improve Calva and make the Clojure/ClojureScript development experience in VS Code even better. Please leave your input in the GitHub discussion.

calva 3
❤️ 1
🙌 1
dsp15:01:38

probably a dumb question, but I guess cljs devs are more or less expected to know javascript? or at least some rudimentary knowledge of the runtime platform? I have experience with plain clojure, had hoped to carry most of my knowledge over (and, indeed, have), but I suspect due to differences between the runtimes there's a whole bunch of missing stuff that i'm looking for that probably will require a build-it-yourself approach, at which point js is probably needed? maybe I am just not looking in the right places, or am lacking some knowledge. an example is: I am trying to build a cljsrn web radio player. my understanding is that html audio tags, while they work out of the box for playing streams, will likely keep the entire stream in memory(?), so are unsuitable for things like infinite streams. so another plan is to fetch the upstream data, and have it be chunked into arrays, to be fed into some web audio api stuff, so that i can discard listened-to data and not have memory usage balloon. I seem to fall at the first hurdle though. none of the cljs http clients i've looked at return anything like aleph's streams; instead i came across https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API and https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Using_readable_streams and some light wrappers on top of it, but working with this stuff definitely i'd say qualifies as runtime/js knowledge and is akin to java lib interop i suppose (something i rarely have to do for things myself, due to the already-existing rich ecosystem) is it just a fact that cljs is still very much greenfield for a lot of stuff? cos the web apis are new? just so i adjust my expectations. probably did not pick an easy first project.

rmschindler17:03:51

Methinks that ClojureScript requires knowing only the minimal JavaScript necessary to be comfortable using JavaScript APIs. And of course, yes, as you say, the "rudimentary knowledge" of the runtime platform.

dnolen15:01:59

I would say ClojureScript isn't any different from Clojure for non-trivial projects - you're probably going to have to integrate some platform stuff - there won't be libraries for everything (and there probably should not be, wrapping trivial stuff is non-productive), if you're going to use it in anger for years on a project probably getting familiar with JVM tooling is a very good idea

dnolen15:01:29

All this stuff applies to ClojureScript - whatever JS target you're looking at - you need to know something about it, or be comfortable with learning something about it

dsp15:01:43

yep, fair. I guess I was "blessed" that I already knew something about the JVM before touching Clojure, whereas I have completely avoided javascript my entire life. cljs just probably sets a faster on-ramp... it took me a year until i was wrangling with endianness, bytebuffers, network sockets (netty) and idiosyncrasies of the JVM (oh how I cursed... https://clojuredocs.org/clojure.core/int-array -- nowhere is it clear that arrays have a maximum size, and that overflows can happen, so i got negative sized arrays rarely, and underruns most of the time, which made it especially insidious to debug. coming from CL, where you can just go ahead and make a 20GB in-memory array without hassle). whereas this is my first real cljs project, and i am already looking to construct a http client for something that is just "for free" on the other runtime & with nice libraries. will end up knowing the entire ecosystem to get to the end goal, when all i really wanted was a nice end-user UI. at least it's interesting! (or else i wouldn't do it. this is a free-time side project after all.) -- so I am not complaining. just curious how deep I have to expect to go, so I don't underestimate. thanks for the input

rgm18:01:44

This is so interesting to me since I was the opposite: had a lot of JS knowledge acquired in anger, but zero Java when I came to clj/cljs. Five years in, I'm finding both CLJ and CLJS a comfortable home base to keep coming back to as I inevitably end up having to figure out a lot more about the underpinnings when things break. If nothing else, I love them for paving over the host language syntaxes, leaving me free to pay closer attention to the actual semantic differences.

👍 1
tabidots15:01:14

Having trouble with goog.dom.classListadd and remove work fine, but addAll and removeAll do not. I have tried using [some-string other-string] and (js-obj [some-string other-string]) as arguments and neither have worked. Am I missing something? EDIT: Got it working with (clj->js [some-string other-string]) but I feel like this shouldn’t be necessary. What is the proper way to do this?

p-himik15:01:36

#js [...].

1
Ngoc Khuat16:01:51

I have jetty server and a front-end using clojurescript. Now I want to start my jetty server to server both the APIs and my clojure-script project. Could anybody guide me how to do it?

p-himik16:01:50

Your UI is likely to be just a single HTML file and a single JS file, maybe with some CSS files. In the simplest case, you just put all those files in a single directory without anything else and serve that directory via some static route in Jetty.

👍 1
souenzzo16:01:11

I have a https://github.com/souenzzo/atemoia that does it At dev-time, it means when you are running in the REPL, you need add the dir where you output your cljs in your HTTP server The http serving files at target/classes/public: https://github.com/souenzzo/atemoia/blob/master/src/atemoia/server.clj#L102 The cljs builder generating files at target/classes/public : https://github.com/souenzzo/atemoia/blob/master/shadow-cljs.edn#L3 The extra /atemoia path will be added to your script tag: https://github.com/souenzzo/atemoia/blob/master/src/atemoia/server.clj#L47 main.js exists because it is the :main module of shadow-cljs: https://github.com/souenzzo/atemoia/blob/master/shadow-cljs.edn#L5 For "prod", it means when running in a jar, it will access directly from https://github.com/souenzzo/atemoia/blob/master/src/atemoia/server.clj#L103

1
Ngoc Khuat16:01:40

@U2J4FRT2T that looks great, lemme try it out

Ngoc Khuat16:01:11

I don’t see any html in there. does it get generated by shadow-cljs?