Live data from Hacker News

Ditch React. Ditch Angular. Go Vanilla with Zam

zamjs.com

21–29 of 29 posts

Re: Ditch React. Ditch Angular. Go Vanilla with Zam

#21
post #15

Good work. It seems like a working library. And it's fast at the things it chooses to do. But ... 1. Ditching React and Angular for this is like ditching Photoshop for MS Paint. 2. Someone using Zam isn't "going vanilla JS", they are going Zam JS. 3. Going into a performance arms race with jQuery is not a one man job. It would be nice to know how you achieve such performance gains. What tradeoffs are involved? Like,…

I see your points.

"Like, is it faster because it uses native dom selection functions?"

Yes, this library is fast because it's based around native dom functions.

"If that's not the case, what kind of groundbreaking work did you do here to achieve the impressive looking benchmarks on the Github page?"

I'm not claiming there's anything "groundbreaking" about this library. I made it to encourage vanillajs development, which I believe to be important.

Re: Ditch React. Ditch Angular. Go Vanilla with Zam

#22
post #16

Earlier quoted context omitted.

I saw this "then-heavy" style in many places, but I never really understood: I find perfectly fine to make "fadeIn" return a promise, or an ajax call, and find "the right way" to join them with then / when / Promise.all etc. But what is the meaning to add a lambda function as "response => response.json()" in a then? why a different lambda "json => el.innerHTML = json.results[2].message" ? isn't it a "gratuitous" use…

Not sure what you mean but response.json() is promise that can fail with parse/read error. It's where error handling should happen making it imperative doesn't solve anything

I don’t know why you assert that that’s where error handling should happen because I disagree. My thought was that promises were for values that are calculated asynchronously or anyways aren’t immediately available. They support errors but I don’t think this means that all code which emits errors should use promises to do error handling, that seems like a bastardization of the original idea.

Re: Ditch React. Ditch Angular. Go Vanilla with Zam

#23

Earlier quoted context omitted.

Not sure what you mean but response.json() is promise that can fail with parse/read error. It's where error handling should happen making it imperative doesn't solve anything

I don’t know why you assert that that’s where error handling should happen because I disagree. My thought was that promises were for values that are calculated asynchronously or anyways aren’t immediately available. They support errors but I don’t think this means that all code which emits errors should use promises to do error handling, that seems like a bastardization of the original idea.

It is calculated asynchronously. Response body is lazy and calling .json() on it consumes it and returns promise. That is API of WHATWG fetch and many other JS HTTP clients https://fetch.spec.whatwg.org/#body-mixin

Re: Ditch React. Ditch Angular. Go Vanilla with Zam

#25
post #13
post #9

Earlier quoted context omitted.

From a performance stand point -- does it really matter? You are right. fadeIn and fadeOut should have some optional callback for completion.

Yes, it absolutely does matter. Chaining promises together, running them in parallel with Promise.all, and the abortable-promise pattern, make developing (and especially debugging!) much much easier than having to deal with callback hell. zam.fadeIn(el, duration) .then(zam.ajax(url)) .then(response => response.json()) .then(json => el.innerHTML = json.results[2].message) This code is nearly self-documenting, is easie…

Wouldn’t you want the fadeIn to be parallel to the Ajax fetch?

Re: Ditch React. Ditch Angular. Go Vanilla with Zam

#26
post #8

Genuine question: in 2017, why would you create a JS framework that didn't use futures? eg in the documentation, ".fadeIn(selector, time)" - "Returns nothing". Why not return a future that resolves when the fade completes?

They are called Promises. Stop trying to use different words to sound smart

Re: Ditch React. Ditch Angular. Go Vanilla with Zam

#28
When writing a framework, I always ask myself what is this doing that cannot easily be done with the native APIs?. Answering this question is easy for both Angular and React: in both cases they enforce conventions that make certain flavours of software development easier.

What advantage does Zam have over using the regular DOM api? AFAICT, Zam doesn't introduce significant changes to the underlying paradigms so by Occham's Razor I have a hard time believing this additional framework will help me.

On a side note, I'm not sure why everyone attacks React and Angular so much. Believe it or not, they work very well for their intended purpose. There will always be hacks in every community who chose bazookas to catch butterflies but it's a fallacy to attribute that to the framework itself. Both React and Angular, IMO, enforce concerns that scale super-linearly w.r.t. to project size: e.g. mutating a DOM element is fine if you're the only actor on the document but definitely doesn't work when n actors all depend on the same DOM node to broker a shared state.

Re: Ditch React. Ditch Angular. Go Vanilla with Zam

#29

The title is pretty ridiculous. There are legitimate reasons why people use frameworks like React and Angular. Things like Zam and jQuery could be fine for small projects, but there's no way this is a replacement for frameworks that have build systems, virtual DOMs, etc. Maybe I'm taking the cheeky headline too seriously?

I totally agree with you. I think this guy states it pretty well when it comes to React vs. VanillaJS. There is no doubt that React.js is a great approach towards managing state in the view layer of a browser application. However, from my own limited experience as well as just comparing raw numbers from time spent in rendering to the amount of memory consumed, there is a clear price to pay in any convenience gained f…

Have you looked into Preact? Aside from the convenience of being (almost) a drop-in replacement for React, I recall it was also supposed to be much more performant. While I'm sure pure JS DOM could eke out even better performance, it's possible that compared to Preact (or some other fast VDOM implementation like mithril), the benefits are not worth it anymore.

(I'm not sure of any of this though, so I'd love to hear others, who have kicked the tires, weigh in.

Post reply on HN