Live data from Hacker News

Metaphysics and JavaScript

docs.google.com

21–30 of 34 posts

Re: Metaphysics and JavaScript

#21
post #16

Earlier quoted context omitted.

I really don't see the comparison with Angular other than the use of templates. Can you elaborate? Also, what "rails" does React provide?

> I really don't see the comparison with Angular I haven't used Svelte so take my comparison surface level. templates, directives and the prop names all remind me of Angular. > Also, what "rails" does React provide? The "rails" that react provided that I found useful where more around opinionated data flow with props (especially with Flux).

> templates, directives and the prop names all remind me of Angular

Yes, but those are commonplace in any library/framework that uses templates. Like you said, this is just a very superficial comparison. Angular is framework that comes with lots of abstractions, modules, dependency injection, etc. It's a very different beast than Svelte.

> The "rails" that react provided that I found useful where more around opinionated data flow with props (especially with Flux).

Right, but React is only the rendering part. You are probably refering to Redux.

Re: Metaphysics and JavaScript

#22
post #19
post #15

I've tried Svelte and while I don't love some of the dev ergonomics it's a damn fine project. React was a great alternative to Angular back in 2015 but it's not even close to being objectively the best solution in 2019 except for its popularity. Preact or Inferno are so much faster/lightweight and are pretty much drop-in replacements for React. BTW is there a video of this presentation somewhere?

We pretty much only use React for rendering and lifecycle (still rocking class-based components). Does Preact offer material improvements other than bundle size? If so I might look into switching.

Preact is considerably faster, but maybe React is good enough in your use case.

I also prefer using mostly class based components and some functional components for lightweight dumb components. I use Inferno for rendering and vanilla + MobX for everything else.

Re: Metaphysics and JavaScript

#23
post #22
post #19

Earlier quoted context omitted.

We pretty much only use React for rendering and lifecycle (still rocking class-based components). Does Preact offer material improvements other than bundle size? If so I might look into switching.

Preact is considerably faster, but maybe React is good enough in your use case. I also prefer using mostly class based components and some functional components for lightweight dumb components. I use Inferno for rendering and vanilla + MobX for everything else.

We certainly have performance bottlenecks in our rendering, so if a different library is faster we're definitely interested

Re: Metaphysics and JavaScript

#24
post #14
post #6

I'm not sure I understand. Yes, there are some pitfalls to React Hooks (and, honestly, they're really slick but definitely require more cognitive overhead than React.Component) but he doesn't really describe how Svelte solves these problems. In fact, looking at the demo code it looks pretty similar to how I'd built it in React. My trepidations concerning frameworks like Svelte come from things like this: ` ` What doe…

