Base and Standard Library

With Julia 0.7 (and 1.0) “Base” and “Standard Library” seem to be different things.

Before (0.64 and lower), according to the Docs, Standard Library was the only library with module name “Base”, e.g. Base.exit and all the others.

Can you point me to some reasoning about this fact?

For me “Base” and “Standard Library” sound as synonym to each other, so why the distinction?

Base is all the stuff that’s actually needed for the core language. The “Standard Library” are just regular packages that are installed with julia. Some of the functionality previously contained in Base has been moved to their own packages, to make it easier to update them without having to update the language itself (looking for a source for that one, I’m fairly certain I got it from the release notes or an issue on the github).

I’m sure if you search a bit on this forum, you’ll find many more reasons though.


ok, I understand that, thank you.
I have searched in the release notes but couldn’t find anything on a higher level of an explanation, only details on specific functions.

My confusion about this started with reading this question:

Starting a new REPL (1.0):

julia> @which rand()
rand() in Random at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Random\src\Random.jl:222

so I thought rand() is from the “Standard Library” because of the path "…\julia\stdlib\v1.0\Random\src\Random.jl`.
Looking into the documentation is confirming that.

Assuming that “The “Standard Library” are just regular packages” I would expect that there needs to be some ‘using’ statement to use something from the Standard Library, which is not the case for ‘rand()’.

So there are perhaps some implicit imports in the REPL.

In the mean time it has been somehow answered with

But still it seems to be not a real answer, more like “it is that way because it was decided to be that way”.

Well, rand still is just part of the Random stdlib - but as that has to be able to update even faster than e.g. LinearAlgebra to catch regressions in randomness, it makes even more sense to have it as a package on its own. At the same time, access to rng is essential and really important, so it should also be easily accessible, in this case without having to do using Random. I agree that this hides its origin, and maybe it can be thought about in the future, but at the moment it seems like a good compromise. The only immediate downside I see is that it’s not apparent that you have to do ]up when you want to update the implementation of rand you’re using in case of a hotfix.

Take a look at the other packages in the stdlib, they’re mostly really just nice-to-haves that can also benefit from having a faster release cycle than julia itself.

1 Like

Actually, the generic function rand is defined (empty) in Base and then extended in Random (as explained in that linked thread). So no need to do using Random, the methods of rand defined in Random are just around. I think this is a bit different to other packages, for which the methods only come into existence after using that package. Presumably because it is backed into the sysimg.

1 Like