Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Difficulties doc - #6

Closed
benogle wants to merge 2 commits into
masterfrom
difficulties
Closed

benogle wants to merge 2 commits into
masterfrom
difficulties

Conversation

@benogle

@benogle benogle commented Jul 25, 2014

Copy link
Copy Markdown
Contributor

I want to create a document that outlines all the difficulties people have had using the API. I feel like we have a lot of really good data in the forum, in @probablycorey's analysis of the packages, etc. It would be nice to get it all in one place to help us make some informed decisions.

Feel free to suggest changes on this PR or add them directly to the md doc.

@benogle

benogle commented Jul 25, 2014

Copy link
Copy Markdown
Contributor Author

@lee-dohm @izuzak @abe33 would love to get your input on this. Also CC folks I am missing!

@abe33

abe33 commented Jul 25, 2014

Copy link
Copy Markdown

I'll try to list all that I can think of :).

As for the CC, I guess that @joefitzgerald or @thomasjo may be interested as well

@benogle

benogle commented Jul 25, 2014

Copy link
Copy Markdown
Contributor Author

Thanks!

@joefitzgerald

Copy link
Copy Markdown

I think a lot of people still struggle with the notion that things can (and often should) be asynchronous. Events / commands confusion is one example of that. Another concrete example is that the autocomplete-plus Provider / Suggestion API is synchronous (I am working on fixing this).

I would put some serious thought into educating people how to write packages in such a way that they do not degrade the performance of Atom. This may seem redundant ("why should we teach people how to code properly in node... everyone knows you should use callbacks and promises?!"), and yet it's still a pervasive problem.

I would start with:

  1. Rock solid documentation of events
  2. Very strong advice about module activation
  3. More functionality around BufferedProcess - ensuring that externally launched processes don't become wayward
  4. Provide recommendations to package authors about providing an API for their own packages; not enough packages have functionality that can be composed to form additional functionality, leading to unnecessary forks and duplication of functionality

I'm sure there's much more to add there.

@abe33

abe33 commented Jul 25, 2014

Copy link
Copy Markdown

Here's a first batch based on what came up regularly on the forum or that I experienced myself. Most of the time it is related to a lack of documentation, and where I'm confident I can dig in the code by myself there's probably a lot of people that either doesn't have the time/interest to do so or may be are a bit at loss because they are new to JavaScript/CoffeeScript or does not use it on a daily basis.

  • Using Atom events and where to find them. Differences between commands and events.
  • How to report errors to the user (Not really covered by the API yet, but already asked several times).
  • How to display modals or asking for user input (html input Vs. mini editor).
  • Working with files (what is the typical flow of Atom when dealing with buffers, where does a package can hook in that flow).
  • Working with promises (this may be new for a lot of people that don’t practice JS extensively or have been used to use callbacks).
  • Handling dependencies to other Atom packages (how to make sure a package is available, how to report to the user if it is not the case).
  • How to setup tests for packages that manipulates editors and editors views.
  • How to deal with large buffers effectively (I struggled twice on the color highlight and minimap packages to find how to avoid killing the performances and I'm done with that yet ^^)

Hope it helps.

@benogle

benogle commented Jul 25, 2014

Copy link
Copy Markdown
Contributor Author

Thank you guys. These are a huge help.

I would put some serious thought into educating people how to write packages in such a way that they do not degrade the performance of Atom.

YES. Man, it's easy to shoot yourself in the foot with performance. Ideally, we'd have the easy way be the fast way in common cases (see decorations api).

@joefitzgerald

Copy link
Copy Markdown

+1 on reporting errors, warnings, and informational messages. I think this is a great example of where this could be added as a core package, with a half-way point of establishing an API for reporting them and then modifying atom-message-panel to integrate with that API.

As it stands today, atom-message-panel is the best solution but when I compare what I can achieve to what is available in more established products, there's lots of nice-to-have functionality like filtering / showing / hiding / moving / clicking / exporting these that the core team could provide.

On the other hand, I'd still need something like atom-message-panel to display non-warning output (like the output from the app someone is authoring, when it is executed). So - something for line-item infos / warnings / errors, plus something for consistent package-specific display of bulk informational text, that can be styled.

@joefitzgerald

Copy link
Copy Markdown

@benogle The decorations API was huge. Allowed me to remove multiple views from my package and generally reduce complexity while enhancing speed.

@thomasjo

Copy link
Copy Markdown

Yeah, big 👍 on reporting messages to the user. This is something I need to tackle in my LaTeX package very soon, and while I'll most likely end up using atom-message-panel, I'd really prefer a built-in API for it, with support for handling clicking messages and navigating to e.g. the corresponding file and line. I might also end up doing a PR for it, but it seems like such a massive piece, it might be best handled by the core team.

I've had some pain points around various functions (and instance variables/properties) not being documented; while they are easy to find, it has left me unsure whether they are public or private. This means I'm not sure if they are "safe" to use or not. I don't relying on private stuff, since they can be changed or removed at anytime since they are not part of the public API.
While all of us in the community can contribute to the documentation, it's a little bit hard when we have no clue whether a particular function is meant to be public or private.

@benogle

benogle commented Jul 25, 2014

Copy link
Copy Markdown
Contributor Author

Noted on the messaging stuff. I didnt know it was a problem at all!

it has left me unsure whether they are public or private. This means I'm not sure if they are "safe" to use or not.

That is exactly what we are doing right now. Making a conscious decision about which parts are public / private. Then we can base the docs off those. Can you elaborate on things you are using you were unsure about? Specific APIs would be helpful.

@thomasjo

Copy link
Copy Markdown

Sure thing. These are the ones I remember off the top of my head

  • Editor::isModified()
  • WorkspaceView::getEditorViews()
  • WorkspaceView.statusBar (property)
  • Grammar.scopeName (property)

Now that I've written that list, I realize that I'm basically unsure whether any property use is considered safe. Basically I think properties that are considered part of the public API (e.g. atom.config and the ones I listed et al.), need to be documented as well. I realize that's trickier. Not even sure if Biscotto supports it out of the box.

I'll try to think of more examples.

@lee-dohm

Copy link
Copy Markdown

Thanks for kicking this off @benogle!

Let's see ... where to begin. I think the things that will provide the most bang-for-the-buck are:

  • A map of what functionality is provided by what built-in Atom package (i.e. I want to add something to the status bar ... uhhhh ... wait, there's nothing in the API docs about the status bar. Now what do I do? 😕)
  • Helpers, helpers, helpers ... not just for message panels like @joefitzgerald mentioned, but things like the following:
    • StatusBarItem - for adding something to the status bar
    • StatusBarMessage - for displaying a message in the status bar that gets overwritten when the next one is displayed or times out after x milliseconds
    • A common FileItem that is used by the tree view, fuzzy finder and tabs. One that is preferably extensible so that if I add say a scopeName property to it, it shows up in the view as a data-scope-name property that I can then style like in my file-type-icons package.
  • Expose the logic of determining the scope for a file more obviously, there are lots of packages that have redundant logic to the information that is in the grammar definitions to determine whether a file is a Ruby file, a Python file or what have you. Provide an API like, atom.scopeNameFor('path.ext') or atom.scopeNameFor(editor) or whatever you want to pass in that can possibly be resolved to something that first-mate can figure out the grammar for.
  • While we're on that ... provide shortcuts for n00b (or forgetful like me) package writers. Rather than me trying to remember if I open a file by calling it on the Workspace or the WorkspaceView ... how about just atom.openFile(fileName)?

These are mostly selfish things that I've run into in writing my own packages. I'll see if I can cull some things from the board and add them to the list.

@joefitzgerald

Copy link
Copy Markdown

Another thing I thought of: there is general confusion about how to log information that might be useful in debugging a package.

console.log is used almost universally for this, but it'd be nicer if there was some logging API which ensured this output was thrown away 99.9% of the time - unless someone has put a single package in 'Debug Mode', or all of Atom in 'Debug Mode'.

@joefitzgerald

Copy link
Copy Markdown

Perhaps instead of 'Debug Mode' there would be a way to set loglevel universally or for specific packages?

@abe33

abe33 commented Jul 26, 2014

Copy link
Copy Markdown

@joefitzgerald I wrote a small module when working on the minimap to have logs in debug mode but mute them otherwise.
Something that can be great, in addition, is to have a way to know which package is in dev mode. that way I will be able to mute every other channels.

@smashwilson

Copy link
Copy Markdown

💭 It looks like everyone's done a pretty thorough job so far. Let's see what I can reinforce and if I can come up with anything else.

  1. Event documentation has come up a few times. Re-finding what classes produce which events is probably the number one thing that I have to go to the source rather than the docs for, especially among the Editor, EditorView, TextBuffer family. Also, general documentation about best practices for using subscribe and unsubscribe instead of on and off, for example.
  2. Providing an orderly, flexible means of exposing an API for other package authors to consume, especially in a way that doesn't lead to tight coupling and dependency hell. Broadcasting and listening for events can address some of this; looking up packages in the PackageManager and calling exposed methods can address some other use cases. I'm not sure if the mechanisms that exist now are sufficient and it's just a question of documenting the patterns, or if there's more work to be done in Atom proper to support this.
  3. More support or guidance for creating and working with form controls beyond mini-editors and buttons. Actually I've found even working with mini-editors to be a bit mysterious, since getting things like copy and paste to work properly is a bit hidden.

@lee-dohm

Copy link
Copy Markdown

Read-only EditorView ...

https://discuss.atom.io/t/read-only-editor/11125

For those times when you want to display code in some part of the UI, but don't want the user to be able to edit it.

@lee-dohm

Copy link
Copy Markdown

Resizeable elements:

https://discuss.atom.io/t/tables-with-reisizable-column/11142

I think this could be a huge win, to provide a generic resizable view that any view could be placed within.

@joefitzgerald

Copy link
Copy Markdown

Case-in-point regarding events. I feel like I use them heavily, and even now I was making some rather large mistakes, leaking event subscriptions, not cleaning up after myself, and generally being a bad package on activate / deactivate / activate cycles (e.g. package update).

Attempt 1 (failed): joefitzgerald/go-plus@9cac33b
Attempt 2 (seems to have succeeded): joefitzgerald/go-plus@626dd40

Brutal critiques of what I have done are much appreciated.

@joefitzgerald

Copy link
Copy Markdown

Interestingly, if you @subscribe(someInstanceOfAWorkspaceViewHere), it kills all keyboard bindings and most commands. Just FYI. Perhaps guard against that?

An aside: Why doesn't .on on a WorkspaceView return a Subscription like most other things?

@abe33

abe33 commented Jul 29, 2014

Copy link
Copy Markdown

Why doesn't .on on a WorkspaceView return a Subscription like most other things?

This is due to the fact that WorkspaceView, or EditorView instances are jQuery objects, and the jQuery ::on method doesn't return a subscription.

@benogle

benogle commented Aug 27, 2014

Copy link
Copy Markdown
Contributor Author

Thanks for the info, guise. Closing in favor of atom/atom#3399

@benogle benogle closed this Aug 27, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants