News for hackers. Stuff that matters.
Re:Solid.js feels like what I always wanted React to be by tambourine_man on Tuesday March 01, 2022 @07:12AM (#30513171)
>…much like traditional templating languages, we get a construct like <For> that reinvents a concept that's already in the language.

I'm right there with you, but when React invents a whole markup language inside of JavaScript, it's not in much of a standing to make purity criticisms.

Re:Solid.js feels like what I always wanted React to be by BigJono on Tuesday March 01, 2022 @08:16AM (#30513704)
Well you've obviously completely missed the point of JSX then. The "whole markup language" that they invented is literally a line for line transform. Optimisation aside, there's no reason why line 58 of a file with JSX in it won't be line 58 of the transpiled JS file, and read exactly the same. All JSX is is a custom function call syntax.

It's about as pure as you can get while having any sort of html-ish 'templating' whatsoever.

So, I'd say it's exactly in the right place to be making purity criticisms. They've taken the only approach that preserves the integrity of the code and doesn't involve build time magic.

Re:Solid.js feels like what I always wanted React to be by ______-_-______ on Tuesday March 01, 2022 @08:46AM (#30514002)
Solid's <For> doesn't rely on any build-time magic, other than the JSX custom function call syntax that is also present in React. If you want, you can even call it like an ordinary function:

    function MyComponent() {
        return For({
            each: [1,2,3,4],
            children: x => <div>{x}</div>,
        })
    )
It's just a function call, and it doesn't even need `React.createElement`. What's more pure than that?
Re:Solid.js feels like what I always wanted React to be by scotty79 on Tuesday March 01, 2022 @04:56PM (#30520596)
Normal for statement is more pure than that.
Re:Solid.js feels like what I always wanted React to be by recursive on Tuesday March 01, 2022 @08:31PM (#30522530)
Functional purity? `for` can only have side effects. It has no functional purity. It doesn't even have a value.
Re:Solid.js feels like what I always wanted React to be by scotty79 on Thursday March 03, 2022 @04:00PM (#30546931)
Imperative purity.
Re:Solid.js feels like what I always wanted React to be by tambourine_man on Tuesday March 01, 2022 @08:35AM (#30513884)
Oh I missed the point on React altogether. After 10 years, I still fail to see why anyone would use it voluntarily.

But coming back to JSX, a custom function call syntax is OK and pure because it has a one to one mapping on line number?

I don't know if there's much point in discussing purity since it's badly defined and mostly in the eyes of the beholder, but it always smelled like one hacky syntactic sugar to me.

Re:Solid.js feels like what I always wanted React to be by masklinn on Tuesday March 01, 2022 @08:09AM (#30513635)
That is an utterly bizarre rejoinder. JSX has always been (and afaik still is) optional and extremely thin syntactic sugar. It’s little more than a convenience macro (so that views can look a little more like the markup equivalent).

It has no intrinsic semantics, and maps pretty much directly to actual javascript (which you can write directly or use an alternative helper for — hyperscript being a common one).