The Zen of React

submited by
Style Pass
2022-09-21 13:00:09

I am writing a series of posts about React: why it’s great, why hooks are great, and then maybe what all is wrong with it and what can be done.

HTML has a certain elegance to it (except for that doSomething() bit), which is that you pretty much write exactly what you want to see on the page. The syntax is cludgy, and the output looks like crap by default, but it’s what you asked for: in this case, a document which contains some text, a button, and a label.

HTML is wonderfully direct because it’s declarative. That’s because there is no mechanism in plain HTML code for running arbitrary functions and loops and whatnot, in which it would get to do anything under the sun to produce its output. This is a tradeoff, of course: is it better to use a more expressive language that can do everything you need, or to use a simple declarative one that does what it says, but then have to build a whole ecosystem in other languages around it? Well, it doesn’t matter, because in 2022 we’re stuck with the latter for the foreseeable future.

Note that HTML did not need to have an XML-based syntax to be declarative. We could just as easily have built the whole web on a language that uses a function-call syntax based on Javascript:

Leave a Comment