Live data from Hacker News

Rich Harris joins Vercel to work on Svelte full time

twitter.com

541–550 of 571 posts

Re: Rich Harris joins Vercel to work on Svelte full time

#541
post #520

Earlier quoted context omitted.

> The thing I like most about react is that it’s just executing plain Javascript most of the time. Then explain what hooks do ;) Hooks are decidedly not Javascript (even if they look like Javascript), and are a much more weird construct than {#await promise}

No, they are JavaScript, it is array based programming wrapped in a reactive functional-declarative approach. Simply array of objects cascading with state. {#await promise} is more cryptic than any useHook function implementation.

> No, they are JavaScript, it is array based programming wrapped

Javascript has no support for array-based programming.

So, hooks are not Javascript: they look like regular function calls, but:

- they can only be declared and called before rendering

- they can't be called out of order

- they cannot be called conditionally

- they have to be called a specific name to be handled correctly by React runtime

- some (but not all of them) require dependency lists that determine how they are invoked

> {#await promise} is more cryptic than any useHook function implementation.

usEffect documentation is something like 20 pages long. The use of {#await promise} is immediately understandable from the code example, and its entire documentation fits on a page and a half

Re: Rich Harris joins Vercel to work on Svelte full time

#542

Earlier quoted context omitted.

> The point is this small extension to JS grammar lets you do templating with normal JS, instead of #for you can use .forEach, .map and other array methods. But then React is much more than just "small extension". Hooks alone are less of a Javascript than any Svelte template syntax.

We're not talking about React we're talking about JSX. Svelte has a lot more going on than it's template language as well. We're only comparing the templating system to JSX.

Let's compare to JSX then: https://news.ycombinator.com/item?id=29194287

Re: Rich Harris joins Vercel to work on Svelte full time

#543
post #178

Earlier quoted context omitted.

> Svelte doesn't support JSX/TSX though =( It actually supports the next best thing: HTML! Now in all seriousness, JSX does have its benefits like being able to write a small function that returns a piece of JSX. But in my experience, using Svelte is a huge productivity booster than I don't mind losing JSX's benefits.

Plus JSX is based on a "Virtual DOM", and "Virtual DOM is Pure Overhead": https://svelte.dev/blog/virtual-dom-is-pure-overhead >Virtual DOM is pure overhead >Let's retire the 'virtual DOM is fast' myth once and for all >Rich Harris, THU DEC 27 2018 >If you've used JavaScript frameworks in the last few years, you've probably heard the phrase 'the virtual DOM is fast', often said to mean that it's faster than the real…

> Plus JSX is based on a "Virtual DOM", and "Virtual DOM is Pure Overhead":

If you mean React + JSX then yeah, but JSX is just a DSL and doesn't imply using a virtual DOM.

For example, Solid js uses JSX and doesn't have a virtual DOM.

https://www.solidjs.com/

Re: Rich Harris joins Vercel to work on Svelte full time

#544

Earlier quoted context omitted.

Nothing about its usage implies what it actually does. It's about API affordances. You can't simply just read the code as someone inexperienced with React and say "oh, I know what this does". Returning a closure as the result of another closure has no inherent meaning as to when that closure would be called, because there's no "name" for that functionality. And don't even get me started about the dependencies array,…

If I hadn't been using React for many years before they introduced useEffect and various other hooks, they would have all been incredibly confusing. They still are really confusing when used in "clever" ways, especially with developers being allergic to writing comments. Even something as simple as `// this will do X when the component unmounts` make reading usages of useEffect 10x easier (vs. having to remember what…

It's very easy to convert a hook to a HoC, purely wrapping that functionality in a class component.

Re: Rich Harris joins Vercel to work on Svelte full time

#545

Earlier quoted context omitted.

We're not talking about React we're talking about JSX. Svelte has a lot more going on than it's template language as well. We're only comparing the templating system to JSX.

Let's compare to JSX then: https://news.ycombinator.com/item?id=29194287

That's still React. JSX is only turning brackets, tag names, and attributes into function calls and object properties.

Special attributes, events, etc. are React specific and not related to JSX.

Basically it's a clean way to represent nested function calls, that's it. It has nothing to do with React nor does it need React.

gets turned into React.createElement('tag', {prop: "value"})

That's all. Period. The special props React introduces has nothing to do with JSX.

Also you can customize JSX to change the functions it generates. (i.e. swapping out React.createElement)

Re: Rich Harris joins Vercel to work on Svelte full time

#546

Earlier quoted context omitted.

We're not talking about React we're talking about JSX. Svelte has a lot more going on than it's template language as well. We're only comparing the templating system to JSX.

Let's compare to JSX then: https://news.ycombinator.com/item?id=29194287

Those are all features of React or the React JSX transform, not JSX. Other JSX transforms or frameworks using them may or may not share any or all of them. (JSX is not only used in React.)

Re: Rich Harris joins Vercel to work on Svelte full time

#547

Earlier quoted context omitted.

Agree 100%. The migration from componentDidMount, componentDidUpdate, etc to useEffect was a major regression in terms of readability. The return function in useEffect vs. componentWillUnmount is just terrible. This is always a bizarre topic for juniors.

I actually think that useEffect is an amazing abstraction. It lets you group related functionality like subscribing and unsubscribing into one place and makes it very difficult to leak stuff or use stale values. I didn’t write many class components beforehand though, so my mental model didn’t have to change all that much.

I don't disagree that useEffect is a great extraction overall. But the mental load to understand it vs. explicit lifecycle methods is significantly worse.

The ability to subscribe is indeed amazing (this was much more verbose in class components).

Re: Rich Harris joins Vercel to work on Svelte full time

#548

Earlier quoted context omitted.

Agree 100%. The migration from componentDidMount, componentDidUpdate, etc to useEffect was a major regression in terms of readability. The return function in useEffect vs. componentWillUnmount is just terrible. This is always a bizarre topic for juniors.

I actually think that useEffect is an amazing abstraction. It lets you group related functionality like subscribing and unsubscribing into one place and makes it very difficult to leak stuff or use stale values. I didn’t write many class components beforehand though, so my mental model didn’t have to change all that much.

agreed. transition from classes to hooks and useEffect was confusing at first but it now seems very predictable and sensible (does get a little hairy when you have one effect dependent on another).

just started writing my own named effects (eg useAuth() for encapsulating firebase auth) and still in a bit of an uncanny valley with doing that - but again it's very logical once you get used to it and actually in the end a simpler mental model of component state.

never want to go back.

junior devs, start with useState, it'll all flow from there.

Re: Rich Harris joins Vercel to work on Svelte full time

#549

Earlier quoted context omitted.

Let's compare to JSX then: https://news.ycombinator.com/item?id=29194287

Those are all features of React or the React JSX transform, not JSX. Other JSX transforms or frameworks using them may or may not share any or all of them. (JSX is not only used in React.)

Ah. So we're comparing a specific templating language (Svelte) with an idealized and nonexistent version of JSX (JSX is a non-standard extension that has different flavors depending on what underlying framework, and versions of a framework, you use).

Re: Rich Harris joins Vercel to work on Svelte full time

#550

Earlier quoted context omitted.

Let's compare to JSX then: https://news.ycombinator.com/item?id=29194287

That's still React. JSX is only turning brackets, tag names, and attributes into function calls and object properties. Special attributes, events, etc. are React specific and not related to JSX. Basically it's a clean way to represent nested function calls, that's it. It has nothing to do with React nor does it need React. gets turned into React.createElement('tag', {prop: "value"}) That's all. Period. The special pr…

https://news.ycombinator.com/item?id=29206956
Post reply on HN