Live data from Hacker News

In search of the perfect JavaScript framework

dev.opera.com

81–85 of 85 posts

Re: In search of the perfect JavaScript framework

#81
post #62

>We want to apply values to variables and get the DOM updated. The popular two-way data binding should not be a feature, but a must-have core functionality. Strongly disagree. I find one-way bindings and one-way data flow much easier to reason about. A little less boilerplate code is not worth mental overhead, cascading updates and hunting down the source of wrong data in my experience. What is important is not updat…

What's with the immutability stuff? Shouldn't updates just be event driven? Is it really so hard for developers of parent components to subscribe to events of child components?

I would argue that a parent component listening to events on its child is an unnecessary level of indirection. The parent creates the child (or at least it should, in my opinion). The parent should just give the child the callbacks it wants directly.

I've become more or less convinced that over-reliance on events is a big anti-pattern. Combined with mutable state, you get a lot of difficult to track changes in state. Some describe it as COMEFROM-based programming, the dual of the much-maligned GOTO paradigm. The COMEFROMs are your listeners and event triggers are labels they reference. The downfalls of each are pretty much the same: code that becomes increasingly difficult to reason about as it scales, because you have arbitrary global movement in control flow. COMEFROM is even worse because it introduces concurrency. Concurrency + shared mutable state is a recipe for subtle bugs.

So much of the time in a web app, an event only really has one listener. In these cases, a simple callback passed to the child component suffices. But even when you might need to have more than one component react to an event in a child component, I would argue that whatever is responsible for creating the child should still pass a single callback, which might simply be an entry point to dispatch logic on a controller whose only job is to mediate that behavior. Said controller might use or something else as its mechanism.

Re: In search of the perfect JavaScript framework

#82
post #62

Earlier quoted context omitted.

What's with the immutability stuff? Shouldn't updates just be event driven? Is it really so hard for developers of parent components to subscribe to events of child components?

I would argue that a parent component listening to events on its child is an unnecessary level of indirection. The parent creates the child (or at least it should, in my opinion). The parent should just give the child the callbacks it wants directly. I've become more or less convinced that over-reliance on events is a big anti-pattern. Combined with mutable state, you get a lot of difficult to track changes in state.…

Why is it hard to reason about event based code? A framework will need the flexibility to enable any developer of any component to do what they need when something happens. That is what an event system enables.

If you want the events to be a directed tree, that's basically what angular 2 implements. Immutabilty is optional.

I can easily visualize a tree and reason about it. Gotos are very different. What you wrote seems like a bit of equivocation.

The parent creates the child (or at least it should, in my opinion). The parent should just give the child the callbacks it wants directly

That's what setting event listeners is. The parent knows about the interface of the child, not necessarily the other way around. So the child won't be able to know what callbacks to call. That is also why inversion-of-control leads to more stable platforms.

Re: In search of the perfect JavaScript framework

#83
I don't think people use frameworks and abstractions because they have a smoothier learning curve, or because they are simpler, but because of DRY. After repeating the same pattern twice, the programmer turns it into a module and abstracts it. After having a lot of modules, the programmer packages them all in a framework. This is good for the author of those modules and the framework, because he understand them, but not always for the outsider who just looks at the complete framework and don't know what's inside.

Re: In search of the perfect JavaScript framework

#84

Earlier quoted context omitted.

As a developer that recently made the transition from FileMaker, which is very user-friendly but limiting, to Rails, I love the new possibilities and the fact that Rails provides nearly everything I need and comes with established best practices, but I'm always a little helpless when interactivity (without reloading the page) is required. The apps I'm working on (internal, business apps) mostly work perfectly fine wi…

I found Knockout to be a great middle ground for when "I can do this in jQuery, but it's gona be messy" and "I'm building a SPA". It hits the sweet spot between easy learning curve, abstraction, and interacting with the DOM nicely. Sadly, it's not as hip as React/Angular/Ember these days.

I've also had a good experience using Knockout. I used it to add some interactivity to a largely static site, and then expanded its use to create a fairly complex management interface. It's easy to pick up with great interactive tutorials on the web site, and with component support in the latest version you can build some larger web apps.

Microsoft uses it their recent remake of their Azure portal; this page has a video on building large apps with Knockout: http://jbeckwith.com/2014/09/20/how-the-azure-portal-works/

Re: In search of the perfect JavaScript framework

#85
post #41

> "Abstraction is dangerous" The fact that Javascript people keep saying this with a straight face is getting really absurd. You do realize Javascript is also just an abstraction, right? And that the browsers that run it also abstractions, and the operating systems, and the kernels, and even the hardware itself has multiple layers of abstraction? "Abstraction is dangerous" is just fundamentally wrong. Abstraction is…

Looks like someone things "dangerous" and "useful" are mutually exclusive. See also electricity, automobiles, consuming food, etc. No one is saying "don't use abstraction ever."

Maybe this metaphor will help:

"Using other people’s code is like surfing. You control and surrender. You’ve got to trust the wave to carry you, but stop paying attention, and the first abstraction leak will throw you under the water."

https://medium.com/@dan_abramov/youre-missing-the-point-of-r...

Sure, you could say "bad abstractions are bad." And it's true there's a spectrum. Some are much less leaky than others, of course, some have the boundaries of what they do and their interface outside more elegantly shaped than others. But saying "well, we just don't want bad abstractions" doesn't capture well the fact that all abstractions either leak to some degree or are awkward coverings for some problem domains.

Nor does it really get us where we want to go in terms of "exactly what abstractions we want." We want useful ones. We want minimally dangerous ones. And the way you get the latter is to understand how abstractions are dangerous.

Post reply on HN