News for hackers. Stuff that matters.
Re:Exact – a new cross platform UI framework by the Expo team by halflife on Tuesday November 10, 2026 @12:43AM (#50436526)
JSX is terrible because of 2 shortcomings-

1 - all logic needs to be written in 1 statement. That forces you to use nested ternaries, nullish operators, and array fns where simple workflow controls would read much better.

2 - it’s designed to render html but conflicts with JS and TS, so you can’t have a class attribute, and weird escape hatches around generic fns.

Re:Exact – a new cross platform UI framework by the Expo team by satvikpendem on Tuesday November 10, 2026 @01:53AM (#50436931)
For 1, you're supposed to break up more complex logic like that into functions and variables, so that acts as a forcing function which works as intended. For 2, 99% of HTML is just fine, just className would be different but it's not a big deal in practice.
Re:Exact – a new cross platform UI framework by the Expo team by halflife on Tuesday November 10, 2026 @05:22AM (#50438289)
I’m not talking about complex logic. Because simple conditions, iteration or switch statements are not supported with classic control flow.
Re:Exact – a new cross platform UI framework by the Expo team by satvikpendem on Wednesday November 11, 2026 @07:36AM (#50452690)
That's complex logic. You shouldn't be switching on the UI layer like that.
Re:Exact – a new cross platform UI framework by the Expo team by troupo on Tuesday November 10, 2026 @02:02AM (#50436994)
> so you can’t have a class attribute

Because it's a thin wrapper directly translatable into a JS function call. `className` is JS

Re:Exact – a new cross platform UI framework by the Expo team by ricardobeat on Tuesday November 10, 2026 @04:48AM (#50438058)
`class` is a valid property name in JS, since ES5 (2009).

React opted for backwards compatibility at the time it came out, and never made the upgrade - you can write `class` in Preact.

Re:Exact – a new cross platform UI framework by the Expo team by troupo on Tuesday November 10, 2026 @06:15AM (#50438706)
> React opted for backwards compatibility

I think they opted for what these properties are actually called in Javascript: https://developer.mozilla.org/en-US/docs/Web/API/Element/cla...

I wish they'd stick with that for all properties though.

Re:Exact – a new cross platform UI framework by the Expo team by ricardobeat on Tuesday November 10, 2026 @06:23AM (#50438784)
The rationale was to follow the DOM property names to avoid clashing with reserved keywords; not because mirroring JS was the goal. Data attributes for example have always been data-*, readonly, contenteditable in lowercase, mirroring HTML.
Re:Exact – a new cross platform UI framework by the Expo team by troupo on Tuesday November 10, 2026 @09:28AM (#50440884)
That is probably my bias showing, because I'd rather they adipted the JS property names for everything :) Less confusion
Re:Exact – a new cross platform UI framework by the Expo team by halflife on Tuesday November 10, 2026 @05:24AM (#50438307)
I know WHY it’s not possible, but that’s a design limitation of the parser being templating on top of JS, instead of a separate DSL with escape hatches for JS, like most other templating engines
Re:Exact – a new cross platform UI framework by the Expo team by troupo on Tuesday November 10, 2026 @06:13AM (#50438684)
It's not really a design limitation, as this way it simplifies the parser, the DSL, the templating... Basically everything. And your entire templating/parsing could be just "convert this to a function call"
Re:Exact – a new cross platform UI framework by the Expo team by halflife on Tuesday November 10, 2026 @08:31AM (#50440042)
Yes, it simplifies the engine, at the cost of developer experience. Like useMemo, that now is compiled in automatically with the new react compiler.
Re:Exact – a new cross platform UI framework by the Expo team by troupo on Tuesday November 10, 2026 @09:27AM (#50440878)
> Yes, it simplifies the engine, at the cost of developer experience.

Given that its taken the world by fire and nearly everyone adopted JSX/TSX as the templating language, doesn't seem like developer experience suffered.

> Like useMemo, that now is compiled in automatically

A completely different beast, and this one definitely makes DX suffer.

Re:Exact – a new cross platform UI framework by the Expo team by halflife on Tuesday November 10, 2026 @01:24PM (#50444157)
There are many reasons why JSX is popular, react being the biggest one, where subsequent frameworks wanted to leverage people’s knowledge.

However angular, svelte, vue and more have a specific DSL for templating.

Re:Exact – a new cross platform UI framework by the Expo team by whilenot-dev on Tuesday November 10, 2026 @02:13AM (#50437069)
If I understand you correctly, #1 is just plain wrong. JSX is transformed into standard ECMAScript. You can store JSX-nodes in variables and pass them around however you like.

  // this
  <Box>
    {
      shouldShowAnswer(user)
        ? <Answer value={false}>no</Answer>
        : <Box.Comment>
            Text Content
          </Box.Comment>
    }
  </Box>

  // ...can be written like this
  const answer = (
    <Answer value={false}>
      no
    </Answer>
  );
  const comment = (
    <Box.Comment>
      Text Content
    </Box.Comment>
  );
  const result = shouldShowAnswer(user) ? answer : comment;

  <Box>
    {result}
  </Box>
In React at least, null won't render anything.

#2 is a known trade-off, and so marginal and well known that it's almost not worth mentioning it.

Re:Exact – a new cross platform UI framework by the Expo team by halflife on Tuesday November 10, 2026 @05:19AM (#50438266)
It’s not wrong, this is a limitation of JSX, every interpolation needs to be a statement.

Ofcourse you can split every control flow into separate component and combine them together finally, but that means exactly that - that every minute condition or iteration is deferred elsewhere. And it makes the actual render result hard to understand.

Re:Exact – a new cross platform UI framework by the Expo team by whilenot-dev on Tuesday November 10, 2026 @06:36AM (#50438880)
At this point I honestly don't know what you're on about...

> every interpolation needs to be a statement

Interpolation??? JSX extends the PrimaryExpression in the ECMAScript grammar. So yeah, every JSX element/fragment is an expression, not a statement. You can't seriously consider an ECMAScript expression a limitation?

> you can split control flow into separate component[s]

You do realize that none of the variables in the example above are components, do you? They are the result of JSX elements, and if we're talking React they'd be React elements.

> combine them together [...] makes the actual render result hard to understand

So, for you, a long ECMAScript expression is a limiting factor, but composing shorter, simpler expressions into a longer, more complex one is hard to understand. Even though in your comment above you wrote:

> simple workflow controls would read much better

What's your alternative?

Re:Exact – a new cross platform UI framework by the Expo team by halflife on Tuesday November 10, 2026 @08:46AM (#50440278)
I may have mixed between expression and statement, however in JSX {} must return exactly 1 expression, so that limits the amount of code you can place there.

Your'e missing the point arguing about semantics of components or JSX elements, the point is that if you want to avoid control flow via expressions, you must destruct you template (however simple it may be) into tiny template fragments that makes it harder to understand the complete rendered picture.

Imaging if JSX could look like this:

  <div class="container">
    My list
    @for(item in list) {
      <h2>{item.name}</h2>
      @if(item.loading){
        <p>Loading...</p>
      } @else if (item.error) {
        <p>Error loading item</p> 
      } @else {
        <p>{item.description}</p>
      }
    }
   </div>
This is much easier than the suggested JSX approach:

  const renderItem = (item) => {
    if(item.loading){
      return <p>Loading...</p>
    } else if (item.error) {
     return <p>Error loading item</p>
    }
    return <p>{item.description}</p>
   }

  const renderList = (list) => {
    return list.map(item => {
     return <>
      <h2>{item.name}</h2>
      {renderItem(item)}
     </>
    })
   }
  
  return <div class="container">
    My list
    {renderList(list)}
   </div>
Re:Exact – a new cross platform UI framework by the Expo team by whilenot-dev on Tuesday November 10, 2026 @11:00AM (#50442213)
EMCAScripts statements are enough, no need to redefine them in JSX.

  <div class="container">
    My list
    {
      list.map((item) => {
        let content = null;
        if (item.loading) {
          content = <p>Loading...</p>;
        } else if (item.error) {
          content = <p>Error loading item</p>;
        } else {
          content = <p>{item.description}</p>;
        }

        return (
          <>
            <h2>{item.name}</h2>
            {content}
          </>
        );
      })
    }
  </div>
VS

  <div class="container">
    My list
    @for(item in list) {
      <h2>{item.name}</h2>
      @if(item.loading){
        <p>Loading...</p>
      } @else if (item.error) {
        <p>Error loading item</p> 
      } @else {
        <p>{item.description}</p>
      }
    }
   </div>
I still don't see any limitation.
Re:Exact – a new cross platform UI framework by the Expo team by halflife on Tuesday November 10, 2026 @01:20PM (#50444100)
In my suggestion I demonstrated a theoretical approach to how I think JSX shouldve been done.

JSX eventually is not a templating engine, it’s just sugar over createComponent/createElement functions, and thats its downside, we are creating html components that need templates to render.