4 ms·
I agree with your first sentence. We can agree to disagree on the second, though, as I thoroughly prefer a template approach.
by holtalanm 6y ago
I agree with your first sentence. We can agree to disagree on the second, though, as I thoroughly prefer a template approach.
- kingdomcome50 6y agoCould you elaborate a bit more? I’m honestly curious.
- holtalanm 6y agoJSX vs Templates has almost evolved into a holy war at this point within the js community. There are benefits and drawbacks to both, so you'll find people coming down on either side of the argument. My main reason for preferring templates over jsx is that it allows to separate the functional component code behind the scenes from the actual rendered html in a cleaner fashion, imo, than just embedding the html directly into the JS code. I could also say that, due to my background, I am just more comfortable with it, as well.
- adrianhel 6y agoAnd to elaborate on the other side of the argument: JSX creates plain JavaScript objects instead of exposing an "almost-JS" templating language. Additionally you get an enormous amount of flexibility. For some types of apps that is very important.
- holtalanm 6y ago>> exposing an "almost-JS" templating language I'm not certain I would call Vue.js templates as an 'almost-JS' templating language. It is pure html. A browser could render it without any js backing it up. I can't speak for many other template specs, but I believe Angular.js was just pure html, as well, using custom properties to perform the binding between the html and the backing js, which is very similar to what Vue.js does, in that aspect at least.
- CraftThatBlock 6y agoI should have said that it's the best in my opinion. I think people from different backgrounds do prefer different methods, for example Vue seems very popular with PHP.
- holtalanm 6y agoI came from a java background. Company I started at used an old templating approach using freemarker, and you could say it just stuck with me. I'm not 100% opposed to JSX, and I think it has its uses, but I prefer to keep the rendering layer separate from the functional code behind the component. I'll grant that a lot of frameworks like Angular.js and Vue tend to blur those lines a little bit with their approach due to directives, but in the end, it is still html, at least, and I like that kind of simplicity.