3 ms·
I've heard good things about Mithril performance. I'll need to take a look. Virtual DOM as a panacea may be overrated, though. Maybe React's just isn't fast en
by SomeCallMeTim 11y ago
I've heard good things about Mithril performance. I'll need to take a look.
Virtual DOM as a panacea may be overrated, though. Maybe React's just isn't fast enough, but if you use another way to keep track of what parts of the DOM to change, simply pushing things into the DOM can be WAY faster than using a Virtual DOM. [1]
Cycle.JS still hits my "HTML in code BAD" reaction. An example from the front page:
.map(name =>
h('div', [
h('label', 'Name:'),
h('input.field', {attributes: {type: 'text'}}),
h('h1', 'Hello ' + name)
])
So we're again mixing HTML and JavaScript, and in this case we're also reinventing the syntax. If you're going to mix HTML with JavaScript, at least using standard HTML syntax seems like a better solution.
A lot of popular frameworks are using this generated HTML approach, though (including apparently Mithril). I'm still trying to figure out if my negative reaction is justified.
[1] https://aerotwist.com/blog/react-plus-performance-equals-what/ https://aerotwist.com/blog/react-plus-performance-equals-wha...
- staltz 11y agoThis is such a superficial aspect of the framework that it's really not worth discussing. You need to go deeper to learn it properly, and only then give verdict. In ClojureScript (Om, Reagent, etc), you have the same HTML building pieces with code. Also in Elm you use normal Elm functions, not a HTMLish DSL. Also, nowadays in Cycle.js we use the more friendly syntax: .map(name => div([ label('Name:'), input('.field', {attributes: {type: 'text'}}), h1('Hello ' + name) ]) ) Which was inspired by elm-html https://github.com/evancz/elm-html https://github.com/evancz/elm-html .
- Frikki 11y agoIt’s no more "HTML" in your JavaScript than if you do `document.createElement('div')`. `h` is method that returns a JavaScript object; not HTML.
- SomeCallMeTim 11y agoI don't use document.createElement('div') in any but very rare situations either.
- foxdonut00 11y ago> "HTML in code BAD" reaction That's what it is, just an automatic reaction without any real practical argument. Do yourself a favour and "unlearn" that. Open your mind. You're doing yourself a huge disservice by turning away from new ideas with these knee-jerk reactions. Working with views as functions of data gives you much more than it takes away.
- SomeCallMeTim 11y agoI'm considering doing exactly that (unlearning the reaction). Too many people are agreeing with you for me to ignore it. On the other hand, every time I turn around I think of more things that it "takes away." This time it's an entire category of tool: The visual layout editor. I like it when my code can be data-driven, and data-driven using a standard format that can be saved using a (visual) tool. I especially like it when my artists can tweak the page layout for me, but I don't like the idea of giving the artists files full of JavaScript or JSX to tweak. Are there artist-friendly tools that can edit the layout of a React site/app, where the JSX can be modified in-place using the tool? It doesn't strike me as an impossible-to-solve problem, but it could be tricky to do well.