- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Rename abstract numeric types like FloatingPoint and Complex? #8142
Comments
My votes:
|
Hard to get this consistent at this point. A radical change would be to use the |
@StefanKarpinski +1, but why not |
I hear you on the consistency issue. But something is off about |
The more I think about it, the more I like the idea of introducing a common prefix for all abstract types. This makes it entirely obvious that one is dealing with an abstract type. The argument that a name is "free" like in the Since |
I'm not a fan of the Can I suggest a very different perspective here? I think the confusion we see on the mailing list is only correlated with names and tab-completion: the real cause is that many people coming to Julia have never worked with any type system before. So FloatingPoint confuses them because the idea of abstract types confuses them. And Complex confuses them because parametric types confuse them. We can maybe fix these specific issues with name changes, but there's a broader cultural problem: the manual doesn't provide any way for newcomers to learn what a type system is. |
-1 to I think it may also be prudent to consider other upcoming changes: #1470 will allow the use of Abstract types differently, #6975 talks about official Interfaces which will overlap, and #6984 is the covariance change. I think any name changes needed to be looked at in the broader scope of the future of the type system. I'm also really looking forward to a lot of these changes; can't wait to throw them all together and get my "Julia-legs" again with the new system. |
I kind of agree that it's not very satisfying to keep second-guessing which names will have an intended psychological effect. We thought The issue with |
The issue with @StefanKarpinski I'd be fine with |
@quinnj: Absolutely, these things all need to be seen in a common scope. Still, explaining the difference between Let me ask the other way around: Would there be a drawback if we would introduce a convention how to name abstract types? On a related note, the bang-convention is IMHO great too. |
And it does not has to be the |
I'm not opposed to a naming convention, especially if it's fairly lightweight (e.g. an |
Jep, the "lightweight" property is what made me like |
We could keep aliases around for a while to smooth the transition. Is |
If we adopt prefixes, can we at least go with one that has some mnemonic property like Abs or Abstract rather than A? |
Yes, Abstract is too long; Any is much better. -erik On Tue, Aug 26, 2014 at 11:38 AM, Stefan Karpinski <[email protected]
Erik Schnetter [email protected] |
+1 to |
Carrying this to a systematic extreme: is AbstractArray going to become AnyArray? Is String going to become AnyString? |
|
+1 for a short prefix. |
Am I the only one who things the A prefix is not just non-mnemonic, but anti-semantic? "What type is |
@johnmyleswhite: (refering to |
I believe at one point, it was mentioned that we would actually have an
|
Nope. Me too. |
I don't see what the problem with such a long prefix on |
I agree. I think the only reasonable prefix so far is |
+1 for almost any convention for making it easier to understand the meaning of some piece of code. A full |
The problem with |
I think that's an overestimate, but only by about 50%. |
I think 100% of the users who have used C before will think it is the same. |
Well, that's exactly the situation with Fortran users and Complex. |
That's true, but the issue with renaming Also |
The real issue IMHO is that new Julia users willl think |
I think at some point we are going to run into a situation where consistency/sanity will be directly opposed to background experiences of programmers from other languages. I think that if the cost is worth the benefit, and if this is possible at all, we should put less emphasis on previous coding backgrounds once we have good lint/analysis tools. If I could, in IJulia, press a "lint this" button, have it highlight an |
Yes, it is all about cost vs. benefit. However some words simply have established meanings. In computing it's often not clear which those are, which makes things difficult. But if a meaning is firmly-enough established, I believe there is nothing to gain by using it differently. I agree we should not be overly slavish to backwards compatibility. We need to distinguish between terms that are firmly established, and those that are simply backwards-compatible with one system or another. |
I just realized I wrote "if the cost is worth the benefit". I'm such a |
Since in Julia, only leaf nodes are concrete types, presenting the type tree to users will largely solve the problem. (well, I just wanted to say that I want this type tree, but cannot find it.) |
@Sisyphuss here you go: include(JULIA_HOME[1:rsearch(JULIA_HOME, joinpath("usr", "bin")).start - 1] * "examples")
TypeTrees.print_tree(TypeTrees.types_tree) |
@lostanlen Thanks for your humor! I think that users would prefer a concise, portable and visible typetree that could be used as a reference card. |
I came late to the party, so several comments and thoughts: I would like to have Regarding the abstract-ness of I think the For what it's worth, I find |
Also, +1 for having |
Sure, a function that takes a complex value can always take a real value instead, but what if you have a function that accepts an I think it does make sense to be able to talk about the set of types that do not only represent complex numbers, but are able to represent more or less any complex number (up to precision). |
Then you get
|
@Sisyphuss here is a GraphViz based plot of v0.3.10 by @jbn, here is the code he used, it would be nice if we could automatically provide similar plots updated and linked in the documentation. |
@Ismael-VC it seems to me that he used Julia to write a Graph data object (a sort of metaprogramming). IMHO, his code can be directly used in a v0.4 kernel and produce a correspondent v0.4 type graph. |
@Sisyphuss it's done with Graphviz, but I don't know much dot foo, this: julia_0.4.1_type_hierarchy.pdf graph looks too crowded, I'll try to make it better. Acrobat reader doesn't render this file for me (too big I guess?), but Chrome does! If this can be prettyfied, I'd like to add them to the documentation somewhere. |
@Ismael-VC it can be opened by other application such as evince. To make it pretty, maybe it will help to divide the tree to subtrees at the first level. |
I vote +1 for This lead me to think on "an integer". Should it be
Don't know... You can skip this idea ;-p Definitely to stress the fact they are abstract is a huge improvement |
Should we close this? We made the change to |
We've seen empirical evidence that new users sometimes use abstract numeric types like
FloatingPoint
orComplex
in lieu of concrete types likeFloat64
andComplex128
. The result is that users end up with slow code or even wrong code due to operations over variables with types likeArray{Complex,2}
orVector{FloatingPoint}
. (For example: this comment in #4796)The unintentional use of abstract numeric types seems especially prevalent with
FloatingPoint
orComplex
which share common prefixes with concrete types. Other abstract numeric types likeSigned
orReal
do not seem prone to accidental misuse to the same extent.Suggestions for new names? I'd propose something like
FloatingPointAbstract
orAbstractFloatingPoint
to emphasize the abstract nature of the type. And perhaps something likeComplexCartesian
instead ofComplex
to emphasize the canonical (real, imaginary) representation and to distinguish it from polar forms or other more esoteric representations.The text was updated successfully, but these errors were encountered: