cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.46k stars 160 forks source link

Any plans to support JSX syntax? #102

Closed peisenmann closed 8 years ago

peisenmann commented 8 years ago

Related to https://github.com/cincheo/jsweet/issues/59 Are there any plans to support JSX syntax? I skimmed the docs and don't see any way that I could plug in anything to the transpiler itself like additional syntax (Maybe possible with Candies, but I didn't see a way).

Just curious if JSX support (or more remotely transpiler plugins so myself or someone else can write my own JSX support) is on the roadmap at all.

renaudpawlak commented 8 years ago

I will look at it when dealing with #59.

lgrignon commented 8 years ago

Seems complicated to me. TypeScript brought this due to the React's popularity but the TypeScript team is able to change their language's syntax at any time, which is is not the case of JSweet, which sticks to Java syntax. Unfortunately we can't enrich java syntax even if we need to.

lgrignon commented 8 years ago

That being said, it would be possible to simulate JSX in java through a library but I think you'd miss the point of JSX.

We will, anyway, take a better look at it.

peisenmann commented 8 years ago

@lgrignon I intuitively feel like the JSX syntax is not a good fit for JSweet directly for the reason you listed "It's not valid Java syntax". I'm not sure, however, if there were to be some kind of hooks into the transpilation process where a plugin could be turned on to handle that. That opens two obvious rabbit holes that I can see: 1) You're now talking about having plugins and potentially a plugin ecosystem (I don't think there are transpiler plugins yet in JSweet) and 2) Anything that offers additional non-Java syntax may muddy the waters of the purpose of JSweet.

JSX isn't critical to my use case. I don't know if the ability to write JSX (or anything a transpiler plugin might eventually support) would be a draw for other users of JSweet or not, either. Just thought it was worth mentioning while we the topic of React candies were being discussed.

renaudpawlak commented 8 years ago

Clearly JSX is not the main purpose of JSweet and is not a priority right now. However, it does not mean that some similar solutions cannot be found by thinking "out of the box". I am thinking for example about this cool trick to "simulate" HTML in Java syntax: http://benjiweber.co.uk/blog/2015/08/21/html-in-java/. But it would not be part of JSweet core for now. Maybe a side project if someone wants to give it a try...