Live data from Hacker News

Solid.js feels like what I always wanted React to be

typeofnan.dev

391–400 of 444 posts

Re: Solid.js feels like what I always wanted React to be

#391

Earlier quoted context omitted.

>In React, we render lists by using regular JavaScript idioms like loops, arrays, and array methods like map. However in Solid.js, much like traditional templating languages, we get a construct like that reinvents a concept that's already in the language. I find this a totally bizarre complaint. I've spent the past few months working on Svelte stuff and I've seen people on HN make this same complaint about Svelte's t…

A react feature that I appreciate is that it is "just javascript". It's easier to learn how to loop or have conditionals in React because it uses native JS features. It makes it easier to understand, for me. Having templating DSLs in other frameworks isn't a deal breaker, but it's a pro of React that I appreciate.

But I mean, it's not really. A hook invocation looks exactly like a javascript function invocation. Except it's subject to hook rules. Those don't come from javascript. Those are language rules that come from react. And even worse, the syntax for invoking a hook is exactly the same as the syntax for calling a function.

Re: Solid.js feels like what I always wanted React to be

#392

Earlier quoted context omitted.

This seems like a huge step back from declarative UIs, any reason why you would say it’s preferable?

Performance, for one. This method can easily avoid allocating an object for every div (since it turns into a method call, not something that needs to return an object), compared to React's render() method. Another scenario outlined in the article of rendering a row of buttons, each with it's own click handler, that needs to allocate a lambda for each button every render. Alternatively, using map() and filter() also a…

I suspect that the nature of the DOM means that being able to do that in the first place would actually require a virtual DOM w/diffing assuming you're targeting browsers.

However that's probably obvious, so: Assuming you're considering greenfield / blue sky thinking here, it's worth noting that v8 has had so much money and engineering hours sunk into it that the react-ish pseudocode probably doesn't make nearly as many allocations as a naive reading of the code might expect.

(a good friend of mine was very surprised to discover that v8's JIT is good enough that naive javascript code was basically competitive with FFI-ing out to C++ just because the node FFI layer introduced sufficient overhead that the JIT managed to catch up ... I am not a compiler wonk so please don't take this as a remotely expert pronouncement but "it is, in fact, quite difficult to overestimate v8 these days" seems to be a solid heuristic)

Re: Solid.js feels like what I always wanted React to be

#393

Wait what's the problem here? Because you didn't like adding [count] as a dependency to setEffect(()=>{},[...count goes here...]) you wrote an entirely new framework?

It's not just that one case. Everything in react is like this. I find react code hard to reason about because this type of friction exists almost everywhere. Solid is what I always wished react was, but had a hard time articulating.

Re: Solid.js feels like what I always wanted React to be

#394
post #68

What feels like complete insanity when it comes to React is that it needs compilation to work: render() { return The count is: {this.state.count} ; } This is not Javascript and it will need to be compiled into Javascript before it gets executed. But you can do the same in Javascript: render() { return ` The count is: ${this.state.count} `; } Using regular Javascript makes my life a thousand times easier than having t…

You might find this interesting: https://github.com/developit/htm#readme

Re: Solid.js feels like what I always wanted React to be

#395

Earlier quoted context omitted.

> All these frameworks are component-based, can have top down state only (or do bottom up in react), can use things like jsx/hooks because it's just syntactic sugar (vue has jsx support). Honestly, the boon of React is just how easy it is to create components, or at least how simple things were back in the day - it is exceedingly composable , moreso than AngularJS, Angular or Vue have been, at least in my experience.…

Zustand has solved the complexity of state management for me, although getting {employer} to adopt it is of course a different problem altogether. It's really bizarre to me how poorly useContext works, in contrast to how good everything else in React is for the most part. Having a good, "official" global state management solution that requires little boilerplate would be a huge benefit.

Wait till you realize Zustand does not work on React 18's Concurrent Mode and istead must use Jotai (same author) ?

Re: Solid.js feels like what I always wanted React to be

#396

Earlier quoted context omitted.

