If some naming conventions, such as uppercase-method-names, are so frowned upon, why do languages allow them at all?

StackOverflow https://stackoverflow.com/questions/22693967

Question

Is there a practical or historical reasoning behind languages allowing the most egregious naming convention taboos? The two most obvious examples are uppercase function names and lowercase class names, which I often see violated in stackoverflow newbie questions.

There is no style-justification that I know of where you can do these things, so why are they even allowed to compile? At the moment, my theories are

  • It was not such a taboo when the language was built,
  • It would make some important edge cases impossible, or
  • It's not the language's job to enforce good style.

I can find nothing on this topic (some links are below).

There are some conventions, such as underscores beginning variable names, or Hungarian notation (the latter of which I have been personally disabused of in comments) that are not overwhelmingly accepted, but are less divisive.

I'm asking this as a Java programmer, but would also be interested in answers form other language's.

Some links:

Was it helpful?

Solution

Coding style is like writing style. If you write in a style that is diFFicult TO READ And does not read very well your mINd hAs GReat diFFICULTies actUally understanding what you are reading.

If, however, like in normal reading text - it is laid out in a form that matches well with what your mind expects then it is clear and easy to understand.

On the other hand, if the language actually FORCED you to write everything using EXACTLY the the right syntax then not only would it make coding slow and awkward but it would restrict your expressiveness.

Many years ago I came across a language that allowed you to add strange symbols to variable names. Users were allowed to do thing like:

var a=b = a = b;
var c<d = c > d;
if ( a=b & c<d ) ...

i.e. a=b was a perfectly acceptable variable name, so was c<d. As I am sure you would agree, this led to many mistakes of interpretation. Even if a new language allowed that I would not use it. Coding standards are for consistency and helping the human mind understand, syntax is for helping the computer mind understand.

OTHER TIPS

Depending on the language designer's intent some languages are more opinionated than others when it comes to implementation and how the designers think things should be done.

The easiest example I can think of right now is Go, which has unit testing and code formatting built in. The designers are of the opinion that things should be done a certain way and they provide you the tools to do it.

Other languages do nothing of the sort like Scala where the language designers were very unopinionated in their implementation and supply you the tools to accomplish any given task in 10 different ways.

This isn't to say that some languages are built under tyrannical rule and others are extremely loose with their requirements. Its merely a choice made by the language designers which we end up having to live with.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top