FWIW, I would actually prefer a smaller Base namespace, with e.g. linear algebra as modules (neither external packages nor base), and a much larger library of modules provided. So more python-style in that respect. This is somewhat insubstantial, but would of course require a gargantuan code refactoring of everything (lots of using or import and qualified name use; I prefer the latter).
edit: larger library of modules provided: Pull in packages into julialang, as stdlib
Those are some of the biggest changes between Julia 0.6 and 0.7.
I don’t know if there’s any more overall now, but a lot of things – like LinearAlgebra and Random – are in standard libraries. You have to using LinearAlgebra before a mul! or svd now, and same for more niche random functions like srand.
I know, and I really like these changes! I just think they don’t go far enough, I’d like Base to be really slim and StdLib to be fatter. For example, what is quantile doing in Base? Why are StaticArrays and DataStructures not `standard library? More brutally, can’t we put regular expressions into StdLib?
Ideally, I’d like each module/namespace to be small enough to have a complete single html-page documentation that can be read cover-to-cover, just like the python standard library. You don’t think that every beginning julia programmer needs to learn how to write regular expressions? Then it does not belong into the Base namespace, imho.
I agree that a modular, rational and well-organized Base is a good to have. However, I hope we don’t push too far breaking things into pieces. Python takes things too far IMO; it doesn’t even include pi! Sometimes it takes me longer to find out which libraries contain the functions I need than actually coding a small quick script.
I’ve been asking that question myself (as well as moving BigInt and BigFloat into StdLib).
All three of those introduce large binary dependencies (PCRE2, GMP, MPFR) and are also not thread-safe
(not because of the libraries, but because of the bindings themselves).
In other languages such as Python, Rust, Go Regex support is done via a standard package (crate).
I agree. We should probably move stats functions like quantile out of Base, put them in StatsBase, and put that in the standard library.
Regexes could move out too, but they’re pretty widely used in Base itself. Tackling that would probably involve rewriting code to use weaker forms of string searching, moving out file/path-related code, moving out package-loading code, and more. Maybe doable, but a lot of work.
I looked at all of the uses in base, and it’s maybe not so extensive as you believe.
Also, all that’s really needed for v1.0 would be to make a Regex package in stdlib, that exports the macro r"…",
the actual replacement of the regexes used in base could wait until v1.1.
I found 37 regexes in 11 files, which seemed to involve fairly simple patterns that could be rewritten to not use a regex (and be more efficient, IMO)
I’d have to go investigate it again (I don’t know if you recall, I’d brought this up with you in person during the 2016 JuliaCon).
The global rounding mode and precision are the ones that I remember that still need to be fixed, I know that the other issue I saw then, with convert to string (and printing), has finally been made thread-safe.
The other issues that make me really want BigInt and BigFloat moved out of base is they don’t perform well at all, due to the impedance mismatch between the GMP/MPFR interfaces (which wants you to always be dealing with references), which requires finalizers (16-bytes extra for every BigInt or BigFloat on 64-bit platfoms, which don’t get freed up immediately and can cause a lot of memory pressure), and the issues with these types (like String) being semantically immutable in Julia, yet actually mutable.
Note that Dec128 is a lot faster than 128-bit BigFloats, precisely because of this impedance mismatch, even though you might expect for binary floating point to be at least somewhat faster than decimal floating point at the same size.
Part of the problem (at least with BigFloats), is that their API limits performance,
i.e. depending on a settable precision, which needs to be constantly picked up,
and needs to deal with thread-safety, instead of having BigFloat parameterized by its precision,
so that it could be stored as a primitive isbits type.
IMO, a bad API has ended up getting “baked into” the language, but it doesn’t need to be.
Ok, you’re right, that’s silly. Super basic stuff, like e, pi, expsin wants to live in Base namespace. But why gamma, beta, lgamma, etc? These are important and it is cool to have a good special function library that is shipped in the default distribution, but do they need to be global namespace?
I have no problem with regexps being a dependency of Base, but having them in the namespace sucks. Isn’t there a sensible way of having two separate namespaces, even if functionality is mixed?
The same holds for BigInt, BigFloat, and file-handling. Why not have an os module that contains all that stuff? Even if some base functionality depends on handling pathes / files, it would be good hygiene to make it a separate namespace.
Are we talking about this? What is the problem of just allocating a new Ref{Cint} everytime? We are allocating a BigFloat anyway, instead of providing an inplace version lgamma!(dst::BigFloat, src::BigFloat), so these handful of cycles shouldn’t make a big difference.
So even if a speed-up of 20% can be gotten by eliding this alloc, everyone who cares about speed must directly call into the C library anyway in order to skip the impedance mismatch.
I’d written a BigFloat package back two years ago, before JuliaCon 2016, that pretty much solved the impedance mismatch, but got stymied by the issues of making it thread-safe. I should have just pushed on and released it, because as it turns out, all of the threading problems still haven’t been fixed for Base BigFloats.
Ok, sure, I’m all in favor of separating modules and such, but I also don’t see why this is such a huge problem, or “sucks”. There are very few exported identifiers just for regexes, e.g. r_str and Regex. Why are these ruining your day?
Where did I say that would be a problem? What I actually did was file an issue saying that using a global ref for this is silly, and easy to fix.
Note: one thing I didn’t do back then, was make the desired rounding mode part of the type.
Since that is also something that causes problems from being picked up at run-time from a global value, that needs to be made thread-safe, it seems like that would be a good thing to make a type parameter, along with the precision.
I’d have to experiment with it, and of course, the math people would know better how to handle operations on two numbers with different precision and rounding modes, how to promote the values.
They ruin my day, because they aren’t generic (so won’t work with my Strs package), aren’t thread-safe,
and can’t be overwritten without it being type-piracy and people getting warnings.
If they were moved to stdlib, then somebody could do using StrRegex instead of using Regex, and everything would be just fine.
I thought that was precisely one of the big reasons for moving things out of Base and into stdlib, so that they wouldn’t be locked down with types that aren’t so good, and can’t be changed without being a breaking change.
Note: it would probably take a very short time to simply create a stdlib Regex package, that just had @r_str and Regex exported, and add deprecations in v0.7 as has been done elsewhere if @r_str or Regex are used without a using Regex.
The harder work (which didn’t look that hard to me, maybe a couple days?) of removing the usages of regexes from Base could happen then at any time, either before or after the v1.0 release.