bind:group is explained in the docs ( https://svelte.dev/tutorial/group-inputs ). I don't think React would be particularly easy to grok without first having read its docs (or some kind of instructional material) either. Regarding the "magic," note that you can always inspect the generated Javascript, which is quite readable (particularly in dev mode). Given that the component code is largely self-contained (it does…

That's not what I mean when I say "magic". Magic, to me, is having some special string in your template which is going to invoke some arbitrary logic to get something "just working". In this example, note how `group` does different things depending on what kind of input you're dealing with. That's the kind of stuff that sounds great in a demo but quickly becomes a pain in a large application.

It's not about being able to learn a framework without reading the documentation, it's about how many distinct concepts you have to read the documentation for to use the framework. React is extremely conceptually light, by design, which is something I love about it.

Re: Metaphysics and JavaScript

#27
post #24
post #14

Earlier quoted context omitted.

bind:group is explained in the docs ( https://svelte.dev/tutorial/group-inputs ). I don't think React would be particularly easy to grok without first having read its docs (or some kind of instructional material) either. Regarding the "magic," note that you can always inspect the generated Javascript, which is quite readable (particularly in dev mode). Given that the component code is largely self-contained (it does…

That's not what I mean when I say "magic". Magic, to me, is having some special string in your template which is going to invoke some arbitrary logic to get something "just working". In this example, note how `group` does different things depending on what kind of input you're dealing with. That's the kind of stuff that sounds great in a demo but quickly becomes a pain in a large application. It's not about being abl…

bind:group is not a "special string" but simply part of the API, in the same way useEffect is part of the React API. bind:group is no more "magical" than useEffect (both are ultimately going to "invoke some arbitrary logic").

> In this example, note how `group` does different things depending on what kind of input you're dealing with. That's the kind of stuff that sounds great in a demo but quickly becomes a pain in a large application.

I really don't see how. It is relevant to exactly two kinds of inputs (radio and checkbox) and does exactly what you would expect with each (given the different behaviors of radio and checkbox inputs).

> It's not about being able to learn a framework without reading the documentation, it's about how many distinct concepts you have to read the documentation for to use the framework.

Sure, but looking at the right menu in the React documentation (https://reactjs.org/docs/getting-started.html), there are actually quite a lot of concepts and API details to understand in order to become proficient in writing React apps. I would be hard pressed to say that looks any lighter or simpler than Svelte (I would actually argue the opposite -- Svelte seems simpler and more straightforward).

Re: Metaphysics and JavaScript

#28
post #27
post #24

Earlier quoted context omitted.

That's not what I mean when I say "magic". Magic, to me, is having some special string in your template which is going to invoke some arbitrary logic to get something "just working". In this example, note how `group` does different things depending on what kind of input you're dealing with. That's the kind of stuff that sounds great in a demo but quickly becomes a pain in a large application. It's not about being abl…

bind:group is not a "special string" but simply part of the API, in the same way useEffect is part of the React API. bind:group is no more "magical" than useEffect (both are ultimately going to "invoke some arbitrary logic"). > In this example, note how `group` does different things depending on what kind of input you're dealing with. That's the kind of stuff that sounds great in a demo but quickly becomes a pain in…

> bind:group is not a "special string" but simply part of the API

Right, but the difference is in the API design. React gives you a small set of tools to implement whatever functionality you need. Svelte gives you specially-crafted tools which to handle specific scenarios. Svelte gives you a command to bind input groups to a stateful value, React gives you the tools to do it yourself. The difference is subtle but experience has lead me to vastly prefer the latter, mostly because you're less reliant on the framework designer getting everything "right".

Here's a good talk which helps explain the difference: https://2014.jsconf.eu/speakers/sebastian-markbage-minimal-a...

Re: Metaphysics and JavaScript

#29
post #28
post #27

Earlier quoted context omitted.

bind:group is not a "special string" but simply part of the API, in the same way useEffect is part of the React API. bind:group is no more "magical" than useEffect (both are ultimately going to "invoke some arbitrary logic"). > In this example, note how `group` does different things depending on what kind of input you're dealing with. That's the kind of stuff that sounds great in a demo but quickly becomes a pain in…

> bind:group is not a "special string" but simply part of the API Right, but the difference is in the API design. React gives you a small set of tools to implement whatever functionality you need. Svelte gives you specially-crafted tools which to handle specific scenarios. Svelte gives you a command to bind input groups to a stateful value, React gives you the tools to do it yourself. The difference is subtle but exp…

I think React gives you more specially-crafted tools than you suggest and Svelte gives you fewer than you suggest. Even in this case, bind:group is just a shortcut -- Svelte also provides the tools to "do it yourself" if you need that ability in some special case (see https://svelte.dev/repl/3cffb15ef71f43b08872f72c527089a2?ver...).

Re: Metaphysics and JavaScript

#30
post #17
post #13

This is a very good take. DOM as a function of state has real tradeoffs but also real benefits; state as a function of state just gets out of hand. IMO React Hooks are where React jumped the shark. setState and Redux were already clunky and felt too rooted in unhelpful ideals, but hooks just took the cake. My company's codebase uses MobX for all state and I highly recommend it. It embraces mutability and imperative c…

To add insult to injury it's fairly easy to use hooks wrong - and used wrong they are, which suggests that their learning curve is not as friendly as proponents of this pattern would wish.

Could you share some examples of hooks used wrongly in code?
Post reply on HN