I was reading this post and it left me wondering...
Why is it wrong to use a variable named _
in C#
for a intensively used library (should one ever surface), but perfectly fine to use $
for the same purpose under JavaScript
?
Arguably because _
(as a variable name by itself) carries no meaning, and a longer/more meaningful identifier doesn't take much longer to type (with Visual Studio's intellisense). Not to mention the fact that the C# compiler won't "penalize" you (in terms of increasing the size of your compiled program) for having a longer identifier.
In the case of jQuery, however, using someIdentifier
instead of $
actually does increase the final size of your javascript file. By a couple of characters, sure -- but multiply that by a couple of orders of magnitude (number times repeated in your file, number of times your file will be downloaded by a client's browser, etc.) and a few characters could start to matter, especially if your site experiences a lot of traffic.
Finally, you also have to take into account the community involved. In the Javascript community, for example, jQuery is so commonplace that even if you don't use it in your application, anyone remotely familiar with it will know what $
means. There's nothing in C# (that I'm aware of) that has that level of visibility, and since it's a compiled language with a powerful IDE, there's really no need for a jQuery-like "$
"-equivalent prefix.
My two cents.