Hacker News new | ask | show | jobs
by xixixao 3409 days ago
I'd say the problem isn't "this is not JSX", but that the syntax just looks awful:

     div []
        [ div [] [ button [ onClick Increment ] [ text "+" ] ]
        , div [] [ text <| toString model.counter ]
        , div [] [ button [ onClick Decrement ] [ text "-" ] ]
        ]
JSX isn't the only syntax that took off, there are for example indentation based syntaxes for HTML, theoretically:

    div
      div
        button onClick: Increment
          text "+"
      div
        text <| toString model.counter
      div
        button onClick: Decrement
          text "-"
already much nicer (and if it was all wrapped in parens it wouldn't make much of a difference).

Given that Elm is "just" for making HTML apps, this does seem like something the language should focus on.

1 comments

Your syntax only looks good in hello-world examples and will stumble upon the same sort of ambiguities that things like coffeescript grappled with.

It turns out that it's less work to always have delimiters than it will be to have to add them anyways to disambiguate.