Those screenshots of code are kind of a challenge to read.
tags.41–50 of 147 posts
Those screenshots of code are kind of a challenge to read.
tags.Earlier quoted context omitted.
Yes and no. Homerolled solutions such as this are free of another developers assumptions, but tend to scale poorly. Generally they need to be modified as new requirements are created, or unforeseen circumstances arise. Over time you end up putting together more and more logic in and the illogical conclusion is that you end up building your own heavily bespoke version of React/Angular/jQuery/whatever, before realising…
You are absolutely right, but I do believe people should start learning the alphabet before trying to read a book. React looks fine to me and at my daily job our frontend devs do some amazing job. I just wanted to learn and all I seem to find is how to learn javascript through React, and not React through Javascript. I do agree this is a home made solution and would not work nicely with lots of devs involved. I'm tal…
Yes, frameworks are built from the basics and novels are built from an alphabet.
However, Frameworks reduce relative complexity, increasing their audience. Novels actually have an increased relative complexity reducing their audience.
While, its hard to find good analogies outside software development, it might be more correct to say: if javascript is the alphabet, then React is a picture book.
Picture books lowering the relative complexity, allow literate and illiterate people alike to mostly understand a story. Here its easier to see that the Framework (pictures) help novices (the illiterate, i.e. children), as soon as possible, to become independent and productive (understand the story). There is also the added benefit that exposure to both words and pictures simultaneously allows for an understanding of the alphabet and grammar, i.e. helps the learning process.
Frameworks don't exist just because someone wanted to write a framework. They exist because they solve problems. And they solve problems you likely forgot to think about so you don't have to. Like not losing cursor positions when re-rendering, or not breaking the DOM when trying to re-use input elements or manipulate tables.
React is actually great in this regard: it doesn't try to solve everything, it just focusses on one problem (two if you include React-DOM/Native) and solves it well. Redux is another great example (the entire API can be implemented in less than 100 lines).
The reason libraries and frameworks like React and Backbone and Angular and Ember exist is that direct DOM manipulation doesn't scale. It's on a lower level of abstraction than the application you're trying to build. And the advantage of React (and similar libraries like Mercury) is that it just lets you build components (i.e. partial DOM trees) -- it's trivial to swap the component library out in the future without having to touch any of the application logic around it.
I went down a similar path a few years ago when starting a new project. Instead of learning a new framework I wrote my own. It took less time overall, since the logic wasn't especially hard to write, and it was easier to debug - at first. Everything changed as soon as another developer, then two, then three, started working on it with me. They were not happy about learning how to use my custom MVC framework. Perhaps…
imo: frameworks are materialized experience, opinions, and testing.
If writing a framework is not a goal of the project, don't write your own framework. And few projects have the clear goal of writing a new framework (especially in addition to any other goals like creating a product).
1. Language forces you to model-view-controller style
2. Language makes the model immutable
3. Language forces you to use correct types which saves a lot of trouble.
On the other hand, I a new to frontend - so I might be wrong.
Has anyone wondered how similar in spirit React is to the way html and js were originally meant to be written (with embedded callbacks, e.g. ` `)? Isn't the `a` in some sense a React component with explicit and local state changes, only missing a explicit render? Theoretically one could build on top of this to make Angular/React style custom components without the need to re-invent state management code. Of course, I…
But the more poignant observation about React is that the components aren't actually anything like templates. You can think of React components as descriptions of the structure of the DOM -- if the equivalent structures in the DOM already exist[1], they are just "progressively enhanced" when you run React on them. The only reason you would want to generate that HTML on the server with React instead of writing that HTML yourself is that it avoids unnecessary duplication.
[1]: currently React needs to add proprietary attributes to identify markup generated by React but this will be made redundant in an upcoming version.
But React is about the view. You can't possibly be convinced that manually traversing the dom is just as easy and expressive as using JSX. Even in the simplest of interactive (as in you need Javascript) components or pages.
React's concept and syntax is super easy to understand and perfect for modularizing the components of your app. The real problem IMHO is the tool chain. That's what drives developers unfamiliar with the ecosystem away. And of course the fact that it seems to change all the time. The first time I looked at React they rolled their own transpiler. Now Babel is the recommended way to go.
According to the tutorial page you should either use browserify or webpack. You don't have to - but without them stuff gets messy pretty quick. Of course if you pick one of these up you also have to learn how to use them and you will want plugin A, B and C to get to your simple Hello, World React App in the first place.
So yeah. That's why it's so easy to step away from that thinking why don't I just simply roll my own framework.
The best thing about Polymer is that, unlike React, it works with W3C standards instead of going off on a tangent and hacking the DOM entirely. It extends current HTML5 standards instead of creating its own universe.
With Polymer, each component has its own mini-DOM which is actually a real DOM - Not the virtual layer you get in React which keeps overwriting the real DOM.
Unlike Angular, Polymer gives you a lot of control when it comes to how data flows throughout your app. Because of this, there are a few different component-level configs that you need get your head around. For example, by default in Polymer, data only flows downwards to child components, you have to enable a special 'notify' attribute to allow data to flow upwards to parents (this is different from Angular where data flows freely wherever there is a placeholder for it in your DOM).
I think React has been getting way too much hype. Polymer, on the other hand, is ridiculously under-hyped. Of those people I know who used both React and Polymer, all of them preferred Polymer. I'd like to hear alternative opinions from other people though.
React is just a library. It is the ideas behind it that are important: a) building web front-ends by dividing them into components which are first-class citizens of the codebase, and can be composed, parameterized and reused, just like pure functions. [1] b) expressing the view as a pure function of state has replaced any need to mutate the DOM manually and think about transitions ($.remove(), $.append() etc.). We ne…
There is no 'one true way'; as long as your app works and you can hold it in your head, everything is fine. With all due respect, this is the major criticism of adopting React, given that it's still in active development and given that many who are looking at using it have established apps using other patterns already.
function Comp(state) {
return React.createElement(
'div', // tag name
{}, // props/attributes
'Hello ', state.name // children
);
}
And this is how you use it: ReactDOM.render(
React.createElement(Comp, {name: 'World'}),
document.getElementById('stage')
);
So in those situations the entire surface of the React API consists of two functions: React.createElement and ReactDOM.render. And if you use JSX, you won't even directly use React.createElement in your code.React is conceptually trivial. The API has been getting tighter with each release. React is in active development but so are all of its competitors[1][2]. React is production ready -- Facebook is even dogfooding the pre-releases in production.
[1]: in fact, when a library/frameworks stops being actively developed people start assuming it's dead. Counter-example: Redux is no longer actively being developed because it is officially complete and the implementation is so straightforward and resilient it can't really be improved right now.
[2]: the reason it's bogus to compare it to Angular2 "because that's not finished yet either" is that Angular2 is being built to spec whereas React is being developed under use. Angular2 will be "finished" when the full spec is implemented. React will be "finished" when real-world use shows no further need to change -- by that definition none of the alternatives (including Angular2 post-"final") is "finished" either.
Thank you for writing this article. I'm an iOS/Backend developer looking to do some lightweight front-end programming, and whenever I look at the JS landscape I shudder. Nearly every suggestion from JS developers is on the line "Have you tried "React/Angular/Ember/ObscureJS?". The Grunt/Gulp/Yeoman/Bower/Npm/Batman.js etc toolchain makes me question my sanity. Is it so difficult to just use Plain Old JavaScript™ and…
Pick one. Yes, you will pick the wrong one. That's okay. It will always turn out to be the wrong one eventually (if only because your requirements will change).
Don't obsess with what's hot. Figure out why it's hot, and what makes it different than the thing that was hot the previous week. If there's no sufficiently discernible difference you can probably afford not to pay attention to it until it pops up again.
The frontend ecosystem is in constant flux because the frontend platform is in constant flux. HTML has stopped using version numbers. JS itself has transitioned to yearly releases. CSS has fragmented into dozens of separately versioned specs.
That's just the way it is.