Hacker News new | ask | show | jobs
by jhall1468 3939 days ago
It's only easier to read because it meets your expectations since it looks "javascripty", but absolutely not as easy to reason about.

Both of those snippets are intended to generate HTML. In that sense there's no question which one is easier to reason about/read.

2 comments

Not easier to reason about?

I would argue the opposite — it is immediately easier to reason about, since I see what functions are called, and I can go look up the documentations for those functions without having to go through a precompile-step.

Yes and additionally (with Chrome's DevTools) you get out-of-the-box functionality like the ability to set a break point, live edit your code right at the breakpoint, and save your change right back to the filesystem. With transpiled languages this kind of workflow is generally less streamlined -- I don't know why more people don't complain about it. The best alternatives I've seen are when people completely reengineer the workflow - I'm thinking about the Elm debugger as an example.
Thanks - I hadn't even thought about that aspect, but it's definitely a problem I would run into. As popular as React is though, I'd assume there is a browser extension or something to support the workflow.
It really depends on what you're used to.