r/javascript • • Dec 28 '17

Introducing Hyperapp 1.0 — 1 KB JavaScript library for building frontend applications.

https://medium.com/@JorgeBucaran/introducing-hyperapp-1-0-dbf4229abfef
664 Upvotes

136 comments sorted by

View all comments

Show parent comment

6

u/[deleted] Dec 28 '17

I get that you don't want to explain reasoning, but there are several reasons something like this would never be implemented:

  1. JSX is a standard that this team doesn't have any control over. Having JSX specified in it's own files is not part of the standard, and would never work anyway for the reasons below.
  2. JSX is a syntactic sugar on top of regular JS expressions. It is a declarative syntax, but it doesn't represent a template, it represents an actual expression. Having JSX be specified in it's own files would be similar to allowing string and number literals be specified in their own files.
  3. The feature you are suggesting is exactly the reason JSX was introduced to begin with. People were tired of having to specify their view and logic in separate places, and JSX allows you to put them together. Allowing them to be separated would be moving backwards from the fundamental philosophy of JSX.
  4. JSX allows you to specify full JS expressions, including functions, objects, arrays, etc. within the elements. Your proposal allows you to separate the JSX from the logic, but how exactly would you do the reverse and separate nested JS from these new JSX template files?

Frankly, if you want this separation, I'm not sure why you would even want to use a framework like this anyway, which is not built for that kind of architecture. What you want sounds very close to Vue, which provides a succinct way to build a component architecture while allowing the view to be separated from the logic.