#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    2
    Rep Power
    0

    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)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Canada
    Posts
    185
    Rep Power
    0
    Originally Posted by ultimai
    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)

    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.
    ex:
    Code:
    ltr = raw_input("enter ltr:").lower()
    
    enter ltr: G
    ltr
    g
    I hope that answers your question. let me know.
    "In theory, there is no difference between theory and practice.
    But, in practice, there is."

  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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,

    Mark.
    programming language development: www.netytan.com Hula

  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    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.

    Regards,

    Dave - The Developers' Coach
    Last edited by DevCoach; March 6th, 2004 at 08:04 PM.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    217
    Rep Power
    0
    I would say it is for, like DevCoach said, consistency.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    2
    Rep Power
    0
    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.
  12. #7
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.

    http://www.python.org/doc/essays/styleguide.html

    Mark.
    programming language development: www.netytan.com Hula

  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    217
    Rep Power
    0
    Originally Posted by ultimai
    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.
    I was thinking the same thing when I started to used the Queue module. It starts with a capital, which it unusual.

IMN logo majestic logo threadwatch logo seochat tools logo