Hacker News new | ask | show | jobs
by wrren 3072 days ago
I like the syntax, but I have to say that I prefer JSX. The real advantage of JSX is that it's very similar to HTML and developers have been reading, mentally modeling and reasoning about HTML -> DOM translation for decades.
4 comments

I like to write my apps with one language where possible. I find the switch in context to much of an overhead.. but I am aware this is personal preference. Use what makes you happy :) it all gets compiled to vdom trees anyway!
That's the disadvantage, too: you gotta use html! Where are the lispers to talk about how much better sexps are?

Even with decades of knowledge, I think you'll find that devs can transition to the non-html model really, really quickly, and then it's nice because everything is a single uniform language.

> Where are the lispers to talk about how much better sexps are?

Well... there is the OP...

The real problem with JSX is that it's almost HTML, but not quite, so you constantly have to fight against your assumptions about how it should work.

At least JS is really just JS, and developers have been reading, mentally modeling and reasoning about JS -> execution translation for decades.

For an alternative to JSX that's actually real HTML, but also real JS and requires no compiler, checkout lit-html: https://github.com/Polymer/lit-html

It lets you write HTML templates as JS template literals:

    let post = (title, body) => html`
      <h1>${title}</h1>
      <div>${body></div>`;
But unlike using innerHTML, it stamps DOM from <template> elements, and only updates parts that change, actually doing less work than VDOMs.

Lots of editors have automatic support for inline HTML tagged with a tag named "html", so you'll get syntax highlighting in say, Atom. And VS Code has a plugin that adds intellisense.

JSX got closer to just HTML recently, now that you can specify HTML attributes in addition to DOM properties.
To be fair, you could say the same thing about Markdown. And yet here we are.
What is the link between the two? Markdown does not really look or works "like" HTML, it just happens to compile to it.
Again just being pedantic here. This thing doesn’t look or work like HTML, but it does happen to compile to it too. I find Markdown way easier to read than HTML, and I read both all day long. Maybe having two decades of experience reading HTML Zoe whatever isn’t enough to offset the superiority of this format? (No idea. I dislike JSX, and I don’t think this is actually more readable beyond cute little examples, but I might be wrong.)
All I can say is readability is subjective. Hiccup is used quite extensively with Clojure/ClojureScript. Clojure for HTML rendering and ClojureScript as an alternative to JSX for Reagent. For people that enjoy Lisps I think it's probably great, for people that don't maybe not so much.

I definitely like the lower density of text that an absence of end-tags provides.