Live data from Hacker News

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

typeofnan.dev

351–360 of 444 posts

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

#351

Instead of vDOM, solid.js uses - real DOM elements + cloneNode(). And that's doubtful decision. Each live DOM element is about 100-200 bytes in memory. While in React (PReact, Mithril) this JSX expression: a is this: ["div",{},["a"]] 5 or so times less. In other words: needs to be tested on large DOM structures.

That's just a component template though. When you produce large DOM trees, you usually do so by rendering your components a lot of times, not by having a lot of different components

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

#353

Earlier quoted context omitted.

This is about "feels like" and me too--the little newsletter popup and lack of substance shows this. React became obsolete over the past few years as browsers increasingly adopted the mix of web components features (eg componentDidMount vs connectedCallback). Just using React, and the explanations for why a technology is and isn't used in an organization speaks to the level of practical knowledge and detritus in proj…

That is a big call regarding web components. I did some looking into web components for a recent project and React is just way ahead in many areas. You could use a framework like Lit to help smooth things over, but that just speaks to the underlying standard being somewhat cumbersome to use. I totally want web components to succeed and be the new way of doing things, but I get the feeling that is still a while away.

I think calling web components "cumbersome" belies the intention of the APIs, which is to enable custom HTML elements, encapsulation, and interop - fairly low-level concerns.

Lit takes care of templating and reactivity. Web components don't have those, it's expected that you use other methods, including what you already use, to create DOM and react to state changes.

The DOM may eventually add templating and reactivity, but that's a pretty big question given how many approaches and syntaxes there are. Until then libraries are fine and allow for multiple opinions.

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

#354

This article hits on something I've felt for a long time. The idea that "hooks are superior" to me is ridiculous. If a linter is required to tell me when I'm writing a bug that is not immediately obvious, that is a failing in the framework to round those edges. Lints are not rounded edges! Solid is nice and _seems_ to fix the issues with hooks, but as another comment mentioned, the challenge is with building at scale…

I don't think complaining about needing a linter makes sense. JSX is already a compiled language, so you have a compile and build step (doubly so if you're also using Typescript). Think of ESLint rules-of-hooks as just a plugin to your compiler that further modifies the syntax of JavaScript to include rules about when and how you can call certain functions.

Hooks are a syntactic element of react code. Calls to them aren't legal inside conditionals or loops.

Full linting support smooths over that rough edge just as effectively as babel handling ?. syntax smooths over its absence in certain JS runtimes.

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

#355

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. Once you deal with larger amounts of data and need virtualised rather than fully-materialised lists, you start using different things in React as well. The fact of…

> virtualised rather than fully-materialised lists

I want to push back somewhat on this practice. Our computers are fast enough now, and the browser implementations optimized enough, that they should be able to handle thousands of materialized list items without breaking a sweat. Sometimes you really need virtualization, e.g. if the underlying data source has millions of records. But if the data can be fully materialized, then the implementation is simpler, and the user can take advantage of things like find in page. Virtualization is a convenient way to avoid the inefficiency of unoptimized VDOM-based rendering (e.g. with React, and yes, I know there are other optimizations available in React), but fine-grained updating (as in Solid) is even better.

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

#356

Earlier quoted context omitted.

Slightly dismissive, but I agree the setInterval function was a little misleadingly contrived. The transition to functional components was to reduce the coupling between abstract functionality and DOM-related lifecycle events. React hooks are mostly about expressing where and when you want to memoize a value, with the default being not to. Once you learn what to look out for, and properly designing and review codebas…

What are you talking about? The setInterval example is completely idiomatic React hooks. It is literally given in the React docs: https://reactjs.org/docs/hooks-faq.html#what-can-i-do-if-my-...

Reading it now, the language I used was inappropriate. You're correct, the stated problem is common with registering and triggering self-repeating and timed loops.

That was really my point, don't do that.

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

#357
post #227

Earlier quoted context omitted.

> Because you sometimes want to filter, sort or project your data. The idea that this type of thing should be happening anywhere near the view rendering loop is the exact reason I've not had a great time picking up React codebases. By the time you're rendering data into markup, the data should be in the exact state you need it. No further filtering or data mangling or sorting. That type of data manipulation should ha…

I love vue’s concept of computeds. It makes me think back to knockoutjs when things felt like they “just worked” as long as you knew where the ES5 footguns were. It’s nice to have a concept “ground truth” in data and props and then computeds that sort of tie it all together.

Yes, and those are available as well with MobX (in React), Svelte, etc.

You can do same/similar with React hooks, just not as clean or obvious.

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

#358

How is the setInterval cleared when Counter is no longer rendered? It seems like a leak.

It's certainly a leak. That setInterval is going to be holding the closure context alive which will reference the component in many frameworks. The setInterval will also keep firing causing, wasting CPU and battery. It's hard to take any examples here seriously without showing proper cleanup that would pass code review.

Good to see other people spotted that, I noticed it immediately and had a "there's a bug! a bug!" alarm bell ringing in my head throughout the rest of the article. I may have some sort of setInterval related PTSD.

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

#359

The author lost me in the introduction. > "Ohhh, an OO pattern with a couple of one-liner lifecycle methods is just WAY too much code! Higher likelihood for errors and worse developer experience." ... > "So instead, I'm going to replace this with a functional pattern, that crams a couple of lifecycle functions into a closure, and is riddled with edge cases and common developer mistakes." This article perfectly crysta…

I've been in the industry since the days of VB6 (which I loved). I've never been more productive than I was with VB6 and WinForms. That said, UI has always been a mess, even then. The more feature-rich you want your UI, the gnarlier and messier it gets. Everyone always likes to blame the front-end engineers for being slovenly, but my experience is that; UI is just messy. It's just hard to program cleanly. Not to ment…

Back when I studying CS and as Junior, I would laugh at memes about "Frontend vs Backend" where they described the Frontend as this pretty pasture and the Backend as this god forsaken place of spaghetti code.

In a way I find this meme even funnier now because of how backwards it is. Often times it's the backend that's really clean and organized and the frontend is a hot mess.

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

#360
post #125

This article hits on something I've felt for a long time. The idea that "hooks are superior" to me is ridiculous. If a linter is required to tell me when I'm writing a bug that is not immediately obvious, that is a failing in the framework to round those edges. Lints are not rounded edges! Solid is nice and _seems_ to fix the issues with hooks, but as another comment mentioned, the challenge is with building at scale…

Hooks triggered my code smell detector so bad that I didn't even bother finishing the tutorial. That said, I still preferred React.createClass so I guess I'm somewhat off the beaten path when it comes to React.

Read the implementation of Hooks (in the React codebase) if you want a big LOL. They're a slower, partial re-implementation of objects with bizarre custom syntax. In a language that's already so heavily OO that the functions are objects.
Post reply on HN