--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/a3f79568-10d3-49b0-a93f-a1bcf7054c59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4Je_JcgPxKo_rCtYkHhdUzT2HOtP5GeT%2BqVtXV6vXgPXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
@doc time: "O(n)"
@doc space: "O(n^2)"
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/7e570c16-9cbc-44af-a42b-18b4f39f2742%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BX2LWZ2Z4xDxa67ovo8rtWOJjVqc_8oy5ukWoE-kiZCg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/70b115b3-2d8b-4e61-a837-0a7a224b4ef8%40Spark.
I'd like to actually argue against this addition.For one — it adds complexity to the documentation - you have to know what the big-O notation means in the first place — I'd argue it will make the documentation less approachable for people without formal CS education. It only becomes worse with some of the more complex data structures that feature "amortised" or "expected" big-O performance. To give just one example - all operations on maps implemented as HAMT are rather complex to express in this notation and would probably need a paragraph if not more to explain.Secondly, it might prove problematic in a way that it bounds the standard library not to change those in the future. Changing an implementation where it would affect the complexity of the function could be considered a breaking change. I believe that for that reason, for example, the Rust standard library does not feature such documentation in general.But there's also a much bigger issue and that's if this is actually useful in real programs beyond most simple divagations. Modern computers with out-of-order CPU execution, expensive and complex caching mechanisms and other such features mean that the classical notion of big-O notation rarely directly reflects on real-world performance. Even worse if the function at hand allocates - should it also consider the potential impact it could have on garbage collection? There are numerous algorithms that theoretically should be worse, but are much better in practice. I fear that adding such information would lead to people deciding which potential implementation is better just by looking at that documentation instead of benchmarking for their own use case, which is the only reliable method of testing for performance.To summarise - I think this will only add additional, superfluous information to the documentation that is of questionable usefulness but that might prove problematic in the future.
Michał.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/7e570c16-9cbc-44af-a42b-18b4f39f2742%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/7442e39a-5926-4b80-8a9d-fd28173bb7ba%40googlegroups.com.
The Big-O annotation practice is not to write "O(2n+3)" but to reduce this to its pattern of asymptotic growth, which in this case is simply "O(n)".
Among the several existing predictors, Big-O is the one generally used and that people are most aware of. It is also the one that predicts the worst-case asymptotic performance an algorithm can get when systems are put under the stress of large inputs. Adding other indicators introduces unnecessary complexity and confusion, which obviously is not what we want in our documentation.
In general, the "n" relates to the number of elements in the collection, and I suppose that in cases of functions involving two collections, they can be annotated with something like "O(n+m)", where "n" and "m" are the number of elements in each collection.
These are very simple expressions every software developer should know or be interested to learn for the sake of understanding algorithms better and the quality of the software systems they write.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/d8bd66d7-4328-4c2d-8d9b-19002a8d6bc9%40googlegroups.com.
@doc time_complexity: "O(n) if n < 32, otherwise O(log32(n))"
I agree with all of the points made by Michał and Paul. Additionally, most functions will never need to specify this information. In the few cases where you might want to specify this information it seems like it would be very reasonable to use module docs and function docs. This is especially true because asymptotic time _isn't_ the most useful way to measure immutable data structures. Often you'll want to look at both asymptotic and amortized time complexities. But even if we set amortized time to the side for a second, how would you document a data structure that internally uses a list until the list size reaches a certain amount and then switches to a HAMT with a branching factor of 32? Do you say that searching this data structure is O(n) when n < 32 and O(log32(n)) when n >= 32? In my mind putting this information in the module doc is clearer and allows me to write a full explanation.It seems to me that the core problem is communicating relative performance of different data structures and algorithms. I don't think this proposal is needed to solve that problem and it creates more complexities than benefits.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/d8bd66d7-4328-4c2d-8d9b-19002a8d6bc9%40googlegroups.com.
--Chris
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/e6919fe4-9bb6-4894-93ce-8ac4f4255869%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGjNwxqnSm4sya_zwUWzxDTmF3HxgcAK%3D3abGsxFqvTE4NU%3Dpg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGjNwxqnSm4sya_zwUWzxDTmF3HxgcAK%3D3abGsxFqvTE4NU%3Dpg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAF7CYk66Y9JN-rxr7mznstyz%3Db%2B_aSwW77pO1wROw8EGZ5Ypzw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGjNwxrOhv0u%3Doy_iAqPmOsRObJ00gnyH2jXE-B%3DGq22ZaDKvQ%40mail.gmail.com.