4 ms·
The big shift has been from managing complexity to avoiding it where possible, encapsulating it when not. In my current favorite webstack, every logical view is
by ng12 10y ago
The big shift has been from managing complexity to avoiding it where possible, encapsulating it when not. In my current favorite webstack, every logical view is abstracted behind an API (which happens to be a React Component). Internally, everything about that component is encapsulated -- the internal implementation, the sub-components, even the CSS thanks to CSS Modules. In fact, if I really had a reason to write a specific component in Angular or jQuery I would be able to: it's easy to embed non-React code inside React, and as long as it exposes a top-level React Component I'm hunky dory. I refer to React because that's my library of choice -- but you can say similar things about Angular and Aurelia.
This has only been something we've gotten right over the last few years. jQuery trampled all over the DOM, data-binding heavy frameworks like Backbone were impossible to reason about, Closure Library turned your Javascript into Java-flavored spaghetti, Coffeescript was basically Perl, and CSS was global by default. Now React lets me write perfectly performant abstractable code. Redux lets me manage state in a functional, reproducible way. Webpack supports CSS modules which let me write sane styles and code-splitting so I don't need to worry about managing resources. Typescript lets me write code that's safe and easy for others to consume. ES6 modules allow me to actually architect my codebase without shoving everything onto window. And the ringer is I'm not married to any of these technologies -- I can scalp out Redux for another data store, Typescript for Babel, go back to global CSS, etc.
Writing UI code is hard, and I'm not sure why some HN folks assume web developers are ignorant. Web apps are a HUGE hack, and it's funny to me that a forum dedicated to hackers has so many who shun it for that reason. It's not "flavor-of-the-month", it's finally making progress towards a really hard problem in really exciting ways.
- flukus 10y ago> Writing UI code is hard, and I'm not sure why some HN folks assume web developers are ignorant. Probably because every feature you listed was achievable before react.
- gaastonsr 10y agoI just want to hear your answer with one of those... How did you do type checking before TypeScript (or the like) in JS? give me a real answer.......
- flukus 10y agoI didn't, and you didn't mention type checking above. One very common way though was to avoid the need for it altogether in javascript, by rendering html on the server.
- ng12 10y agoThat's a different poster, and I did mention it above. What does server-side rendering have to do with Typescript? Are you advocating avoiding javascript all together?
- flukus 10y agoSorry, I missed that, I was replying to the parent comment only. But yes, I do advocate avoiding javascript altogether whenever possible (which is more often than current trends). There were a number of other transpilers too, all of which were a pain and I don't see how typescript is going to improve on that.
- ng12 10y agoI actually regret writing out such a detailed reply. Congratulations, you're a top HN troll.
- gaastonsr 10y agoGreat answer. Sometimes I hate HN for people like above.
- gaius 10y agoWriting UI code is hard, and I'm not sure why some HN folks assume web developers are ignorant. But it really isn't and the proof is HyperCard from the 1980s. It's only hard because you have made it hard, for no reason that anyone can fathom (apart perhaps from job security).
- ng12 10y agoI'm very curious what kind of web apps you think people are building. HyperCard was great for demoware -- and if you were to try and make it into a real production-ready tool you'd get VBA. Do you really think everybody -- from Android/iOS to Swing to qt to Web 2.0 -- just had no idea what they were doing?