Ditch React. Ditch Angular. Go Vanilla with Zam
zamjs.com
zamjs.com
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 from a library like React. From a pure performance perspective it does appear there may be some merit in evaluating a pure JS DOM approach to a given problem. However, from the perspective of managing a team of developers who want to deliver a large amount of maintainable code, there can be a clear advantage to leveraging libraries and frameworks such as React, Polymer, Angular, etc.
https://objectpartners.com/2015/11/19/comparing-react-js-per...
(I'm not sure of any of this though, so I'd love to hear others, who have kicked the tires, weigh in.
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, is it faster because it uses native dom selection functions? If so, then this is just an extra layer of indirection with no added value over something like a polyfill. 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?
"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.
eg in the documentation, ".fadeIn(selector, time)" - "Returns nothing". Why not return a future that resolves when the fade completes?
You are right. fadeIn and fadeOut should have some optional callback for completion.
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 easier for a transpiler to handle, and doesn't scream "refactor me!" right after you've deployed your app.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 of a then-able object? I found more readable to have a (sincronous, debuggable, "old-style") function without the need to split in one thousand one line lambdas.
moreover, my python background makes me looks as "ugly" the last one, as it's a lambda function with an assignement, and not a simple expression.
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.
Things get a little more complex with some of the methods though. For example: .css()
Fetch is only faster on certain browsers. I'm thinking about incorporating it in the future.
I had to explicitly set "left: 0"
Seriously though, this looks interesting, but the "ditch React/Angular" claims are silly, there's gotta be a better way to differentiate yourself and convey your value prop.