Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Wow. Do people consider this kind of coding acceptable now? We spent decades trying to separate templates, business logic, and inlined JS, and you managed to cram all three into a short snippet.


Yes and this is a tired argument by now. The talk by Pete Hunt aptly titled "React: Rethinking best practices"[0] given in 2013 points out how separating templates and logic is merely a separation of technologies, not concerns.

[0]: https://www.youtube.com/watch?v=x7cQ3mrcKaY


Thanks for posting this, it was really interesting. Everyone who criticizes JSX should have watched it before doing so.


Whether to show a logout link or a login form is presentation logic, not business logic.

I've spent decades telling people that trying to keep logic out of templates is a waste of time. A useful templating language has variables, conditionals, and even functions. There's no reason not to use a real programming language.

There's no good automated way to enforce MVC. How is an automated tool going to know whether "show this number to two decimal places" is a model thing (inherent precision of the data) or a view thing (presentation choice)?


>> Whether to show a logout link or a login form is presentation logic, not business logic.

I would prefer keeping presentation logic, or any logic for that matter, out of the HTML.


It's actually no different to any other templating solution. Take a look at this[1] Mustache.js example and note the logic! At least JSX is honest about what it is.

[1]: https://news.ycombinator.com/item?id=13153298


I guess honest can be a nice way of saying more verbose, just like elegant is another way of saying more terse and simple for those who get it


Agree. Looks like those who haven't suffered from it, can't live without this suffer. They just need to have this experience to be able to understand downsides.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: