Why is it bad to start a variable name with a dollar sign in C++/Java and similar such as in PHP?
Edit: Are there any risks?
Why is it bad to start a variable name with a dollar sign in C++/Java and similar such as in PHP?
Edit: Are there any risks?
Java allows the dollar sign to begin identifiers, but recommends that it only be used for mechanically generated code. (see here)
It appears that in C++ identifiers may be able to use dollar signs as an extension, but it's not part of the standard.
Because in both C++ and Java doing so would be a syntax error (in the case of C++) or bad style (in the case of Java). Neither of these languages need variables to be so indicated, and doing so is wrong. Starting variables with a special character (like '$') makes things a lot easier for the language system (which is important for interpreted languages like PHP), but makes life much harder for the programmer, because they have to type in all those '$' characters. So most languages (even most interpreted languages) don't require them.