3 ms·
My comment was in response to "JSX with TypeScript" being a great feature of React. We may debate whether it's actually great, but this feature is accidental, t
by hbrn 4y ago
My comment was in response to "JSX with TypeScript" being a great feature of React. We may debate whether it's actually great, but this feature is accidental, there was no foresight.
Facebook was using React in 2011, TypeScript was released in 2012 (and it's not like it was immediately adopted).
- WorldMaker 4y agoFacebook was using Flow at the time and even though they couldn't have predicted the convergent evolution that produced Typescript nor the tide winds that would have pushed Typescript to prominence over Flow, they still designed JSX for static types from the beginning. Even the predecessor tech I mentioned E4X, which were the XML extensions to ECMAScript 4, the "lost" JavaScript version, were built on static typing. The most controversial feature that killed ES4 was static type hints. ES4 never directly showed up in browser support, but it did impact web development as ActionScript inside Flash and ES4 had influence on Typescript's syntax. (In some fun ways JSX with Typescript is almost a "Revenge of ES4". It's a lot better than what ES4 would have been, but it's so heavily influenced by ES4 there's a family resemblance and clues that language design is always more evolutionary than revolutionary.) (Not to mention that the functional programming languages like OCaml and Haskell which inspired the "MVU" patterns are all about strong static typing.)
- hbrn 4y agoFlow "early version" (0.1.0) was released in 2014. Now there's a chance that they had another version used internally at least 3 years prior, but at this point we're just speculating. But IIRC nothing in React docs at the time mentioned how great JSX is with static types. It was all about render functions. For now I'm sticking to Occam's Razor and the idea that JSX was a hack to make render functions usable.
- addicted 4y agoJSX being more easily typed is not a coincidence though. React was not built with JSX in mind. React was built with JavaScript in mind. JSX was simply syntactic sugar. In fact, JSX was entirely optional at the beginning and all the initial React documentation had examples with and without JSX. https://web.archive.org/web/20131118055243/http://facebook.github.io/react/blog/2013/06/05/why-react.html https://web.archive.org/web/20131118055243/http://facebook.g... The key point is that JSX being syntactical sugar on top of a system designed to return JavaScript is what makes it work so well with Typescript and Flow. The key insight here was that components should be described using JS and not HTML. JSX was invented as syntactic sugar to make this more palatable for scores of web devs who had only used HTML. It is this decision to settle on JS vs HTML that directly led to JSX fitting in so nicely with Flow and TS since those are designed with JS in mind.