Live data from Hacker News

JavaScript once had a JSX-like syntax called E4X

developer.mozilla.org

21–30 of 50 posts

Re: JavaScript once had a JSX-like syntax called E4X

#21
post #6

E4X was part of Actionscript 3. It was very nice.

I always found it a little odd but quite pleasant - but I don't at all remember AS3's E4X having interpolation. Did I just never know about this feature (or have since forgotten - it's been, oh, half a decade at least since I've used ActionScript 3 in anger), or was it missing?

It existed in AS3 too. Wasn't widely known to my knowledge though.

Re: JavaScript once had a JSX-like syntax called E4X

#22
post #11

Earlier quoted context omitted.

How would that work in practice, though? Using Babel JSX gets compiled to React.createElement('div', null, {}). You can configure babel to output something else if you use something other than React. So what would a standardized JSX syntax output? It can't be document.createElement since that is a web API and not a generic JS API. So what would it do, exactly?

I've written an in depth blog post on "generic jsx", which turns JSX into function bind/currying syntax that would work fine in any framework (or not framework at all, as we currently use it). http://tolmasky.com/2016/03/24/generalizing-jsx/ We use this generic-jsx in DemoKit: https://github.com/runkitdev/demokit , and it's really cool because you can do fancy stuff like: // Curry your JSX tags! const wordmark = ; ..…

That would be actually super useful. JSX became for me the best part after writing React applications for quite a while. Performance-wise not using React is actually faster ^^ (If you take care of the dirty updating work of course)

6 years ago I wrote a proof of concept to replace a large Rails application in pure JS using prototypes and constructing the html from strings. The latter turned out to be the most messy part so I stopped that and rather refactored the legacy Rails code to do something useful.

Could be really great for super lightweight JS apps!

Re: JavaScript once had a JSX-like syntax called E4X

#23
One bit of E4X trivia: a bug in the Firefox E4X implementation was taken advantage of by an exploit called "EgotisticalGiraffe", according to the Snowden documents. The implementation of E4X in Firefox was large and complex.

https://www.schneier.com/blog/archives/2013/10/how_the_nsa_a...

Re: JavaScript once had a JSX-like syntax called E4X

#25
post #8

Would be nice to see JSX syntax become standardized. Clearly lots of people like it.

Note that there is a formal specification for JSX: https://facebook.github.io/jsx/ This has been helpful to make sure that all the tooling around JavaScript can work with JSX.

Re: JavaScript once had a JSX-like syntax called E4X

#26

Earlier quoted context omitted.

I always found it a little odd but quite pleasant - but I don't at all remember AS3's E4X having interpolation. Did I just never know about this feature (or have since forgotten - it's been, oh, half a decade at least since I've used ActionScript 3 in anger), or was it missing?

It existed in AS3 too. Wasn't widely known to my knowledge though.

Thank you - confirmed. I just dug up a copy of Flash CS6 and tried this:

  var val : String = "foo";
  var foo : XML = ;
...and it worked. I swear this wasn't documented anywhere. That said, I just googled a few Flex examples (I never used Flex) and it seems to be common there, so I guess that explains why at least someone knew it existed!

Re: JavaScript once had a JSX-like syntax called E4X

#27

In 2008 I built a production website in Helma (server side JavaScript framework running on Rhino, JS on the JVM) with E4X for the view. You could say I've been waiting for React for a long time. Also that I used way-too-niche technology for a one-off project. :-/

Avantgarde rather than niche I'd say.

Helma, v8cgi and co. pioneered server-side JavaScript and around 2010 inspired CommonJS for portability, which Node.js became the dominant implementation of.

I believe Netscape's original web server product featured JavaScript as server-side scripting language back in 1995/6 already.

Re: JavaScript once had a JSX-like syntax called E4X

#30

Earlier quoted context omitted.

It existed in AS3 too. Wasn't widely known to my knowledge though.

Thank you - confirmed. I just dug up a copy of Flash CS6 and tried this: var val : String = "foo"; var foo : XML = ; ...and it worked. I swear this wasn't documented anywhere. That said, I just googled a few Flex examples (I never used Flex) and it seems to be common there, so I guess that explains why at least someone knew it existed!

That's possibly why I knew about it then (for a brief period, I did Flex work ten years ago).
Post reply on HN