3 ms·
The author has taken an Ember app they wrote themselves, and compared it to a React example that includes code from the 19th chapter of a guide to learning Reac
by onion2k 7y ago
The author has taken an Ember app they wrote themselves, and compared it to a React example that includes code from the 19th chapter of a guide to learning React, "React Custom Hooks (Advanced)", without working through the first 18 chapters. It's no wonder they found it complicated.
Comparing things is good and useful, but if you're not qualified to understand both sides of the argument well it's really hard to do a good job. This article fails hard on that count.
Also...
The first thing that is a clear difference with the Ember Octane version is that it's split across multiple files.
The React example is one file because it's an example. The idea is to demonstrate all the moving parts in one place. It's not presented as a representation of what you would build as a production app. If you look at Road To React there's a chapter called "Folder/File Organization" in the appendices that explains how you might progress after working through the tutorial app.
- thawaway1837 7y agoHaving interacted with Core Ember devs I would be very surprised if the author didn’t know anything about React. I’d wager that he indeed knows a lot about React. At least the ones I interacted with did not only know React, they knew it well enough to identify its pitfalls, and be able to translate what they believed to be its best parts to EmberJs. Also, the comment about different files is a thing even outside this example (and is one reason I prefer react over Ember personally). React has no defined file system, and strongly encourages components are written in a single file. Ember, OTOH, does a lot of file separation, and a lot of convention over configuration.
- cageface 7y agoConvention over configuration is one of the worst ideas ever in software in my opinion. All it means is that you have to memorize all the implicit assumptions about how an app is put together before you can work productively. It makes for great convention talk demos but in production what you really want is very explicit and obvious relationships between pieces. For example, this is the reason I find a React/Typescript codebase vastly easier to understand than Rails. If your language is so verbose that making things explicit is too painful then maybe it's time to reach for a more expressive language instead of hiding everything behind a set of implicit rules.
- 101404 7y agoNo, it means that there's a way things are usually done, but if, in you situation, a different way works better, you are free to use it without having to fight the framework.
- cageface 7y agoIn a React codebase, for example, I can look at the imports and see immediately where everything in play in that file came from. In real production codebases this is invaluable.
- pzuraq 7y agoI definitely agree with this! In large codebases especially. This is ultimately why Ember has decided to move toward using JS imports to stitch components together as well, we recently merged an RFC to do just that.
- thawaway1837 7y agoThis was my favorite part about Ember, and what I miss the most. The Ember team is one of the least dogmatic teams that I have come across, and has been willing to change their entire strategy when presented with a better idea (while providing a well defined and fairly convenient upgrade path). I still remember when React first came out, and showed how one way binding was so much better than 2 way bindings, and the Ember team was able to quickly switch to this new philosophy via DDAU, while still providing an easy upgrade path for our code. And all this was before 1.0 if I remember correctly.
- holler 7y ago> I can look at the imports and see immediately where everything in play in that file came from. I'm confused, ember uses standard js imports as well so what's the difference?
- holler 7y ago> Convention over configuration is one of the worst ideas ever in software in my opinion. When I first started working with ember many years ago, I felt the same way. But now after working on many ember apps, I feel the opposite. The "convention over configuration" really only applies to basic application structure e.g. routing/templates/controllers etc. All it's really doing is creating a standard place to put files, which itself is flexible and more recently allows e.g. colocated components like you'd see in react/vue/etc. I think the core point from the article is just how much ember.js has changed and matured. If you read to the bottom it looks like single-file components with glimmer are in the pipeline as well.
- onion2k 7y agoReact has no defined file system, and strongly encourages components are written in a single file. Sure, but there's a lot more to the example that a single component. There's the app component, 3 other components, a reducer, and a custom hook. Putting all that in a single file is fine for an extended example explaining how things work together with a further chapter explaining how to break it down in to separate files, but it's not how you'd write a real app. The article author clearly doesn't know that if his criticism is that Ember does it better by using more files, so it not unreasonable to question if his knowledge of React is up to comparing it to Ember. It's quite a fundamental mistake he's making.
- thawaway1837 7y agoI don’t think that’s what he is talking about here though. And note, his point about the multiple files isnt even a complaint. As someone who worked with Ember in the past (our company inherited a new product with an acquisition so we were forced to change tech stacks), this comment really comes from the fact that Ember has a very comprehensive file layout system. And one of the major criticisms about Ember classic was how different core pieces for the same component, were located in so many distant folders (hence the comment about colocation of component code, which seems trivial, but is a huge usability gain IMO). I think that sentence should be read more as a reflection on Ember, than suggesting the author does not think React components can be broken into multiple files, and hence an indication of their knowledge of react.
- blktiger 7y agoHaving worked with React/Hooks for the past few months - I think he did a good job of identifying the benefits and problems of hooks. In a production application, you are likely to use something like redux or xstate to keep the state in your components minimal which in turn allows you to avoid a lot of the complexity that hooks have.
- mnutt 7y agoI didn’t get the sense that the author was passing a value judgment against react for being in a single file. Later on he mentions that he likes the ability to colocate component and template, as it is more flexible.
- pzuraq 7y agoHey there! Author here. I actually did work through all of the examples and am very familiar with all of the hooks, I have done a lot of in-depth research while designing and working on Ember in order to understand the pros and cons of hooks. Typically, when another framework makes a new API that is popular, my first reaction is to do research and try to understand how the API works, what its pros and cons are, and to see what I would like to pull back into our own work. As I noted near then end, there is actually a lot I like about hooks! While it does feel a bit overly granular and tricky to me, especially at the lowest level, it adds a composition primitive that didn't really exist before, and doesn't exist currently in Ember (though we're working on it, like I mention near the end). I think we may just have a different sense of what drives complexity, and what can cause antipatterns at a high level. I would prefer something just a little bit less expressive, but with many of the same composability benefits. > The React example is one file because it's an example. The idea is to demonstrate all the moving parts in one place. It's not presented as a representation of what you would build as a production app. I'm very aware of that! I was actually just pointing out a difference there, and that difference is actually something that is _enforced_ in Ember (and actually something we're looking to change, as I discuss in the last section of the post), so I was mainly pointing it out in case people were wondering why I didn't have a more equivalent example. I didn't use the later examples because they added too much more functionality for me to address in a single blog post, and I didn't want to split the files out in the example because I didn't want to change anything in general, in case people thought I was making bad-faith changes just to make React look bad.
- lhorie 7y ago> The React example is one file because it's an example The argument here is that Ember - true to its frameworkiness - enforces a certain file organization pattern. In React, you _can_ split things into different files, but how _you_ do it might not be the same as how _I_ do it (and one may not even do it depending on the situation, e.g. a one-off Error component in a bundle-split API.) On a similar account, because Ember is frameworky and convention-over-configuration, then a happy path in it _should_ be less "complicated" than wiring everything up manually in a less opinionated system. That's sorta the whole point. There are certainly arguments to be made about magical-ness and not-so-happy-paths, but I don't think it's fair to characterize the differences in framework philosophies as an author failing.