Repository navigation
Let's choose a view framework for docs, generated packages, etc. #5756
Description
(This is an attempt to restate #3752, explain the current position and present options)
A blessed view system for Atom
We're in an interesting place with respect to generating views in packages and core. We wrote space-pen and used it heavily, but ultimately decided to discontinue using it for new views (though some base views still use space-pen we are no longer recommending it). So now we find ourselves in an unfortunate position of using the DOM APIs directly, and suggesting package authors do the same, choose a framework themselves, or ╮(. ❛ ᴗ ❛.)╭ - Not a great place to be, and makes it hard to write docs with nice examples.
We used React in the editor component for six months or so, and it was a good experience, but it has a bit of a learning curve.
We experimented with a few things inspired by React and Polymer, and have done some research on 3rd-party view frameworks, but haven't come to a decision. As we work on better docs for the run up to 1.0, we have to start taking this seriously.
Requirements
- Embrace modern browser features (custom elements,
Object.observe, etc) as much as possible - It absolutely does not pollute the global namespace
- Data-binding preferred to imperative updates if templates are used
- View model / MVVM-style separation of rendering and logic
- No dependencies on jQuery-like helper libs
- Small learning curve
- somewhat self-explanatory when used in docs examples
- in other words, most web developers will be able to recognize the concepts that are applied without reading a book on it
Contenders / experiments
- React
- Etch - a library for writing HTML-based view components that provides the convenience of a virtual DOM while at the same time striving to be minimal, interoperable, and explicit - written by @nathansobo and @maxbrunsfeld
- rivets for templating+data binding plus some basic JS object glue for Atom
- television - "Television aims to cleanly integrate the virtual DOM approach of React.js into HTML 5 custom elements." - an experiment from @nathansobo
- virtual-dom this library is used by
television, but could be a component in a similar solution that accomplishes the above goals. - elmer - An experiment from @benogle based on Polymer's template binding
- vue.js - simple, component-based, simple & small
- Something custom, delightful & new from your friends the Atom team (but we don't reallllly want to maintain another view frameowrk)
Want to help?
One way to help speed this along is to do some experimentation with using your favorite framework in a package. See https://github.com/benogle/template-explore as an example package using https://github.com/atom/elmer.
A couple questions I would try to answer with the package:
- How does it handle model/DOM updates? Data-binding? Imperative + virtual-dom like react?
- How does it handle events? i.e. How do I bind a click handler to an element?
- Can it work with
Object.observeand not it's own model system? - Does it inject any globals?
- How does it interact with web components, both in terms of creating new ones and using existing components written using different frameworks?
Discuss
We're interested in hearing the pros and cons of the various ways we can satisfy the items listed under requirements, recommendations for solutions we don't have listed, and questions about the reqs and how and why we arrived at them.
Also, I encourage @atom/core and maintainers to edit the Contenders section in the issue body as more come in, and let me know if I missed / misstated anything in Requirements
Activity
mark-hahn commentedon Feb 26, 2015
That is good news. There was a vacuum for new package developers.
On Wed, Feb 25, 2015 at 6:38 PM, Daniel Hengeveld [email protected]
wrote:
steelbrain commentedon Feb 26, 2015
I am using vanilla-jsx, it supports JSX but it spits out native HTML Elements so it's performant and lightweight
gilbert commentedon Feb 26, 2015
Mithril.js saved JavaScript for me. Like many others frameworks/libraries it uses a virtual DOM, but most importantly it's just JavaScript. No JSX, no OOP, no arbitrary html-ish templating languages. Once you learn its five or so core methods, you're free to think and do anything JavaScript without Mithril getting in the way.
mark-hahn commentedon Feb 26, 2015
I think there should be a blessed template syntax as per the "recognizable
markup" requirement. I want to be able to easily read other package's
code.
IMHO it should be a simple noise-free template syntax like that of
space-pen.
On Wed, Feb 25, 2015 at 8:02 PM, Gilbert [email protected] wrote:
thedaniel commentedon Feb 26, 2015
This conflicts with the second requirement listed - I personally am strongly against anything like space-pen's syntax, or HAML, and I believe the rest of the team either doesn't feel strongly, or prefers that if we use templates at all we do data binding + templates similar to Polymer: https://www.polymer-project.org/docs/polymer/databinding.html
I'll let them chime in, but I wouldn't get your hopes up for something space-pen-like.
mark-hahn commentedon Feb 26, 2015
I don't see how Atom could bless coffeescript and not Space-Pen syntax. They are one and the same.
I know we have to use an existing solution so there probably won't be such a syntax available but I would certainly argue for matching coffeescript if we could.
benogle commentedon Feb 26, 2015
This is definitely not a requirement. Television, for example is more space-pen-like (and even more react like, minus the jsx). I personally like the markup better than the code-like definition, but it's not a requirement.
The global namespace issue is a super hard requirement. Not really for ease of switching, but for playing nice with other versions of the framework, and with other frameworks.
We basically want the option of more than one framework to be used as a dep. That way we're relatively future proof. When the next react or whatever comes along, we can use it by including it as a dependency.
mark-hahn commentedon Feb 26, 2015
The television link is a 404.
benogle commentedon Feb 26, 2015
@mark-hahn it should work now. Sorry about that
thedaniel commentedon Feb 26, 2015
Perhaps I let my opinions leak into the requirements - we're evaluating some options that don't use normal markup in their templates. I still think it's very prudent from a docs perspective but I'll move it out of the issue body and into "thedaniel's suggestions in the comments" since it's not actually a hard requirement.
mark-hahn commentedon Feb 26, 2015
Television looks awesome. It looks cleaner and less-noisy than space-pen. And the custom element handling seems simple, even to a luddite like me. I think it would be accessible to beginners.
lhorie commentedon Feb 26, 2015
Mithril's out of the box syntax is very similar to virtual-dom/television, but you can also get HTMLy syntax via MSX (basically the same thing as React's JSX) if curly braces are important.
There's also SugarTags for a different flavor of code-like definitions.
lee-dohm commentedon Feb 26, 2015
I like the template+data-binding approach. I think it would be awesome if the template language was pluggable so if people wanted something more HTML-like, they could have it, closing tags and all. And if they wanted something simplified a la HAML/Jade/Slim, they could have that too.
benogle commentedon Feb 26, 2015
If anyone out there is interested, one way to help speed this along is to do some experimentation with using your favorite framework in a package. See https://github.com/benogle/template-explore as an example package using https://github.com/atom/elmer.
A couple questions I would try to answer with the package:
Object.observeand not it's own model system?nathansobo commentedon Feb 26, 2015
110 remaining items
mnquintana commentedon Jan 6, 2016
I think a TodoMVC-esque example package for Atom is a great idea, but I agree with @paulpflug that it shouldn't literally be TodoMVC, but rather something that makes significant use of the Atom API.
mark-hahn commentedon Jan 6, 2016
@steelbrain, I'm too lazy to argue by writing vue samples. I remain convinced though that it can be done with vue in an elegant way. You haven't presented anything to sway me, not that you should care.
Anything turing complete could do it but we'd have to compare final results to really get a good comparison.
alvarolorentedev commentedon Jan 6, 2016
@mnquintana maybe something that will use the API and could be an adapt is a 'find TODO comments' on the editor.
paulpflug commentedon Jan 6, 2016
@steelbrain I believe, what you would need is something similar to clusterize.js and I'm sure you could implement and adapt it to your use case in nearly any view framework - only a matter of time ;)
kierans commentedon Jan 7, 2016
I agree with @mnquintana that an examples need to showcase the Atom API, as well as have several different UI widgets to show what's possible.
k33g commentedon Jun 10, 2016
Hello 🌍 , cc @thedaniel
I'm starting some quick experiments with Atom and UI:
With RactiveJS
http://www.ractivejs.org/
Learning curve is small, abs Ractive is pleasant to use
With HTMLElement (Custom Element and VanillaJS)
For small codes, to my mind it's enough: Custom Elements with Classes
Nothing ✨ but does the work for small tests
And then I use it like that:
RobertBColton commentedon Jun 17, 2017
+1 There really needs to be some normalization of view frameworks for package authors. People want to be able to do things in a way that they know won't break in the future.
alvarolorentedev commentedon Jun 20, 2017
@RobertBColton I agree, but in any case is difficult, i think the rendering framework is not an issue in general.
My concern is becoming the fact that the liberty of rendering is adding dependencies in a per plugin bases. I would like to really se something different as use what is internal to atom so we don't have a mix of instances and resources being used, so performance and resource usage becomes better.
In any case this thread is 2 years old and we have not got to any agreement neither here or the forum.
So my vote is to just get to use whatever DOM is being used internally in atom.
kolya-ay commentedon Jun 20, 2017
Is the open issue means that relaying on
etchisn't still a done deal?nathansobo commentedon Jul 3, 2017
At this point we use manual DOM manipulation, Etch, and React in the GitHub package. I think that's as close as we'll come to a specific endorsement, but we'll remain committed to being agnostic and giving package authors freedom of choice. Baking any view framework into Atom core other than the raw DOM APIs that come with the browser is a liability we're not prepared to take on any time soon.
lock commentedon Mar 31, 2018
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!