Marco's Blog

All content strictly personal opinions.
en eo

PIcking Your Javascript Mobile Framework: Part 18 React

2014-11-18 3 min read Comparisons marco

There really isn’t a whole lot making React stand out in a positive way in this comparison. Both performance and code length are towards the maximum acceptable, and the framework comes with its own language you have to learn, JSX.

I’ll spare you the internals of JSX. Let’s just say it’s Javascript made to use XML syntax. I guess you can get the hang of it, and maybe Mithril’s Hoarie should have a glance, but all in all you really have to be hardcore if you accept learning a new language (however little it is different from Javascript) just to code in a new framework.

Especially because that doesn’t really buy you anything. You get a hybrid between two languages with incompatible syntax – like writing Java code mixed with Python – just “because it is a concise and familiar syntax for defining tree structures with attributes.

To be fair, JSX is just optional, not mandatory. So what other benefits does React offer, if we want to count JSX as a benefit? According the home page, the key benefits are that it’s Declarative and Simple. Like, I don’t know, all the other frameworks in this comparison.

Frankly, the main reason to use React is because someone tells you to. It’s a Facebook project, which means it gets lots of love and ongoing development. It’s also very popular on StackOverflow, despite being only a little older than a year.

React has definitely had a disproportionate impact, considering how new it is. It does remind me, though, of the interminable list of pet projects that were floating around at Yahoo! when I worked there: it seems to be something born out of enthusiasm and the desire to do something new more than because all available options were unacceptable. Also, it seems to touch on an internal workflow more than on general conditions of the marketplace.

As far as the Todo example goes, a quick glance at the index.html file reveals that much of the slowness comes from not using Require. Indeed, not even the default compilation of JSX files into pure Javascript is handled. Well, in that case we have to give React the benefit of the doubt: it might be much faster in optimized use than it is in the demo.

The code is organized as usual. There is an app.jsx, a JSX file for the footer, and models for the todo item. There is also a utilities file, just because the JSX processor wants something extra to do.

I repeat, I am not sure who React is for. It seems to find improbable solutions to problems already solved a year before it came into being. At least, though, it relies on a company that has been pretty consistent with its APIs and its support for its APIs. That gives it the edge over the little projects, always on the verge of losing their drive, and those that come from overstretched companies.