compiler support for React (or similar)

111 views
Skip to first unread message

Roberto Zanotto

unread,
Jun 4, 2015, 9:28:52 AM6/4/15
to goph...@googlegroups.com
Hi.

React introduced this new paradigm for building GUIs that is very interesting. Being able to describe the GUI components in a pure functional/declarative way helps a lot with code readability, reliability and maintainability, helps separate GUI and logic code and removes the burden of having to manually query and edit the DOM. A lot of other new libraries are following React's way and with React Native it will be soon possible to write javascript/React applications that make use of Android and iOS native components.

I was thinking that it would be really cool to be able to write Go+React apps that can run in the browser, on the desktop (with node.js) and on mobile, having Go code both on the server and on the client. The only piece that's missing is React support from the gopherjs compiler. Calling React with the current javascript interface would result in a mess of unreadable code, defeating the biggest advantage of React which is readable and maintainable GUI code.

What do you think?

Cheers

Roberto Zanotto

unread,
Jun 4, 2015, 10:32:25 AM6/4/15
to goph...@googlegroups.com
A simplier alternative could be to take a pure javscaript library like mercury and create some gopherjs bindings, but we would lose the mobile native components.

Shaban Naasso

unread,
Jun 4, 2015, 10:34:53 AM6/4/15
to goph...@googlegroups.com
Heya,

i am doing something similar right now, the way i dealt with it was to have the declarative render code in a separate jsx file and declare logic in other file, then i just call the application logic code from event handler (onclick etc.)  in the jsx file.
This way there is a separation of templating language, application logic and the underlying json data model. And most importantly between idiomatic react code and your gopherjs script.

Roberto Zanotto

unread,
Jun 4, 2015, 11:24:56 AM6/4/15
to goph...@googlegroups.com
Makes sense :)
Reply all
Reply to author
Forward
0 new messages