Hacker News new | ask | show | jobs
by torginus 1367 days ago
>A templating language is mainly an inner platform effect. It targets a weird imagined archetype of someone who isn't allergic to code, but somehow isn't smart enough to work in a genuine programming language. In

Strange sentiment. Isn't React templating as well? Besides one of the most famous use of templates is macros (in C as well as other languages). Would people who generate code be allergic to coding?

1 comments

> Isn't React templating as well?

Nope! You can make React apps with just a plain ol' JS file (and doing so is frankly instructive). Most folk add in JSX for extra syntactic sugar tho, so the confusion with templating is understandable.

You can, but who does?
I think the point is that React is a true programming language with syntactic sugar to make it look templates, vs templates that bolt on some language.
React is just JS as any other app using JS with templating. I really fail to see the benefit with the React approach. If anything it makes it more difficult to have a 100% match between design and the end product.
How much React have you written? Because React is just JavaScript, you can take traditional programming patterns and apply them to your UI, for example higher-order components. You can't do this with templating.
Hm, can you describe what do you mean by "can't do this with templating"?

Do you mean that since React/JSX kind of a superset of JS you can do higher order stuff in it, whereas in a simple templating language like Jinja2 you can't?

Isn't that a false equivalence? I mean I regularly use patterns similar to HOCs in Angular. It's easy to wrap components[0] and it's just as possible to project components into other components programmatically[1] with complete dynamism.

[0] depending on the use case there are different preferred ways: directives, which have access to the wrapped component and its template, and can interact with it in many ways, or you can do it from raw TS ( https://github.com/abumuawiyah/ng-ivy/blob/master/src/app/ap... see the withTheme and withStyles functions )

[1] for simple things https://blog.angular-university.io/angular-ng-template-ng-co... ... see also the official working example from the docs https://stackblitz.com/edit/angular-568wsw?file=src/app/ad.s...

People who use it from ClojureScript, for one. Due to the nicer Clojure syntax you don't need a templating language, just a data convention (hiccup in this case).

For those of us who hope JS will slowly become just a compile target, a downside of of JSX is that it's tooling is JS specific, and the syntax is tailored to JS. So it's great that React isn't married to JSX.

I wrote a GUI framework that uses React API directly.

It's more proof of concept than useable, the idea is that we don't actually have to write layouts, we can just describe the layout with code or a template language and let the computer work it out.

https://github.com/samsquire/additive-guis

Yeah strangely it compiles to functions but they way they compose is not the way we compose function. Practically it's a template, compose via component mechanism. If it's a language it should be like Elm where attributes and children are also List and have return type, can be programed in function style.