4 ms·
I agree, and I think ES5 even has a benefit as a language: it's extremely simple. The trajectory of ES2015 seems to be, basically: add as much cool stuff as pos
by mbrock 11y ago
I agree, and I think ES5 even has a benefit as a language: it's extremely simple. The trajectory of ES2015 seems to be, basically: add as much cool stuff as possible. Thus increasing the syntactic surface area, and the amount of stuff to learn.
With a slightly more clever and more concise definition of `createElement`, I also have no need for JSX.
tag("div.widget.fancy", {}, [
tag("h1#title", {}, "Hello, world!")
])
I'm fine with that. My editor understands the indentation.
And... such an enormous benefit... there is no compilation step.
Right now at work, our code base takes 20 seconds to compile with Babel. Enough said.
The feeling, after being used to all this transpilation business, of writing code that's just already ready to serve, is very nice. I can even work on it with nothing but a text editor and a web browser.
Unfortunately everyone thinks I am crazy for preferring this.
- endemic 11y agoI've started going back to straight ES5 for my side projects. It removes the annoying "compile" step, which I find pretty dumb for an interpreted language. For deployment, of course, I concat and minify. But the speed with which I can iterate using vanilla Javascript is refreshing in this day and age.
- mbrock 11y agoI would be interested in a compilation step if it gives me something like PureScript, that is, real, serious benefits from the compiler: algebraic data types, type checking, type classes, and so on. But ES2015 is just a bunch of syntax sugar. Nice syntax sugar, but still. Okay, async/await is significantly useful... but you still have to understand how the promises work under the hood... and I can live with raw promise coding.
- bhauer 11y agoThat looks a lot like the element builder function that Fastmail put together back in 2012. https://blog.fastmail.com/2012/02/20/building-the-new-ajax-mail-ui-part-2-better-than-templates-building-highly-dynamic-web-pages/ https://blog.fastmail.com/2012/02/20/building-the-new-ajax-m... I too am fond of that approach.
- mbrock 11y agoYeah, same idea. The dream that designers, being comfortable with HTML, would be able to mess around with JSX is, as far as I can tell, unrealistic anyway, because it's always full of React-specific weird stuff that the designer doesn't understand and doesn't want to mess with.
- WickyNilliams 11y agoYou should separate your Presentational and Container components [0]. Presentational components can be pure and stateless, containing no/minimal React-specific weird stuff - that should go into the Containers. [0] https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0 https://medium.com/@dan_abramov/smart-and-dumb-components-7c...
- spb 11y agoThis is basically exactly how my function "cre" works (except you can omit the empty attribute object): https://github.com/stuartpb/cre https://github.com/stuartpb/cre
- ENGNR 11y agoI've been avoiding the compile step too just for simplicity. But have you found sensible ways to test without them?
- mbrock 11y agoWhat's the problem with testing, you mean? Sure, I've done plenty of testing of ES5 code without transpilers.
- Scarbutt 11y agoduring development, doesn't react with addons allows to use JSX without pulling in any tooling or additional dependencies?
- guscost 11y agoNope, you're not crazy. I'm doing the same thing at work (but have looked into setting up TSX in the future).