Fork me on GitHub
#clojurescript
<
2023-11-11
>
kokonut18:11:02

Hi, coming from backend, I only have several months of frontend experience and that was in Clojure and Re-frame. But I have felt like I am not really understanding what's going on on the platform level (browser, raw JS functions). For instance, I know how Re-frame works but don't know what Reagent is exactly doing on top of React. I am realizing I am missing fundamentals. So I was playing around with JS functions on the cljs Repl and was asking myself what if I try to build something only using JS libraries like React or Solid on CLJS only using Hiccup (so no reagent or re-frame). Do you think it'd be possible? If so, do you agree that it'd give me more fundamental understanding of JS and CLJS.

p-himik19:11:34

I'd strongly suggest leaving CLJS out of the question and focusing on JS for a bit. Let alone adding Hiccup into the mix without, I assume, any third-party libraries.

👍 2
thheller19:11:06

well you could write a really basic hiccup -> react translator in very few lines of code

thheller19:11:27

but still requires learning basic react first 😛

👍 1
kokonut19:11:12

Yes, and that sounds reasonably necessary, because reagent and Re-frame are based on react.

kokonut20:11:19

If basic hiccup -> react is possible, would basic hiccup -> solid also be possible?

phill20:11:25

The question is not very well-defined. If you want fundamentals, try JavaScript with no wrappers. If you want some exposure to the "laws of physics" without going completely feral, then just implement a feature like streaming input from a text file or streaming output to a text file, without using any libraries.

thheller20:11:35

last time I checked part of solid was compiler based, as in the compiler doing code transformations. that will not really work as it won't recognize the CLJS output properly to do its thing. so I don't think its possible at all, but I haven't spent much time researching so thats basically just a guess.

thheller20:11:10

react does require any compiler support, so thats why its so common in CLJS. things like svelte or solid just don't convert as easily

thheller20:11:27

that doesn't mean its impossible, just not as trivial 😛

kokonut20:11:42

@U0HG4EHMH agreed. I have learned the basics of React and Solid on JS, so I have some understanding of how it works. But what I do on reframe and cljs just feels too different from them. I know it's another layer but still the targeting platform is the same, so I should be able to project what my cljs codes will be translated and manipulate the browser. Yea, this is a vague goal or I just don't know what reagent does.

kokonut20:11:56

@U05224H0W that makes sense.

thheller20:11:12

reagent basically transforms hiccup into react.createElement calls, basically same thing JSX does, plus some extra plumbing to make atoms work. not much else

👍 2
phill12:11:42

It might put your mind at ease to peruse Reagent's program code (clone it or just cruise around it on github).

kokonut19:11:52

Yep, that works!