← Back to context

Comment by zarzavat

4 months ago

I love JSX and hate HTML template syntax, so there's at least one person.

What I like about JSX is that you can reuse all of the control flow primitives from JS. You have if, for, map, filter, flatMap, etc. if you want a new combinator, just write a function as you would for any other type of data transformation.

I consider this one of the biggest advantages of React compared to the approach of having separate templating and scripting languages.

For me it is the opposite. I dislike having imperative constructs pollute my otherwise declarative markup. To each their own I guess.

  • Don't you still have imperative constructs if you use Svelte? It's not like any web framework can remove the need to render things conditionally.

    If you have `{#if cond}`, that's imperative programming, not declarative, it's just imperative programming using a different syntax.

    Using a different syntax for a conditional/loop depending on the type of the data is odd when you think about it. Why should vnodes use one syntax and every other data type use another syntax?

    I will grant that the C ?: ternary operator syntax is ugly. If C had had expression based if/else like Rust then maybe people wouldn't mind JSX so much.

    • Absolutely, and that's one of the reasons that, as much as I was enthusiastic about svelte, it still didn't quite hit the spot. Close but not quite there yet. It's neither html nor js. Still a bit confusing.