[Haskell-cafe] Why shouldn't variable names be capitalized?
brianh at metamilk.com
Fri Aug 4 20:25:27 EDT 2006
Martin Percossi wrote:
> Hi, I'm wondering what the rationale was for not allowing capitalized
> variable names (and uncapitalized type names and constructors). I can
> only think of two arguments, and IMHO both of them are bad:
> 1. Enforces a naming convention. Fine - but my view is that this
> doesn't belong in the language definition (it belongs in the user's
> coding standards).
If everyone uses the same coding standards it's easier to understand other
people's code. Also, if you're working in a team you'd usually have to agree
to adhere to someone else's idea of how to name identifiers which you might
find really irritating, whereas with Haskell there is at least some global
common ground that has already been established so there would be less
reasons to get irritated with actual people! ;-)
> I get annoyed, for example, that when I write code
> that manipulates matrices and vectors, I can't refer to the matrices
> with capital letters as is common in the literature.
But you also can't write things like:
v' = M v
in a general purpose programming language and expect it to be interpreted as
v' = M * v.
> And to anyone
> who says that it's good to enforce naming consistency, I have this to
> say: Any language that requires me to learn about category theory in
> order to write imperative code should treat me like an adult when it comes
> the naming of variables as well. ;-)
But it does! Haskell realises that as an adult you are more interested in
getting as much feedback about the correctness of your program as possible,
rather than glossing over possible errors to maintain an illusory world
where the lure of extra choices magnifies childish whimsy! ;-)
> 2. It makes it easier to write the compiler. I don't think I need to
> explain why this is bad...
Why would you say this? If it's easier to write the compiler the chances
a) The compiler will have a simpler and cleaner design
a1) There will be less bugs in the compiler
a2) It is easier to modify so more language improvements can be explored
b) More people will be motivated to write or modify compilers or other
language-processing tools leading to improvements in the language and better
> I imagine that someone is just itching to "sort me out". Do your
> worst! ;-)
The extra coding confidence you gain by having a fixed capitalisation rule
probably allows you to feel more relaxed when coding so I would not be
surprised if the capitalisation rule leads to health benefits and therefore
a feeling of peace, well-being, and goodwill towards other coders because
either one is in agreement or else there is a common enemy namely the rule
that cannot be changed! ;-)
All we can do is pity those poor C++ souls locked in an abyss of inflated
personality, case conflicts, chronic anxiety, and bug ridden code...
Best regards, Brian.
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.
More information about the Haskell-Cafe