I was lately doing some research about different programming languages. I was interested particularly to learn unique features of popular programming languages and situations where these assets shine. I believe this can help me to decide what language to use depending upon the problem to solve.
I found that many languages offering high level of flexibility ("can adapt to new, different, or changing requirements") are also inconsistent, for example in JavaScript (just an example, no offense to js people), arguments of a function get be manipulated either by naming them in the function declaration (classic approach):
function max(x,y)
Or by using the arguments
variable:
function max() {
if (arguments[0] < arguments[1])
return arguments[1];
else
return arguments[0];
}
c = max(1,2);
The arguments variable is useful for many situations such as function overloading, however, it defeats the purpose of function prototyping (which is to give information about the function), and I saw many JavaScript samples where the argument variable is being used despite there is no need for it, which clearly makes the code harder to understand and debug.
I know that this depends heavily on the users of the language, but usually, code written in a language offering high flexibility tends to be unsafe, harder to understand,optimize and to debug.
Do flexibility and inconsistency overlap? How do languages designers make the choice?
Edit: I'm not critiquing any particular language here, I'm rather focusing on the relation between Flexibility,Safety,Consistency of programming languages.
arguments
object in a situation where named arguments could be used instead like your example implies.arguments
for all of them (which, IMO, is usually easier to read, since the named arguments would still show up inarguments
IIRC)