March 6th, 2004, 04:18 PM
Case sensitivity ads/disads?
Why would you design a programming language with case sensitvity in it's general syntax? (such as x and X being two different varibles) How does it help? What are its advantages?
(I'm not trying to bash python, I am just curious why this is a reaccuring theme with many programming languages)
March 6th, 2004, 04:32 PM
Originally Posted by ultimai
I don't think it is intended to be a nuissance, it simply is there to conform to the
ASCII character codes. Where 'x' is represented by the decimal value 120 and 'X' by the decimal value 88. As there are times when you want to use one or the other, it allows not only options in your coding style, but conforms to standards necessary for all computers to better communicate.
keep in mind that python still recognises both characters too. a x is still an x regardless of its ascii representation.
I hope that answers your question. let me know.
ltr = raw_input("enter ltr:").lower()
enter ltr: G
"In theory, there is no difference between theory and practice.
But, in practice, there is."
March 6th, 2004, 06:50 PM
Where i don't know the technical reason why - i've never really questioned it but - I actually find it pretty useful.
Mainly because it allows for multiple objects with the same name - each with a different case - but it also seems logical that they are different... then, maybe thats because of we're used to it that way!?
Case is also useful for passing info about the object around i.e. Python naming conventions say that class names should be writen as 'className' so its easy to see when we're talking about a class or a function.
[QUOTE]Its one of those things that you will never know the answer to ... and will proberly drive you insane if you try/QUOTE]
Hope this helps,
March 6th, 2004, 07:00 PM
caroundw5h, I think the original poster meant why are keywords, variable names, function names etc case sensitive.
I have used both languages that are not case sensitive (e.g. VB) and languages that are case sensitive (e.g. virtually everything else), and I think the main answer is that case sensitive languages are easier to read.
Consider this: you are looking at a program and you find a call to a function called "doStuff", so you scan through the listing looking for other references to this function. In a case sensitive language you know exactly what you are looking for. However in a case insensitive language it could be written as DoStuff, Dostuff, dostuff, DOSTUFF, dOsTuFf etc. Your brain has to do a hell of a lot more work just to find one function. Multiply that by all the variable, class and function names in the source code and simply reading the listing become a major chore.
When we read we pay more attention to the overall shape of the word than to the individual letters - this is why UPPER CASE IS HARDER TO READ than lower case and RAndOmLy MixEd-CaSE WOrDs aRe evEN HaRdeR. If you do not know what the shape of a word is going to be in advance then you are forced to read words letter by letter, which will reduce your reading speed.
Dave - The Developers' Coach
Last edited by DevCoach; March 6th, 2004 at 07:04 PM.
March 6th, 2004, 07:29 PM
I would say it is for, like DevCoach said, consistency.
March 7th, 2004, 12:11 AM
I personally find it annoying beacuse when you use third party libaries and such, the style tends to be different with each library, or changes ocassionally which can break your code and make you have to run things like pylint and do search and replaces through it.
March 7th, 2004, 05:22 AM
Gotta agree with Ulti, and even in the stadard library i'm still waiting got Python to enforce its naming and or conventions.
But i haven no problem with case sensativity as a hole and anything i write follows Pythons style guide as much as possiable.
March 7th, 2004, 08:58 AM
I was thinking the same thing when I started to used the Queue module. It starts with a capital, which it unusual.
Originally Posted by ultimai