by xjay · 10y ago · 0 comments
I'm against the case-sensitive nature of some programming languages, and file systems for that matter. While it makes sense in a computing context (faster), you invent a new mode, just for the computer..
(Fortran was probably case-insensitive because upper-case letters were used first, and when lower-case letters were introduced, care was taken to neatly map them into the character set bit-wise, so one could simply clear the sixth binary digit to turn a lower-case letter into its upper-case equivalent, then continue the string comparison.)
Of course, with Unicode, you need a more complicated check, or you could just ignore Unicode in the language itself for identifiers, yet allow it in literals, data types, etc.
At least Tcl allows spaces in identifiers, but to 'use' such identifiers one does have to add a bit of extra 'sugar' to prevent the code parser from interpreting the spaces as token separators:
Example of spaces in a variable name:
$ rlwrap tclsh
% set "var name with spaces" "contents of the variable"
contents of the variable
% puts ${var name with spaces}
contents of the variable
% set "var name with spaces"
contents of the variable
Example of spaces in a procedure (function) name (the first line defines the procedure): % proc {my space proc} {string} {puts "'my space proc' called with string='$string'"}
% {my space proc} "hello how are you"
'my space proc' called with string='hello how are you'
% "my space proc" "the quick brown fox"
'my space proc' called with string='the quick brown fox'
% set pn "my space proc"
my space proc
% $pn "this that and the other"
'my space proc' called with string='this that and the other'
So there you have at least one example.The IMO better way to solve this is to set a convention for your programming language and enforce it with the compiler (at least with warnings).
Keep in mind we wouldn't need to care about enforcing case in a style guide, if case didn't matter, because there are no distinctions, and you'd be more inclined to write it the natural way; no camelCase to overrule ambiguation in writing "MIDI Port" as midiPort, or MidiPort, MIDIport, etc.
Case-sensitivity only creates unnecessary dissonance, and leads to clever uses of that system, adding even more choice; and as we know from The Matrix, the problem is choice. ;)
So if we keep it closer to how we would normally read and write words, I think there would be less dissonance about that aspect of programming, or naming files for that matter.
You would still need it to get uniform code. Spaces vs. tabs also doesn't matter but it's still in almost all style guides.
Newton-Raphson Runge-Kutta Fast-Fourier-Transform
Class-ID IO-Channel MIDI-port
Freudian-Id Io-Channel
In contrast to this, I feel it makes sense to have lowercase mean that something is private. Hence, no camelCase: x y z variable longer-variable-name
I've never been that comfortable about appending numerals to the end of identifiers to disambiguate them as I feel that this is a sign that they ideally ought to be subscripted and implemented as arrays. I much prefer hyphens to underscores but would ideally like to use individual words separated by spaces. This can only work if you have an IDE that hides all the underscores (which are incredibly ugly and serve no useful purpose in printed material these days) as you input them and outputs NBSPs instead and then uses similarly suppressed prefix sigils to style your raw input text into an output which conforms to traditional Mathematical notation. Hence, we could have: /foo_bar + /bar_qux
become:foo bar + bar qux
similarly, the following is not a problem if you take advantage of the syntax rule that requires at least one space either side of an operator. Hence, we could have:
/foo_bar / /bar-qux
become:foo bar / bar-qux
i.e. the / sign isn't echoed when you initially type it as it is expecting a letter, but when the IDE receives whitespace it belatedly echoes it as the operator symbol as it is now sure that it isn't a suppressed sigil.
I don't see that case-sensitivity helps to achieve uniformity of code that much. Factors like code structure, common design patterns, and source code formatting are more important. The approach to the structure and design of an application or library is something that each individual development group decides for themselves. Source code formatting can (and should) be enforced by formatting tools.
Having used a case-insensitive language for a while (Object Pascal) I find that developers tend to follow the case convention of a given software project anyway and if they don't the case-sensitive typos aren't an issue. They don't make the code harder to understand and it all compiles.
It actually drives me a little nuts that I can't do the same thing in Elixir (compiler enforced lowercase) because so much of the code looks the same.
(let ((|This variable has spaces| 1))
(print |This variable has spaces|))http://pogoscript.org/guide/variables.html http://www.nongnu.org/argile/ http://tibleiz.net/zinc/identifiers.html
I found some more tidbits in these StackOverflow answers:
http://programmers.stackexchange.com/questions/145751/has-wh...