Live data from Hacker News

Svelte 3: Rethinking Reactivity

svelte.dev

41–50 of 186 posts

Re: Svelte 3: Rethinking Reactivity

#41
post #39

One area where the virtual DOM seems to be important is for rich text editors, where the VDOM can basically take the input, diff it using an immutable structure, then render it to properly structured HTML. An example use case where this would be valuable: a user hightlights text, bolds it, then highlights it again plus some more text, and bolds it. A naive approach would have: This text is bolded plus I bolded this w…

Rich text editing is possibly a special case, though the right person to ask about that would be Jacob Wright (https://github.com/jacwright). He's the creator of https://www.dabblewriter.com (which uses Svelte) and a Svelte contributor, so he probably knows more about this topic than just about anyone else!

Re: Svelte 3: Rethinking Reactivity

#42
Nice handling of reactivity - I think this should already be in language as well.

I'm not sure I like this single components approach and embedding JS in HTML.

The problem with this is that it's too frameworkish.

The big benefit of JSX/React rendering is that it's composable and declarative (as it's just functions), but it's also simple to get - render just returns wanted structure, given the state and you can use simple assert to verify that.

Solutions like angular/vue/svelte rely on custom template parsing which IMO sucks, because it's hard to extend/test without specific template compilers. JSX in contrast is embracing language.

I think that render functions written like in react and data reactivity is the simplest approach to describe application. Seems like VueJS with JSX is closest to this right now.

It would be cool to keep similar API but maybe use compiling to have smaller bundle/older browsers support/different platform support etc.

To be clear by similar API I mean just pure JSX components, where you plugin reactive data, that could be tested without any frameworks and without rendering. This is the simplest way, yet nobody build it yet - MobX + pure React components is close to this (problem is that still rendering is done by React, so rendering isn't most performant - depends on components hierarchy) - with compilation/integration you could make it more performant, but I would keep declararive nature and simplicity of JSX.

Re: Svelte 3: Rethinking Reactivity

#43
post #39

One area where the virtual DOM seems to be important is for rich text editors, where the VDOM can basically take the input, diff it using an immutable structure, then render it to properly structured HTML. An example use case where this would be valuable: a user hightlights text, bolds it, then highlights it again plus some more text, and bolds it. A naive approach would have: This text is bolded plus I bolded this w…

Rich text editing is possibly a special case, though the right person to ask about that would be Jacob Wright ( https://github.com/jacwright ). He's the creator of https://www.dabblewriter.com (which uses Svelte) and a Svelte contributor, so he probably knows more about this topic than just about anyone else!

Thanks for sharing! Looks like Jacob has open-sourced a svelte-based rich text editor based on Quill. Link below for anyone who is curious.

https://github.com/typewriter-editor/typewriter

Re: Svelte 3: Rethinking Reactivity

#44
post #5

I'm really impressed that the release announcement starts by explaining what Svelte is. It's a little thing, but it's appreciated.

Agreed. I really appreciated him not assuming I know -fucking everything- and his WHAT included the WHY. ‘WHY’ (intent) is far more important an is missing from many different technical industries.

Tell me how you intend it to be used and I’ll see if that matches what I think I want (miss-wanting a different topic!).

Re: Svelte 3: Rethinking Reactivity

#45

From the tutorial: > Svelte is giving us a warning: > A11y: element should have an alt attribute > When building web apps, it's important to make sure that they're accessible to the broadest possible userbase, including people with (for example) impaired vision or motion, or people without powerful hardware or good internet connections. Accessibility (shortened to a11y) isn't always easy to get right, but Svelte will…

For what it's worth, Create React App is bundled with eslint-plugin-jsx-a11y which will give you the same warning

Re: Svelte 3: Rethinking Reactivity

#46

Nice handling of reactivity - I think this should already be in language as well. I'm not sure I like this single components approach and embedding JS in HTML. The problem with this is that it's too frameworkish. The big benefit of JSX/React rendering is that it's composable and declarative (as it's just functions), but it's also simple to get - render just returns wanted structure, given the state and you can use si…

> it's hard to extend

This is actually a feature, considering what Svelte does. I know of more than a few efforts to implement similar compile-time production of low level procedural code from React components, but so far nobody's been quite able to do it. And this is despite these efforts coming from some very smart people. The reason this is so hard to do for React is precisely because Javascript is a huge target with a ton of bizarre quirks and edge cases.

> To be clear by similar API I mean just pure JSX components, where you plugin reactive data,

I think Solid.js is the closest thing to this atm. Not React-based though.

Post reply on HN