I have the same complaint about hooks. Most people seem to ignore that tidbit, but to me it's really frustrating. Plus I recently hit more hook issues when putting a setInterval inside a useEffect. There's no way to do a normal didMount/willUnmount workflow without other hacks (i.e. useRef) just to set up a simple timer. Maddening! Edit: after writing this I went and read the article. Same scenario I was bitching abo…

People always use the setInterval() issue as a footgun. The real footgun is people not reading the documentation for the framework they use, because the exact example is handled in the official react docs [0]. I always advice aspiring react devs to understand why this exact setInterval() doesn't work (and why there is the need for the rule-of-hooks), because it will automatically create an understanding how hooks and…

Also in most of these cases, the "natural" way people would prefer to write code for an interval would likely have very unclear semantics, particularly if the interval delay is coming from somewhere else such that its value can change (like component state or props).

Re: Solid.js feels like what I always wanted React to be

#397

New JS frameworks always make for compelling hello world examples. Can you branch on state or use loops over data in Solid.js? The reason _why_ React has a virtual DOM is to enable more interesting relationships between your data and your presentation. Anyone can make a framework that makes the source code for an incrementing number look pretty! As an example of this point, check out the "Simple Todos" example for So…

>In React, we render lists by using regular JavaScript idioms like loops, arrays, and array methods like map. However in Solid.js, much like traditional templating languages, we get a construct like that reinvents a concept that's already in the language. I find this a totally bizarre complaint. I've spent the past few months working on Svelte stuff and I've seen people on HN make this same complaint about Svelte's t…

> What is so wrong, exactly, with "reinventing a concept that's already in the language"?

Nothing, inherently. Just like there's nothing inherently wrong with having extremely clear and simple rules for how to use hooks, and lint rules to identify when you're not following those rules. Nothing inherently wrong with either, some people just have strong distaste for one or the other.

Re: Solid.js feels like what I always wanted React to be

#398
post #4
post #2

This is interesting because it's a bit like Svelte, but it doesn't use the Svelte "language" (which looks like JS and HTML but, in some crucial ways, sometimes isn't ). It's a little disheartening to see that it's 3+ years old and has only had a single significant contributor though[1]. It's impossible to avoid single-contributor projects in the JS world, especially with Node, but the alternatives (React, Vue, Angula…

I have no idea if it's in the creator's interest but I'd love to see Solid get backed by a company the way React, Angular, and Svelte are. That might make people take it more seriously as an option but, as-is, it certainly feels like a risky option to use professionally.

Solid is sponsored by Vercel, Cloudflare and Netify

Re: Solid.js feels like what I always wanted React to be

#399

Honestly my hope (and I admit as a full-stack but leaning back-end developer to be biased against JS) is that the future is in things like turbo-stream, stimulus reflex, phoenix liveview etc - or in things like all_futures (essentially an ActiveRecord wrapper around kredis) - that we move towards building reactive-apps by firing off events from the back-end and figuring out how to subscribe to them on the front-end t…

What about apps that have no backend? What about apps that should work both online and offline?

I'm not saying there are no use cases for a JS framework, and I have a few I like, just that the switch to rails api only/separate react app has in almost every case I've seen added tons of complexity without a clear win

Re: Solid.js feels like what I always wanted React to be

#400

Earlier quoted context omitted.

I know, I've read it. I'm still not convinced. React could just as well generate and insert missing key on build instead of asking me to do this: ... you can add a new ID property to your model or hash some parts of the content to generate a key. It is just plain wrong to ask me to change my data model because of this. This is part of the housekeeping that I expect the framework -- pardon, library -- to take care of…

It can't. Not in a consistent manner. When diffing user provided immutable data you need a user provided key. Otherwise it can't tell the difference between a new list entry and a nested update. You could treat every nested update as a new item but that is incredibly wasteful as it throws away all descendants. This is something all non-fine-grained rendering libraries have to deal with be it React, Vue, Svelte, or Li…

How does Solid avoid the need for user-provided keys? I thought it also had to diff the underlying array. Does it check object identity?
Post reply on HN