Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Let's choose a view framework for docs, generated packages, etc. #5756

Closed

Description

@thedaniel

(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.observe and 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

  1. mark-hahn commented on Feb 26, 2015

    @mark-hahn
    Contributor

    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:

    (This is an attempt to restate #3752
    #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 https://github.com/atom/space-pen and used
    it heavily, but ultimately decided to discontinue using it for new views (though
    some base views still use space-pen
    https://github.com/atom/atom-space-pen-views 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, etc) as much as
      possible
    • recognizable markup (allow users to write 'normal HTML')
      • data binding preferred to imperative updates if templates are used
        • View model / MVVM-style separation of rendering and logic
    • Easy for developers to replace with another preferred library
      • this implies not polluting the global namespace
        • 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

    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 https://github.com/orgs/atom/teams/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

    —
    Reply to this email directly or view it on GitHub
    #5756.

  2. steelbrain commented on Feb 26, 2015

    @steelbrain
    Contributor

    I am using vanilla-jsx, it supports JSX but it spits out native HTML Elements so it's performant and lightweight

  3. gilbert commented on Feb 26, 2015

    @gilbert

    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.

  4. mark-hahn commented on Feb 26, 2015

    @mark-hahn
    Contributor

    no arbitrary html-ish templating languages

    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:

    Mithril.js http://lhorie.github.io/mithril/index.html 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.

    —
    Reply to this email directly or view it on GitHub
    #5756 (comment).

  5. thedaniel commented on Feb 26, 2015

    @thedaniel
    ContributorAuthor

    IMHO it should be a simple noise-free template syntax like that of space-pen.

    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.

  6. mark-hahn commented on Feb 26, 2015

    @mark-hahn
    Contributor

    I personally am strongly against anything like space-pen's syntax, or HAML

    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.

  7. benogle commented on Feb 26, 2015

    @benogle
    Contributor

    recognizable markup (allow users to write 'normal HTML')

    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.

    Easy for developers to replace with another preferred library; this implies not polluting the global namespace

    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.

  8. mark-hahn commented on Feb 26, 2015

    @mark-hahn
    Contributor

    The television link is a 404.

  9. benogle commented on Feb 26, 2015

    @benogle
    Contributor

    @mark-hahn it should work now. Sorry about that

  10. thedaniel commented on Feb 26, 2015

    @thedaniel
    ContributorAuthor

    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.

  11. mark-hahn commented on Feb 26, 2015

    @mark-hahn
    Contributor

    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.

  12. lhorie commented on Feb 26, 2015

    @lhorie

    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.

  13. lee-dohm commented on Feb 26, 2015

    @lee-dohm
    Contributor

    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.

  14. benogle commented on Feb 26, 2015

    @benogle
    Contributor

    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:

    • 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.observe and not it's own model system?
    • Does it inject any globals?
  15. nathansobo commented on Feb 26, 2015

    @nathansobo
    Contributor
    • How does it interact with web components, both in terms of creating new ones and using existing components written using different frameworks?
  16. 110 remaining items

  17. mnquintana commented on Jan 6, 2016

    @mnquintana
    Contributor

    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.

  18. mark-hahn commented on Jan 6, 2016

    @mark-hahn
    Contributor

    @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.

  19. alvarolorentedev commented on Jan 6, 2016

    @alvarolorentedev

    @mnquintana maybe something that will use the API and could be an adapt is a 'find TODO comments' on the editor.

  20. paulpflug commented on Jan 6, 2016

    @paulpflug

    @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 ;)

  21. kierans commented on Jan 7, 2016

    @kierans
    Contributor

    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.

  22. k33g commented on Jun 10, 2016

    @k33g

    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

    export default class MyPlugInView {
    
      constructor(serializedState) {
        this.element = document.createElement('div');
    
        let myForm = new Ractive({
          el: this.element,
          template: `
          <div>
            <p>{{greeting}}, {{recipient}}!</p>
            <div on-click="activate">{{message}}</div>
          </div>
          `,
          oninit: function () {
            this.on( 'activate', () => { // fooo
            });
          },
          data: {
            greeting: 'Hello world',
            message: 'Click me!'
          }
        });
      }
      serialize() {}
      destroy() {
        this.element.remove();
      }
      getElement() {
        return this.element;
      }
    }

    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

    'use babel';
    
    class Small extends HTMLElement {
      constructor() { super(); }
      createdCallback() {}
      attachedCallback(){}
      template(data) { return `<div></div>`; }
      html(data) {
        this.innerHTML = this.template(data);
        this.events(data);
      }
      init(data) {}
      static of(tagName, data) {
        let Element = document.registerElement(tagName, this);
        let instance = new Element()
        instance.init(data)
        instance.html(data)
        return instance
      }
    }
    export default Small;

    And then I use it like that:

    'use babel';
    
    import Small from './small';
    
    class MyForm extends Small {
      constructor() { super(); }
      template(data) {
        return `<div>
          <h3>${data.message}</h3>
          <form>
            <input type="text" placeholder="${data.placeholder}"/>
            <button>Click Me!</button>
          </form>
        </div>`;
      }
      events(data) {
        this.querySelector('button').addEventListener('click', (e) => {
          let value = this.querySelector("input").value;
          this.querySelector("h3").innerHTML = value;
        });
      }
      init(data) {
        console.log('Inititialize ...', data)
      }
    }
    
    export default class MyPlugInView {
      constructor(serializedState) {
        this.element = document
          .createElement('div')
          .appendChild(
            MyForm.of('my-form', {message:'Hello world!', placeholder:'???'})
          )
      }
    
      serialize() {}
      destroy() {
        this.element.remove();
      }
      getElement() {
        return this.element;
      }
    }
  23. RobertBColton commented on Jun 17, 2017

    @RobertBColton

    +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.

  24. alvarolorentedev commented on Jun 20, 2017

    @alvarolorentedev

    @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.

  25. kolya-ay commented on Jun 20, 2017

    @kolya-ay

    Is the open issue means that relaying on etch isn't still a done deal?

  26. nathansobo commented on Jul 3, 2017

    @nathansobo
    Contributor

    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.

  27. lock commented on Mar 31, 2018

    @lock

    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!

  28. locked and limited conversation to collaborators on Mar 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions