Live data from Hacker News

Show HN: A JavaScript UI library for imperative JSX

npmjs.com

41–50 of 55 posts

Re: Show HN: A JavaScript UI library for imperative JSX

#41
post #37

Earlier quoted context omitted.

Add me to this club of JSX hackers: https://crwi.uk/posts/hiccup/ I used this approach to make a syntax highlighted text editor in https://crwi.uk/experiments/text-editor/

These are awesome (both parent comments). Love seeing that I'm not alone in my JSX curiosity.

With our powers combined we can reinvent the tiny fun internet.

Re: Show HN: A JavaScript UI library for imperative JSX

#42

Earlier quoted context omitted.

Same, used jQuery for years and had a love/hate relationship with it. You're correct that React solved the imperative problems from before, but that's not the only factor to consider. You have to weigh the problems it solves against the problems that it causes.

Eh. For me, it was vastly worth it. Yes there are drawbacks to react. But I feel like the gains far far far outweigh them.

totally fair

Re: Show HN: A JavaScript UI library for imperative JSX

#45

I would never want to write it the same element in multiple places like this. That's one of the main points of templating in the first place: to write the code for a piece of output once, with all of the bindings that can affect it. What happens here if you update the JSX for an element in one place and forget to do so in the others?

It's true that the library doesn't stop you from shooting yourself in the foot by duplicating UI references. But you can limit the effect of this with a bit of design work. I'm currently iterating on a few ideas, but this lib is only a week old, so I'm still thinking my way through it.

Re: Show HN: A JavaScript UI library for imperative JSX

#46
post #43

Why not use template literals and a css like syntax for selecting and update? setContent(css`p[key=counter]{ content: 'The count is ${count}'}; }`);

Great question. So right now the library is using xpath expressions under the hood, which are more powerful than css selectors because they can query for content as well.

Re: Show HN: A JavaScript UI library for imperative JSX

#47
post #37

Earlier quoted context omitted.

Agreed! About 5 or 6 years ago I wrote a library to demonstrate to my teams that JSX a) was not magic b) not limited to React. After that was done I became a little obsessed with making the library the fastest JSX renderer - which I think is still true: https://github.com/i-like-robots/hyperons

Add me to this club of JSX hackers: https://crwi.uk/posts/hiccup/ I used this approach to make a syntax highlighted text editor in https://crwi.uk/experiments/text-editor/

Very cool - reminded me of https://github.com/creationix/dombuilder which I have... memories of. Shout out too to https://microjs.com/ for allowing me to relive some nostalgia.

Re: Show HN: A JavaScript UI library for imperative JSX

#48

Earlier quoted context omitted.

Sure! There are several, but let's take a trivial one - setTimeout. This is an example of something that is inherently imperative, and therefore requires some awkward logic to get it working correctly in React. Here's an article explaining how to do it: https://codedamn.com/news/reactjs/how-to-use-settimeout-in-r... In contrast, here's how you would do it in matry: let someValue = 0; setTimeout(() => { someValue++; s…

This is IMO a great example for React and declarative programming. > There's no special concept to understand By not understanding that you need to cleanup timers when your view unmounts, you've introduced a subtle bug that your coworker will discover in 6 months when users report that the counter sometimes increases twice as fast. I've worked on Angular-like apps before, and storing and cleaning up timers was always…

I appreciate the RxJS observables approach with similar built-in cleanup, but also ways to build higher-level tools and compose things together.

    interval(1000).pipe(…)…
Puts the timer up front and center. There's some confusion between "hot" and "cold" to deal and sharing with, but the pipelines eventually clean themselves up and the higher-level operators can be very nice to you if you let them.

Re: Show HN: A JavaScript UI library for imperative JSX

#49
post #37

Earlier quoted context omitted.

Add me to this club of JSX hackers: https://crwi.uk/posts/hiccup/ I used this approach to make a syntax highlighted text editor in https://crwi.uk/experiments/text-editor/

Very cool - reminded me of https://github.com/creationix/dombuilder which I have... memories of. Shout out too to https://microjs.com/ for allowing me to relive some nostalgia.

Everything becomes Lisp in the end.
Post reply on HN