Lurker News

Comments (156) 28 threads

Earlier comments
leontrolski5 replies#
Author here, this was written as a way for me to explore the core idea of react in a minimal setting. Things it's missing

- jsx
- routing
- performance (maybe?)
- component state management stuff
What else would you include?

ngrilly#
Agreed, except for routing which is not a part of React per se.
dahart#
This looks interesting! Not a working replacement for React, right? I would probably add that for optimal performance, don’t use functional differential rendering at all. Keep state and use direct DOM manipulation of only elements that change, right? The very idea of re-rendering by throwing a whole new page up and letting the system diff and update is guaranteed not to be optimal performance, it’s always doing more work than necessary. The tradeoff is that the optimally performant solutions are imperative and stateful and involve all the difficult and bug-prone techniques everyone’s trying to avoid. Engineering for functionality is a solved problem. Engineering for performance is not.
urvader#
Look at Pureact (I’m the author) and make a pull request with your diff code to make the whole thing without any dependencies? Would be supercool!
jonahx2 replies#
Very nicely done. For a similar idea that can be used in production as a React replacement, check out the Meiosis pattern:

http://meiosis.js.org/
It has most of React's benefits, while being extremely lightweight and fully grokkable (no hidden parts, no magic, no framework logic) to any developer.

benbristow1 reply#
With none of the community support or third-party components that the React ecosystem has?
toastercat#
Why use any new & upcoming tool when an older, more popular tool inevitably has more community support and third-party components?
hencq#
I'm not sure if you're the author, but in case you are I just want to say well done on the tutorial! I really like the way it's built up and not only shows the pattern, but also the why behind the pattern. I will definitely give this a try with Mithril.
leontrolski1 reply#
Yeah, it's very mithril influenced (I love that library) - I namecheck them in the article at the top.
codegladiator#
Oh I completely skipped that line. I like mithril a lot as well but haven't been able too use it in a real project.
ppeetteerr1 reply#
> const move = (value, i, j){...}

> This function makes a move in the game, it takes 'x' or 'o' along with 2 integer coordinates. It will mutate all the state variables to reflect the new state of the game. After that, it calls renderNoughts(), this is a call to rerender the game - but we'll come back to that.
Dear programmers, not related to the actual article but, when you have to describe your function with a paragraph of text, please consider improving the naming of your function and its parameters.

bigmanwalter1 reply#
It seems perfectly well named to me! I love when code bases have more lines of comments than actual code.
ricardobeat1 reply#
Sometimes the comments are only required because the code is confusing.

In this case the function both mutates the state, and renders the app. If using a framework like React/Vue etc it might make perfect sense to call this function `move`, but here it has a lot more responsibility and would need a more representative name like update/setState/renderApp/etc. But I think it's pointless to debate as it breaks the single-responsibility principle and you're unlikely to find something like this in a large scale app anyway.

bigmanwalter#
It could also be because the code is terse. In that case it makes sense to explain what's going on.

Load more comments