Disclaimer: I know there is no strictly correct answer to this, but I've come across something that does not make sense to me, and I'd like to try to understand it better by seeing what other people have to say on the subject.
$() function (and also things like
$E(), and so on), and was wondering why they do it. This is basically what I came up with:
- The name
$does not imply anything semantically meaningful by itself.
$is a property in the global namespace, and thus can only be claimed by a single framework at any given time.
- Having multiple frameworks competing over the same global name(s) makes them less easily compatible with each other.
- Older code that uses the
$()function defined in one framework can be accidentally broken by simply importing a second framework that provides its own version of
- With everybody providing a different version of
$(), code becomes less readable because one cannot make assumptions about what
$()is doing without knowing what framework is in use.
- Sometimes novice developers get the wrong idea from all the dollar signs flying around, and think that they need to prefix all their function declarations with "$".
So it seems to me that the cons far outweigh the pros. Which begs the question, if there are so many negatives associated with claiming
$() as one's own, why do many frameworks do this automatically? Are there some other benefits that I am missing?