The :hoplon: ClojureScript Web Framework - http://hoplon.io/
George Ciobanu 2019-05-29T00:25:57.017100Z

hi I have a silly question: is Hoplon alive and well? I really like the philosophy behind it but I noticed that commits are quite infrequent for it and that commits for Castra stopped almost 2 years ago. I'm not assuming that a project needs to be constantly added to / improved, I'm totally ok with the idea that sometimes a product is just done and we can stop adding bells and whistles. I just want to make sure that I'm investing in a framework whose parents are still caring for it 🙂

George Ciobanu 2019-05-29T00:31:38.017500Z

@danieleneal would you mind sharing the reddit post?

George Ciobanu 2019-05-29T01:52:14.018400Z

thank you!


@geo.ciobanu it’s definitely alive, i think it could benefit from more users… but there are users, and @flyboarder actively maintains


among frameworks i think hoplon is distinctive, as we have removed from it over time, and it has no underlying deps such as react

George Ciobanu 2019-05-29T03:32:11.020600Z

@alandipert ty!

George Ciobanu 2019-05-29T03:32:59.021200Z

removing from something is rare 🙂

flyboarder 2019-05-29T03:38:15.021800Z

I also intend to remove some more overhead that I didnt fully develop, 7.3 has been a long time coming

flyboarder 2019-05-29T03:38:23.022Z

it’s almost ready

flyboarder 2019-05-29T03:39:02.022800Z

gotta fix the reload appending issue, which seems to be a recurring problem when we work on the element init

George Ciobanu 2019-05-29T03:48:10.027400Z

I have what I know is a simple question to you but quite a mystery to me. I understand how to use cell and cell= but I'm baffled by how it actually works (and not smart enough to figure out from the source code) When I have a (cell (clicks 0)) and I do 1. (def clicks-even? (cell= (even? clicks))) this works as expected. But when I do 2. (even? clicks) I get an error. In Clojure evaluating form 1 would evaluate (even? clicks) first and then everything else. However form 2 tells me that even? expects an integer. The source code uses a macro for cell= so there is some magic at play. Is there a simple way to explain what the macro does? If not possible don't worry I'll come back to this question once I learn more

George Ciobanu 2019-05-29T03:50:44.028100Z

Either way I'm bought into the model an committed to using Hoplon. Quite surprised more people don't use it, it's super intuitive and elegant

danielneal 2019-05-29T06:29:45.029700Z

Working on a react native app for an organic farm, in cljs :) also just moved to Lithuania and going to be working remotely so it's a strange but exciting time

dave 2019-05-29T13:36:06.030400Z

i also find that surprising! it's so easy to keep in your head, compared to the whole react ecosystem

dave 2019-05-29T13:40:53.035300Z

@geo.ciobanu re: cell=, it is a macro, and it does some code-walking to try and figure out which values are cells. when it encounters a cell, it treats it as an input parameter, such that any time the value of one of the cells within that form changes, the formula cell's value recomputes within the context of your example, clicks is a cell, and when you make a formula cell like (cell= (even? clicks)), the formula cell's value updates each time the clicks cell's value updates, and cell= lets you express the new formula cell value in a more concise way, where the cell values are sort of "unpacked" i think it takes a while to fully wrap your head around that idea. it took me a while, anyway. but it does become second nature after a while

dave 2019-05-29T13:41:25.035900Z

(even? clicks) by itself produces an error because clicks isn't a number, it's a cell

dave 2019-05-29T13:41:59.036600Z

you can do (even? @clicks) to get at the value of clicks, but in practice you will almost never dereference a cell directly like that

dave 2019-05-29T13:42:32.037500Z

in my experience, any time i find myself putting an @ symbol in front of a cell, i've found that i'm doing something wrong

Ahmed Hassan 2019-06-01T10:49:06.018400Z

Aren't there some places where @ in front of cell is necessary?

Ahmed Hassan 2019-06-01T10:49:31.018600Z

Like when passing attribute value from parent to child, you have to deref it.

dave 2019-06-01T12:17:24.018800Z

there are exceptions, for sure

dave 2019-06-01T12:17:42.019Z

one example is when you're implementing a :click handler

Ahmed Hassan 2019-06-01T12:18:50.019200Z

I use (defn event-target-node-val [evt] (-> evt .-target .-value)) for :click handler to get value of event.

dave 2019-06-01T12:20:17.019500Z

a click handler is a function that gets run at the point in time when you click, and it's separate from the hoplon workflow of input and formula cells, so if your click handler needs to use the values of cells, you have to deref those cells

micha 2019-05-29T13:42:52.038100Z

there is one benefit to cell= in my opinion, from an abstraction point of view

micha 2019-05-29T13:43:53.039300Z


(defn foo [x]
  (cell= (+ y x)))
^^ here x can be a cell or a regular value, either one will work

micha 2019-05-29T13:44:19.040Z

this is key in my opinion, or you end up needing to box everything

dave 2019-05-29T13:44:28.040200Z

+1. i've used that trick quite a bit

dave 2019-05-29T13:44:57.040700Z

if you do it right, you basically end up in a world where you don't have to think about whether things are cells or unboxed values

micha 2019-05-29T13:45:09.040900Z


micha 2019-05-29T13:45:23.041200Z

the formula-of is also key, of course

micha 2019-05-29T13:45:48.041700Z

in some places you're making glue or plumbing code, so you know which things are cells and which arent

micha 2019-05-29T13:46:06.042200Z

especially when you need an anonymous formula that no other code will ever have access to

micha 2019-05-29T13:46:15.042500Z

vs. say defining a function with arguments

dave 2019-05-29T13:48:08.044100Z

