I don’t think Predef is the right place to add such things. Predef is not a teaching environment, it’s part of the core language.
Already having println
there (which should be actually called printLine
as the convention is camelCase, and abbreviations in code are pure evil) is imho kind of a smell. (One could argue that it’s a basic and necessary debugging aid, and I would agree I think).
If you want a teaching environment a toolkit
would be the right place, imho.
Toolkits could come with their own “Predefs”. (I think that would be new?)
Than you would just have one “using clause” to get your teaching environment; which could be designed by you however you please, for example with other short static aliases for most basic operations, before going into OO modularity later on.
This way your teaching environment would not “pollute” global namespace for all users of Scala. Because you know, using readLine
is actually extremely seldom, up to none existent, in real world applications (maybe besides “scripts”, which are a quite new type of application for Scala). In real apps you would usually use proper CLI handling libs (e.g. some readline
wrapper) which offer all the common things like parsing of complex commands, flags and options, validation, and instantiation of classes from user input, etc.
I think the whole toolkit thingy is much underrated currently and does not expose its whole potential. But it’s actually a pretty good idea if executed consequently: You could have custom “Scala environments” with all kinds of task specific functionality out-of-the-box just by using
the right toolkit. Curated toolkits as modular but opinionated frameworks (maybe with some online registry / catalog) would be really awesome!
Scala as language is extremely unopinionated, and that’s a good thing. But if you have a specific task at hand you prefer most of the time to use something already specialized to that task, “right tool for the job”, and so (except you want to build your own super customized and specialized thing, than something like vanilla Scala is actually great OOTB). Toolkits are the right way to resolve this dichotomy I think. They could give you some ready to use environment that’s specialized to some task category.
At the same time toolkits are very flexible. In the end they’re “just” a collection of libs, and maybe a custom Predef if this idea gets picked up. As your app grows and your requirements get less typical you can easily fork and modify a toolkit definition, or ditch it completely and replace with module specific sets of imports (even it seems that people are actively asking to have some “common imports” quite often; there is an active thread about that again; easy to create custom toolkits could also solve this issue).
So I would really like to see the toolkit feature expand and get some more love.
I think it could work like the task meta-packages in Debian Linux. In case you’re not familiar with this concept have a quick look at the following:
https://wiki.debian.org/metapackage
https://packages.debian.org/stable/metapackages/
Also note in the description of how tasksel
works that it supports pre / post install scripts; a handy feature Scala toolkits could also pick up I think!
I would place this feature in Scala-CLI. (As it’s the “apt” of Scala). Something like:
$ scala-cli setup ${environment}
Result should be a project directory you could open with something like Codium with Metals. Maybe just containing a worksheet file with a using toolkit ${environment}
line, maybe a full blown pre-configured project with some skeletons, or whatever is typical for the task at hand…
But it could also install all kind of stuff (like Codium + Metals if not present, or WSL on Win) if the pre / post install scripts idea was implemented.