CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2001
    Location
    Oslo, Norway
    Posts
    610

    Lightbulb How about a language that ignores underscores and case?

    Why should we fight on which coding practice is best?

    Most languages have long ago taken a step in the right direction, ignoring spaces and tabs for instance. This left people do have the coding format style they want.

    However, i feel that unnecessary restrictions on identifiers have been put. Why unnecessary? Because I think when one types:

    my_variable_1
    MyVariable1
    my_variable1
    My_variable_1
    My_Variable1
    My_Variable_1

    The human eye mostly associates all these with one and only construct.
    I, for one, always strongly objected C/C++ decision to keep it all case-sensitive. I see no benefits in case-sensitivity, other than the old excuse "because it keeps your code clean and safe from yourself". I welcome the idea of spitting out WARNINGS when a language encounters slightly different casing in references to the same variable name in the code, but i believe it is too much restricting programmer in the way as to refuse case freedom.

    Another big plus of ignoring underscores and casing comes when you realize it will stop programmers fighting each other on the topic of variable name convention. I had it several times, and as I acknowledge mine and my friends right to exercise the style they want, i cannot see another option than this proposal, except maybe doing it all "nazi" style - "Here at this company we use this coding style, and you SHALL use it."

    Ans since I mentioned a plus, i must mention a minus i guess to be objective (since i brag about freedom and objectivity). The minus is that
    probably it will not be such a good idea to mix variable names with their meaning, when such meaning relates to letters of alphabet. For instance you are coding a spell checker which hardcodes two words - "I" and "i" where the first refers to correct English way of referring to "myself", and "i" is the lazy wrong version of the former. You want to label variables as "word_I" and "word_i". There you have it. You cannot. However, as i mentioned, i doubt a reader of your code will instinctively differentiate between the two anyway, so the question is actuall whether such variable names are good at all, contra for instance "word_capital_I" and "word_lowercase_i".

    Good programming does not only come from using somebody's preferred variable naming convention or some "clean" API. It comes from interoperating different systems while keeping freedom to oneself to design the best way one feels about. And i REALLY believe impact on the programming world will not be as noticeable as some would like to have.

    What do you think about this proposal anyway?

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: How about a language that ignores underscores and case?

    Basically, you are arguing for 100% customization. However the programmer wants, that is what he/she gets.

    The problem is that without any basis whatsoever, you only create confusion and much more difficult task on the creators of a language. Why don't you write your own language then? You can solve this problem for yourself.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    May 2001
    Location
    Oslo, Norway
    Posts
    610

    Re: How about a language that ignores underscores and case?

    I believe 100% customisation is something ENTIRELY different than what i proposed. If what I proposed is 100% customisation, then it also means there can be no more customisation? What i propose i a small little "particle" among other parts of a system, and in no way is a "100% customisation". So, whitespace handling is a "50%" customisation" ? :-)
    Don't take it wrong way, i just need an explanation on how this is 100% customisation...

    I also disagree how ignoring case and underscore is a "difficult task" contra already so many difficult tasks every creator of a language faces. Compared to the average difficulty a language designer faces, implementing what i suggested is a minor low-priority (not without reason) thing. Besides, it in no significant way complicates language/compiler design, if you think about it.

    I did not mention wanting to implement my own language. Frankly it is irrelevant (as in let's not make it an argument) whether it is going to be me or somebody else, i merely shared my opinion and suggestion on the matter, and would like to hear arguments for and against, which REALLY do matter, and HOW they matter exactly in practice, what are the benefits and if these benefits outweigh the bad sides, which is what it is all about.

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: How about a language that ignores underscores and case?

    I think you misunderstand my point of 100% customization. By that I mean, not everyone can have exactly what they want. Since you are one programmer, chances are that many share your opinion. I personally, do not. Therefore 100% of the programmer population cannot be appeased. So those who create programming language would have to work twice as hard to make a solution suitable to both your view, and mine. Hence, it would be a more difficult task as well.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: How about a language that ignores underscores and case?

    Can i add in something here...

    1) Case Insensitive variables.: IMO The way MS use it in VB and in .Net are ideal.. When you define the variable, that is the case that is uses throughout the App, When you Reuse the variable in your code, the IDE automatically Updates the Variable Case to match how it is defined.. I personally use this as a method to ensure that when i use variables, they have been Defined. Also my typing sucks and i need to correct typo's continually, this helps me to check that all variables are typed correctly...

    2) Ignoring Underscoring.: This is not so easy.. Underscore is commonly known as a space replacement when space cannot be used. IE variable names. I have a high tendancy to use the underscore in variable names. This, i find, helps to keep the variables Readable.. its easier to read Tmp_Input_String_Data than TmpInputStringData which also at a glance, because of the descriptive name, tells me that its a String variable..

    Also independant studies show that the Brain battles to pick out words without some sort of seperator.
    Tryreadingthissentanceandpickoutwhatistheseventhword.
    Now we seperate it...
    Try_reading_this_sentance_and_pick_out_what_is_the_seventh_word..

    Looking at the first sentance you have to study it to get an answer, the second you simply count the spaces made by the underscore...

    Now if we going ignore the seperators that are in (with out removal) we land up with a mess of differently typed variables all refering to the same memory space.. this does not make for good programming ..

    Gremmy...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured