-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[p5.js 2.0 RFC Proposal]: API audit #7460
Comments
Thanks for getting these all together Greg! Generally agreed with everything. Here are a few comments on some of the points:
|
Thanks @davepagurek! I really appreciate your thorough explanations. In case anyone else has comments, we're planning to move discussion of particular API changes to separate issues for each affected section of the API. I'll also make a separate issue for the quality assurance process and link to it from this issue. We'll dedicate discussion in the current issue to the API design criteria and guidelines. P.S. I like your use of a dropdown for extra context. I've been using footnotes, which violate the spatial contiguity principle that we discussed haha |
I would like to work on it as i am new here so can u please help and guide me ! |
Hi, I’m Rajas, I’ve been using p5.js for the past three months. I’ve grown to enjoy its creative potential. Over the past week, I’ve been focused on understanding and contributing to the p5.js community. I came across an issue related to naming conventions that I believe can be improved. Naming
|
Thanks @dhruvinjs and @ImRAJAS-SAMSE! I've added your usernames in the body of the proposal under a new Volunteers section. I'm planning to make separate GitHub issues for each affected section of the reference, and another issue for discussion of the quality assurance process. Once I do, I can tag you in a comment to let you know. This way, we can keep the discussion in this issue focused on API design criteria and guidelines. Does that all sound okay? @dhruvinjs: We'd be glad to help you get started! There are two great ways you can help out. First, you could help identify potential problems. When I make the separate GitHub issues, I'll include the potential problems that I've already found. Based on those examples, you can try to find other potential issues that I missed during the rapid audit. Second, you could potentially make a contribution to the source code by implementing any changes that are approved; this could be quite helpful, and many of these changes may be relatively straightforward (for example, if they only involve changing the name of a function). @ImRAJAS-SAMSE Thanks so much! I appreciate you bringing this to everyone's attention, and it's helpful that you used the same format as for the issues that were already noted :) The consistency criterion may also be relevant in this case since the name of the class is Abbreviations: A few other examplesAbbreviations are potentially an important area for improvement. In the Conversion section of the reference, "string" is abbreviated as Abbreviations: Opportunity for new contributorsHere's a helpful thing you could both help with: create an inventory of all abbreviations in the p5 API. Perhaps you and @dhruvinjs could divide up the work for that? Let us know if you're interested, but before you spend all the time to do that, it would be good if we can reach a consensus on a guideline for abbreviated names. Abbreviations: Guidelines?I'm planning to propose other guidelines on naming and syntax, but for now, do you have any thoughts on a guideline for avoiding abbreviations in names @ksen0, @limzykenneth, @davepagurek? Some rough options to consider are (a) avoiding all abbreviations, (b) avoiding nonstandard abbreviations, or (c) allowing all abbreviations. I tend to agree with @ImRAJAS-SAMSE that abbreviations should generally be avoided. We may need to weigh that against the cost of breaking changes, but we can also consider options for reducing the impact of breaking changes. Policy for reducing the impact of breaking changes?Although it's a slight digression from the current conversation, it might be helpful to first settle on a policy for reducing the impact of breaking changes. Here's one policy that might be reasonable:
|
Thanks for the update, @GregStanton The plan sounds great, I'm happy to collaborate on the tasks and contribute as needed. About the inventory of abbreviations in the p5 API, I'd be glad to help create it. Once you create the GitHub issue for this, please tag me, and I'll get started. If there's an opportunity to coordinate with others, like @dhruvinjs, yes we can divide the work for better efficiency. As for the guidelines on abbreviations, I think it's an important area to address, and I'm looking forward to hearing everyone's thoughts on it. |
Thanks for the update @GregStanton I'll start contributing the source code and get familiar with you code base |
Hi everyone! I'm new to p5.js community and interested in contributing. I'd like to help with this API improvement initiative. I'm particularly interested in helping with:
Please let me know if any of these would be helpful, or if there are other ways I could contribute as someone new to the project. |
Hey @GregStanton |
Changes to
|
Thanks so much @Vaivaswat2244! I've added your name to the list of volunteers (in the body of this issue) and will tag you in a comment once everything is a bit more organized. There may be other things you'll be able to help with, like an inventory of getters and setters. I have a few things happening this week, but I'll try to have things ready by week's end. |
Hi @dhruvinjs! No problem at all. Your help is much appreciated! The contributor docs are a good way for you to get oriented. For context, this issue about the API audit is currently part of work on p5.js 2.0, which is currently being prioritized. That's the next major version of p5.js, and it introduces some changes that may not be fully documented in the contributor docs. But, most of the contributor docs are still accurate. So, if you're interested to learn more about the contribution process, I'd recommend reading over them. If you get to the section on prerequisites and aren't sure if you have enough knowledge, you might try working through Git and GitHub for Poets. This will introduce you to Git and GitHub, in case you're not already familiar with them. The basic process is that the community will first agree on changes to be made, and after that, work can be assigned to individual contributors like you. Once you're assigned to work on a task, we can help you with any details related to 2.0 that aren't already documented. But basically, you'll make and test code changes on your own computer, and then you'll submit a pull request, so that your changes can be merged into the official version of p5 here on GitHub. If you have any other questions, please don't hesitate to ask! |
At this stage, we are not considering additional breaking API changes as we are moving closer to releasing p5.js 2.0 beta with the main aim of identifying bugs and other critical fixes for the full release. We have also gone through a full advisory process for the breaking changes that are included in 2.0 currently and for any additional breaking changes, especially those proposed here, it should have the same level of scrutiny before we can implement them. That is to say at this late stage, it is unlikely that we will be accepting the proposed changes into 2.0. For individual comments on proposals, see below
|
So I just saw your message @limzykenneth, now I am currently retracting the changes from color to createColor() which I made and what are the other issues that I should fix ! |
Increasing access
This proposal would make p5.js 2.0 and later versions more beginner friendly, in three stages:
Which types of changes would be made?
Most appropriate sub-area of p5.js?
What's the problem?
The p5.js API contains quite a few inconsistencies and other forms of complexity. This complexity makes p5.js harder to learn and harder to use, since users experience it directly through its API. While some parts of the API have been simplified for 2.0, such as the API for vertex functions, other complexities remain. This is because identifying and preventing complexities in a large API is difficult without clear guidelines and a practical quality assurance process.
What's the solution?
1. Establish criteria and guidelines
In order to identify and prevent unnecessary complexity in the p5 API, we can develop a list of criteria we want it to satisfy. We can also provide guidelines for common types of features, such as getters and setters. Initial criteria and guidelines are listed below.
Criteria
For a given feature, these design criteria may be considered with respect to naming, syntax, and behavior.
Guidelines
stroke()
andfill()
, should act jointly as a getter (when no argument is passed) and a setter.vertexProperty(name, value)
should act as getters whenvalue
is omitted.stroke()
, joint getters/setters should be used when possible. However, if separate getters and setters are to be used, they should begin with “get” and “set,” except for getters for Booleans, which should have names such asisLooping()
.disableFriendlyErrors
to toggle friendly errors and using functions likefullscreen()
andautoSized()
to toggle other settings.)These guidelines are included as examples. During the second phase, when specific kinds of issues are dealt with, the guidelines can be fleshed out.
References:
2. Perform an audit (a scavenger hunt!) and fix problems
Under ideal circumstances, the community could hold a scavenger hunt for features that don't adhere to p5's API criteria. Beginners could make significant contributions by spotting naming inconsistencies, for example. However, since p5.js 2.0 will be released relatively soon, I performed a rapid audit of the full API, to get the ball rolling.
Methodology
I skimmed through the whole reference and looked for issues that jumped out to me as potential areas of concern (I didn’t systematically apply all criteria to each feature). I also skipped over some things that I didn’t suspect were problematic.
Caveats:
baseColorShader()
.p5.Table
andp5.TableRow
shuffle()
)p5.NumberDict
,p5.StringDict
, andp5.TypedDict
Results
For illustration, only a partial sample of results from the rapid audit are included here. Skimming this section should give a rough sense of what's at stake.
Note: The sample includes examples of potential problems with naming, syntax, and semantics (broadly defined). Each example is tagged with the criteria that fail to be satisfied.
This partial sample of API problems can be replaced with separate GitHub issues, with one issue for each affected section of the reference. Those issues can be linked from here, in a checklist.
Note: The sample only includes issues that may require breaking changes, but the audit did reveal other issues that could be fixed with non-breaking changes after the release of p5.js 2.0.
Naming
color()
stroke()
.color()
withcreateColor()
.getTargetFrameRate()
/frameRate()
getTargetFrameRate()
and turnframeRate()
into a joint getter/setter.setAttributes()
setAttributes(key, value)
only sets a single attribute. Second, the name is ambiguous, since it only sets attributes of the WebGL drawing context, but this isn't advertised in the name.setAttributes()
with, say,canvasProperty(key, value)
.onended()
touchEnded()
.onended()
withplayEnded()
. (However, there is a deeper issue, which is that these functions take a callback function, whereas event handlers likedoubleClicked()
are defined directly by the user. If one of these two behaviors cannot be used in all cases, then they should be distinguished by their names. For example, a name likeonTouchEnd()
could be used for one type of behavior and a name liketouchEnded()
could be used for another.)Syntax
createModel()
,loadModel()
normalize
andfileType
are out of order in one signature,fileType
is out of order in another, andfileType
is missing from one signature).spotLight()
,directionalLight()
andpointLight()
spotLight()
has eight signatures. It accepts three vectors as input, but in some signatures, some of these vectors are specified asp5.Vector
objects whereas others are not. This makes the documentation unnecessarily complicated and leads to code that’s hard to read. The other listed features have the same type of issue.p5.Vector
specifications. The pure componentwise signature ofspotLight()
has 11 parameters and is very hard to read, but keeping both the pure componentwise and purep5.Vector
signatures reduces breaking changes and keeps these features consistent with other functions that take multiple vectors as input, such asquad()
. (Sincequad()
takes up to a whopping 14 parameters, and sincepoint()
already accepts both componentwise andp5.Vector
input, it makes sense to add support toquad()
and all other 2D primitive functions for both types of input.)p5.Shape
class developed for 2.0 has an interface that’s closer to that ofp5.Graphics
, and it may be exposed to users in a future version).Semantics
addClass()
,class()
p5.Element
class hasaddClass()
andclass()
, both of which add a class to the element. The difference is thatclass()
is a joint getter/setter that seems to makeaddClass()
unnecessary. Having both is likely to confuse users.addClass()
.millis()
millis()
returns the time since the sketch started running; all other functions, includingsecond()
, return the current time (e.g. if a sketch is run 32 seconds after noon, then when the sketch starts running,second()
will return 32 whereasmillis()
will return 0). Also, “millis” is an abbreviation, unlike the other function names; that doesn’t seem like enough to convey the difference in behavior.debugMode()
axisHelper()
andgridHelper()
functions should be an improvement. We might also consider functions likeaxesHelperProperty(key, value)
for greater readability and writability (effectively allowing named parameters).quad()
has multiple signatures and can create a shape in 2D or 3D,triangle()
only works in 2D. Other issues include shapes that can be drawn in WebGL mode but only by specifying xy-coordinates rather than xyz-coordinates. Some of these shapes support a detail parameter while others don’t. Some supportp5.Vector
arguments and others don’t. Rounding corners inrect()
andsquare()
adds another complication.3. Implement quality assurance process via issue templates
Bugs can be fixed in any version of p5. API problems cannot be fixed outside of a major version release (if at all), if they're like any of the problems listed above. To avoid introducing such problems in the future, we can implement a basic quality assurance process via the issue templates for new features and existing feature enhancements:
a. Documentation will be required before release (and encouraged before implementation).
b. Review will be required by multiple stakeholders.
Volunteers
If you're interested in helping with this issue, you can leave a comment, and I can add your username here. Once separate issues have been created for the affected sections of the reference, I'll add a comment on this issue and tag everyone listed to let them know.
@dhruvinjs, @ImRAJAS-SAMSE, @Vaivaswat2244
Pros (updated based on community comments)
Cons (updated based on community comments)
Proposal status
Under review
The text was updated successfully, but these errors were encountered: