On the subject of SQL Server connection strings, Microsoft says:
When specifying a local instance, always use (local).
The implication is that using
localhost is a bad idea. But why? Or am I reading too much into the wording?
This is from memory and without reference so my recall may not be accurate.
IIRC for 2005+ "(local)", "localhost" and "." are equivalent and will use the Shared Memory protocol. Prior to 2005, "(local)" and "." would use Shared Memory whereas localhost would not necessarily do so by default. Use of machine name or FQDN could result in a DNS lookup so is not recommended for a local machine connection.
Lastly, the "(local)" term (including brackets) is a special keyword, rather than a reference to the local machine.