i like formula-of because i sometimes find the ~ cell indicator thingy used within cell= to be confusing, so formula-of gives me an escape hatch when i want to be more explicit about what the inputs are to my formula

micha 2019-05-29T13:48:26.044300Z

yeah totally

micha 2019-05-29T13:50:09.045300Z

lol i'm an idiot, all the cell constructors can handle cells or values, i don't know why i thought it was just cell=, sorry for the confusion

dave 2019-05-29T13:50:54.045700Z

oh, i didn't know that either! i assumed it was just cell= too

micha 2019-05-29T13:52:18.046600Z

formula and formula-of etc. also have that property

danielneal 2019-05-29T13:52:33.047100Z

has anyone done benchmarks of hoplon wrt react

micha 2019-05-29T13:53:25.047800Z

we have a pretty large, complex application with a ton of data and many screens and it's very snappy

micha 2019-05-29T13:54:22.048700Z

however there are limits to what you want to do in cells, naturally

danielneal 2019-05-29T13:54:24.048900Z

🙂 I was just more thinking with all the recent excitement around svelte, it would be funny if hoplon had been there the whole time, quietly outperforming react...

micha 2019-05-29T13:55:59.049900Z

if anything hoplon does fewer DOM updates on average, i would expect

micha 2019-05-29T13:56:21.050200Z

but that's because cells do more work

danielneal 2019-05-29T14:06:13.050400Z

yeah that would be my intuition

George Ciobanu 2019-05-29T15:18:35.051400Z

@dave and @micha thank you so much for your insightful replies, I’m deeply grateful

George Ciobanu 2019-05-29T15:18:58.052100Z

I haven’t used/seen formula-of but will look into it

George Ciobanu 2019-05-29T15:19:56.053600Z

But yes when I just need to things get done thinking about cell= as literally a calculated sheet cell makes it super easy

George Ciobanu 2019-05-29T15:20:51.055100Z

I initially tried to reason it as a subscriber to the cells and values it uses - but the spreadsheet model is much more universal and easy to reason about

George Ciobanu 2019-05-29T15:30:52.067100Z

One more question: we can do (p clicks) (Clicks is a cell defined as in the tutorial (clicks (cell 0)) ) So (p clicks) works but (p (+ 1 clicks)) does not, and we have to use a cell= instead. It's a bit intriguing to me that I can use the cell itself as a value in a p macro/function AND it gets updated properly but cannot process that value in any other way - I have to use cell= to do that. Just to be clear I love the system and I am using it easily, it's just my curious side that's intrigued. Essentially since these are macros (p and cell=) I am ok to assume they do lots of work behind the scenes and just use it as a black box, but I wanted to raise it as something that, if I understand, I'll gladly create a PR for the tutorial to clarify it for other potential newcomers with the same question.

George Ciobanu 2019-05-29T15:31:29.068Z

@dave I would definitely add the x+y example to the tutorial as well it's really eye opening

George Ciobanu 2019-05-29T15:32:10.068900Z

Glad to create a PR for it (with thoughtful explanations around it) sometime this week

dave 2019-05-29T15:36:14.070100Z

i think those would be great things to add to the tutorial

dave 2019-05-29T15:37:02.071700Z

having the hoplon.core elements (`p` et al) include an "implicit cell=" is an intriguing idea. i wonder if there would be any negative implications

dave 2019-05-29T15:37:43.072800Z

can cell= be nested? if not, that could cause problems

micha 2019-05-29T15:38:07.073Z

you don't usually want to nest them

micha 2019-05-29T15:38:21.073200Z

really you never do

micha 2019-05-29T15:41:25.075400Z

@geo.ciobanu when you do (p "foo") for example, it evaluates to a DOM element equivalent to the following javascript:


micha 2019-05-29T15:42:56.076800Z

however, when you do (p bar) where bar is a cell, the p function sees that its argument is a cell and wires that cell up to update the text node whenever the cell changes

micha 2019-05-29T15:43:34.077600Z

so in your case when you do (p (+ 1 bar)) you have an issue because the + function doesn't understand how to add 1 to a cell

micha 2019-05-29T15:44:11.078400Z

but (p (cell= (+ 1 bar))) works because in that case the p functions argument is just a cell

micha 2019-05-29T15:45:26.079200Z

strings and numbers are converted into text nodes by the element functions (eg. p, div, etc)

micha 2019-05-29T15:46:19.080200Z

you can also do (p :id "foo" "bar") to have <p id=foo>bar</p>

micha 2019-05-29T15:47:00.081Z

or (p :id (cell= (str a "-" b)) "bar") where the value of the id attribute is a cell

micha 2019-05-29T15:47:13.081300Z

then the attribute is updated reactively


oh wow, that does sound exciting

danielneal 2019-05-29T15:56:06.082Z

how are things with you, are you still at Adzerk?


very well, but no, i am in the process of completing some strange and exciting times. 2 years ago moved to california and started working at RStudio doing things related to R

danielneal 2019-05-29T15:59:53.082400Z

oo interesting 🙂

danielneal 2019-05-29T16:00:44.082600Z

does this mean clojure is taking a back seat?


yes and no. i don’t technically use it, but i feel it warped my mind enough that in a way, i kind of always do


but it’s also been refreshing to depart occasionally from the dogma

danielneal 2019-05-29T16:11:36.083200Z


danielneal 2019-05-29T16:12:15.083400Z

I can imagine it's quite liberating


have you dabbled in other things since being infected with clj?

George Ciobanu 2019-05-29T17:29:34.087Z

@micha that makes sense thank you so much! I'll make sure to update the documentation asap in case others wonder the same thing in the future

micha 2019-05-29T17:30:20.087200Z

👍 any time!

flyboarder 2019-05-29T17:39:10.087300Z

Yes we are probably more performant, but only since the recent 7.x releases