On Tue, Dec 24, 2013 at 01:05:26AM +0000, bearophile wrote: > H. S. Teoh: > > >Personally, I'm for simplifying the core language and moving > >non-essentials out to the standard library > > How do you define "essential"? > - Frequently used;
I don't think 'frequently used' is sufficient to justify putting it in the core language. If a library type (1) provides the same functionality, (2) compiles to equally-efficient code, and (3) isn't overly ugly to write, then I'd go with the library type. For core language features, I consider orthogonality much more important. That is, if existing features can already do what the prospective feature can do, then it's probably better to put it in the standard library. A good candidate for inclusion in the core language is a feature that, if it were not in the language, would cause some things to be impossible to achieve (or to be achievable only with difficulty). Ideally, the core language should be as minimalistic as possible, and provide only the truly essential features that the standard library can build on. There are a lot of advantages of a small core language: easier to implement, so more likely to be bug-free; reduction of the combinatorial explosion of features that introduce many hiding places for bugs / unexpected interactions because there are too many combinations of features to test; easier to reason about; etc.. Of course, in practice you can't be overly minimalistic, otherwise it becomes painful to do simple things; the adage is, "simple things should be easy, hard things should be possible". > - The compiler can compile it as efficiently as handwritten code; If the library implementation can be equally efficient, then this isn't a good reason to push the feature into the core language. > - Has a sufficiently clean semantics, that is most times the one > that's desired; But isn't this an issue with in-compiler implementations too? An ill-defined feature is an ill-defined feature, no matter whether it's implemented in the library or the compiler. Though I agree that if a compiler implementation has cleaner semantics than a library implementation, then the compiler implementation would be preferable. > - You can't (yet) implement its main purposes with library-code; This is a big reason to extend the core language, although even in this case I'd rather add only a minimal extension (not necessarily the entire feature) that makes it possible for library code to implement the feature, then put the actual implementation in the library. > - Sufficiently important. [...] Important as measured by what? Important features can be part of the standard library too -- that's why it's the *standard* library, after all. It's a different story, of course, if said feature can't be adequately implemented by the library, but that's nothing to do with its importance, rather it's just a matter of extending the core language just enough to be able to implement it properly. Importance doesn't necessarily dictate that the feature must be implemented in the core language in its entirety. T -- INTEL = Only half of "intelligence".