The way the default environment works is somewhat confusing and, I think, unsatisfactory. Most users, except package developers well versed in development workflows, will always use packages by installing them in the default environment. That causes progressive bloat of the environment and dependency issues, as we know.
Thus one idea that came into mind these days is the possibility of a “draft”, or “scratch”, environment. This environment would be temporary, but with the following properties:
-
using Package
would mean a slightly different thing: if the package is available locally for being installed at any other environment, this would trigger its installation in the “draft” environment with the most recent version available (without fetching any info from the web!). Ideally, the return fromusing
would provide that information:
julia> using StaticArrays
StaticArrays installed from local install at version v1.3.5
(is there any reason for this to be much slower than using
the package in an environment where it is already installed?)
-
If the package is not available, just do what is done now (ask if one wants to install it).
-
At any moment one could “save” the draft environment, giving it a name, and from then on it would behave as any other specific environment we currently create.
-
If the environment is not saved, that does not imply anything for other environments, except that if some new package was installed it may be available through the quick install route in a new different draft environment.
The reason for this would be:
By starting Julia in a draft environment, a user can use and add packages without bloating the “default global environment”. The experience would be similar to just adding stuff to the current default environment, but without some of the downsides.
Someone could worry about the fact that packages can get outdated, but it is more common and natural for people to update things when required or when things seem to go wrong (with the expected download, compilation, and install cost).
Something like that could isolate the default global environment, in particular, and that is what I was thinking, Julia started by default in a new draft environment. With that, the natural workflow of just opening julia, using or installing the packages one wants to use and doing the job, would be non-intrusive for the general experience in the long term.
All the rest, meaning, all other environments, could continue to be exactly as they are, including the default environment, with the sole exception that one would need to explicitly switch to it if one wanted to add a package to it for some reason. Using environments would be then a nice developer feature instead of an imposition that comes to the table sooner or later for every user.
As usual, I guess that are many good technical reasons things like this not be simple, and good reasons for not be desirable at all. But who knows, maybe it is an idea worth exploring.