Speculations about the default environment (or a new draft environment)

This is the recommended way to work with it, but it is a symptom of a problem. Julia should not start by default in a state (an environment) where it is not recommended to work.

That may suggest that Julia should start in a temporary environment. The problem there (or any other environment) is that adding packages that were already installed before is too slow, or can even be broken if one has not internet access at the moment. This is an annoyance with Julia that I don’t know with any other production environment (and I understand to a point the reasons for that, given the particularities of Julia). In most production environments one installs a package and that makes it locally available to be used.

Let us not mix the TTFP issue here, it is that I’m referring to. I am talking about the fact that add a package has inherently a lag because that tries to fetch the registry from the server and, if it finds a newer version the package the whole process of updating etc is triggered. There is a workaround for that. But that does not solve the problem that at end one is obligated to repeatedly add packages to temporary environments all the time to experiment things.

Given the fact that, if one sets Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true, adding a package is (generally) fast, it would be a reasonable (IMO) for Julia to start, by default, in a temporary environment with that option turned on and, additionally, in which using just did add + using with a more concise output, such that the experience would be similar to just using in an environment where the package is already installed (or if it was installed in the default environment).

That would allow the general user to just start Julia, add packages, eventually using packages, without worries about bloating the default environment, which could still be accessible but only for specific and unusual operations, like adding the few packages we want to install there.

If that temporary environment could then be saved, that would be a nice way to introduce the use of environments to new users. (this is a feature which, if not available already, would be nice to have for temporary environments in general).

Thus, to summarize, I think it would be nice to have a kind of temporary environment that in which package adding was incorporated to using such that the experience would be similar to a temporary environment but with the packages installed in the default one (in terms of responsiveness). That would imply assuming an updated registry by default and just adding the local copy of the package when it is available.

I also think that the regular user experience would be improved if that was the default way Julia was launched.

In the current state of things, it seems to me that almost every Julia script should start with

import Pkg
Pkg.activate(temp=true)
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true
Pkg.add("Package1")
Pkg.add("Package2")

# Here is where it should really start
using Package1
using Package2

Thus, my idea would be that a draft environment would be something that incorporated the first 3 lines of that header, and merged add and using whenever there is a local copy of the package available.

13 Likes