-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Understandable names #14340
Comments
I'm sorry, but this kind of sweeping issue isn't credibly actionable. Please stop opening things that are so broad. |
@bramtayl Might be better to 1) make a list of at least the worst cases 2) write a PR to add new, more understandable names (including deprecating the inscrutable abbreviations) 3) wait for the fireworks! |
The story of picking function names is much more complex than you'd think at first. True, We also have an avowed policy of avoiding underscores, as it tends to produce overly long names and less-well-factored functions. For example So I think these have to be taken on a case-by-case basis. To that end, it's certainly possibly there are a few especially obscure names we can fix. |
@JeffBezanson Where is that policy? That doesn't seem to be what Julia Docs says:
The statement in Julia Docs seems reasonable, however, avoiding underscores by simply removing them flies in the face of research that has been done into readability of names. I believe that language design should be data driven, and think it would be good to take that research into account in julia. For things like your Another thing is to adopt hard to understand names because they came from That's sad, because julia can do so much better, with it's great (and getting better) type system and multi-dispatch. How about something like: Would people accept a PR that added |
I definitely think that is is good have "well-factored functions". And I understand how it would be easier to inherit C function for users familiar with C. One thing to do would be to go through Julia and make the three changes below: And in the process, building "well-factored functions" groups where possible, and maintaining C compatibility if deemed necessary, all on a case by case basis. From this thread, isupper, isprint, islower have the words supper, sprint, and slower within them. Unwary users could be confused by all the apple products referenced in Julia! This ambiguity would be avoided by is_upper, is_print, and is_lower. |
Here's an example: The function to remove a file is Note, however, that there is a group of similar functions (including e.g. |
Unix is a great example of an interface that is completely unreadable because of excessive abbreviation. Regex is another example (and there are great alternatives; see the R package rex). |
This issue is also mistitled since it's not about syntax at all. |
We are definitely not doing this. This isn't three changes; more like thousands. But the real issue is that as soon as you start trying to apply sweeping policies like this you run into hard decisions over and over. Is Is Another non-obvious point is that when we copy names from C, it's not usually because we're trying to make things easy for C programmers. Rather it's for global consistency --- that is, consistency not just within julia but among software systems. When picking a word for something, one of the first things you ask is whether there is already a word for it, and if so, why not reuse it.
Isn't "rex" an abbreviation for "regular expression"? Who allowed that? |
I think before a 1.0 release, the list of all the names could be given a once over. That doesn't seem unreasonable. It might allow a few particularly poor names to be noticed when viewed in a larger context. But in the long run Julia provides capabilities to create packages which export custom sets of names, heck the package could even be auto generated for the most part. If someone want's a custom set of names then they can provide it themselves. |
@JeffBezanson You are kind of arguing against yourself here - while I also don't agree with @bramtayl's 3 rules, that's why I also don't agree with the "avowed policy of avoiding underscores".
I agree with most of your other examples, except the last two - My recommendation, on a case-by-case basis, would be to look at longer names with _s, and short abbreviated names such as @mason-bially Yes, totally agree. I think short hard to understand names (i.e. to be like Matlab, Unix sh, or C) really belong in compatibility packages. One of the (many) great things about Julia is that it makes doing that sort of thing trivial. |
I would love to see that, especially as part of #5155, for example the printf library really has no business in Base except for comparability with a c like environment (for which it is quite useful). But we could do with a more python like format that actually enables more powerful format strings. But in the long run those sorts of choices should be made by the people using the language. The base library though should strive to have a well factored set of names, which is why I completely agree with your points. |
As Jeff has stated elsewhere, if a name is long enough to need an underscore to break it up, then it's probably actually doing too many things. Generic functions should do one thing, a long name is a sign of missing abstraction and something should be refactored into multiple concepts. Continued comments on this issue are not helpful. Make concrete proposals. Adding underscores will likely be rejected. |
@mason-bially As far as @tkelman "probably actually doing too many things", I'd agree, but that is only probably, and there are a few cases where _'s are appropriate. I have tried to make a concrete proposal here, about the |
Ok, I admit the language "avowed policy" was too strong. I should have said "strong preference" for avoiding underscores. I agree with the goal of identifying and fixing bad names. I think various different approaches will be needed.
I would also prefer an ordinary function call API for formatting to any kind of format strings. |
That sounds great! 💯% behind that! (I'll make a PR for the character category stuff, @nalimilan has already made some great suggestions on that) |
I've recently put in a CRAN package for building time formats. It looks like the underlying logic used is similar to the print formats of @tbreloff . I might write a similar R package for sprintf. I don't think anyone's actually used the package so it's probably full of bugs, but I thought it might be useful. https://cran.r-project.org/web/packages/strptimer/vignettes/strptimer.html |
Base Julia is full of abbreviations. Functions with names like iscntrl are inscrutable. I think, before it's too late, that Julia should make every effort to be written in plain English. To this end, I think that rules like this should be put into effect:
No abbreviations should be used in base julia for any words shorter than 10 (or so) characters
All words should be separated by _
The text was updated successfully, but these errors were encountered: