Programming Language and Library Functions

What should the creator of the programming language include in the language or delegate to libraries?

To begin this reflection, let us recall some elementary definitions.

Programming language

This is a set of instructions, with grammar, to communicate with the machine and indicate to it the tasks to be completed.

Library

This is a set of functions that extend one language and can be used by different programs. They are written in the language, can contact other libraries. The functions of a program can be separated from it so that it becomes a biblio, and they can be shared between several programs.
Most languages ​ ​ have a standard library that must be included in any program.

RED SMALL APPLE
The Application Programming API is a standard interface for a library that can be used by all programs written in the same language. This includes only names and arguments of functions and statements of classes and their members. The library can be rewritten with different code, but retaining the same API.

Now it remains to be determined what should be part of the semantics of the language, that is, all reserved words whose commands, or what should rather be included in the standard library. This does not matter to the user, as the standard biblio is always available with an interpreter or compiler, but for the creator of the language it is an imperative of clarity and consistency.

A priori, you should include in the library everything that can be determined from the language, and include in the language commands that cannot be determined from existing commands .

But some commands are so frequent that it is customary to include them in the language. This applies to keyboard input, console display, and string processing functions. However, they could also be included in a standard library .

For example, print, echo, etc. These commands are part of the JavaScript language and PHP, but in C part of the standard library. The two processes appear to be interchangeable.
The inclusion of functions in a language is not based on a theoretical principle, but on a purely practical aspect: what is often used is built into the language.

Role of operators

But the reason that best justifies inclusion in the language is the possibility of using language operators. For example, I imagine an object type called "entity." This can be a class declared in the library, but if language operators can perform operations specific to a given object type, for example, if the + operator allows you to add an attribute to an entity while it cannot do so on a regular object, then you need to include this object type in the language itself.

Tendency to overlap

The JavaScript language has language functions for concatenating strings, adding a string and a number (bad idea). But it also has a String object with manipulation methods such as slice, splice, replace, etc.
The same goes for PHP, unless it's functions like substr, str_replace, not methods.

What can be said about strings also applies to arrays in JavaScript and PHP.

JavaScript has some integration of the regular expression function into the language. For example, you can write:

var x = /abc/

Then use x, which is a regular expression, as a parameter of other functions.
In addition, the language has a RegExp () object, which has a regular expression as an argument and whose methods are applied to character strings.

In conclusion, it can be seen that the authors are unable to distinguish the border between language and library and there is an overlap between them.

You can also express the language entirely in the form of functions, this is the principle of functional languages ​ ​ such as Erlang and involves the intensive use of recursiveness. What makes the program incomprehensible without concentration efforts. The grammar of the language is also intended to make it easier to read and therefore less likely to make mistakes .

Conversely, C++ allows overloading operators and therefore translating methods over objects into language syntax...

Do I need to be stricter

?

And to bring the language to the maximum, not to integrate into it any functions that could be placed in the library...
There is everything against. If you reduce the language to the required syntax and exclude any functions from it, the grammar will be simplified. In the case of a compiler, this will not change the execution speed much.

On the other hand, the expression in the syntax of the language, actions on objects, as C++ does, improves the readability of the program.

Statements in the form of a function, such as print (...), opposite print "xxx," must be part of the standard library.