lowercase keywords?

One of the raps that VB sometimes gets is that we’re too “verbose.” There are a few things that we think might contribute to this perception that we’re looking at for the future, but I had an interesting flash the other day. I wonder how much the fact that we uppercase our keywords affects our perception? So I built a bootleg of the compiler and tried it out on some code of mine. Before:

        Private Function ParseSimpleNameExpression() As SimpleNameExpression
            Dim start As Token = Peek()
            Dim name As SimpleName = ParseSimpleName(False)
            Dim typeArguments As TypeArgumentCollection = Nothing

            If Peek().Type = TokenType.LeftParenthesis Then
                Dim leftParenthesis As Token = Read()

                If Peek().Type = TokenType.Of Then
                    typeArguments = ParseTypeArguments(leftParenthesis, False)
                Else
                    Backtrack(leftParenthesis)
                End If
            End If

            Return New SimpleNameExpression(name, typeArguments, SpanFrom(start))
        End Function

After:

        private function ParseSimpleNameExpression() as SimpleNameExpression
            dim start as Token = Peek()
            dim name as SimpleName = ParseSimpleName(false)
            dim typeArguments as TypeArgumentCollection = nothing

            if Peek().Type = TokenType.LeftParenthesis then
                dim leftParenthesis as Token = Read()

                if Peek().Type = TokenType.Of then
                    typeArguments = ParseTypeArguments(leftParenthesis, false)
                else
                    Backtrack(leftParenthesis)
                end if
            end if

            return new SimpleNameExpression(name, typeArguments, SpanFrom(start))
        end function

It’s a little frightening how much just changing the casing of our keywords makes us suddenly look like C#, at least to my eyes. I’m curious what people think of the idea? Would you like to see us switch to lowercase keywords? Provide an option?

(My replies to this entry maybe a bit slow–I’m going to be on vacation for a little while, but something to think about while I’m gone…)

61 thoughts on “lowercase keywords?

  1. Einar G.

    I am started as VB developer but now I am in company that is using C# I dont care wich one I use. Both using the same framework and that is the most complicated part to learn.

    There for I ask: "Why is it frightening to suddenly looking bit like C#?"

    Personaly I like lowercase better. Even tough I like VB none case sensitive variables more over C# way of doing it :-)

    Reply
  2. Ben

    Case of the keywords doesn’t make much of a difference to me. I think being able to just write End to close code blocks would do more to abbreviate the verbosity (leaving the trailing block keywords as an option, of course)

    Reply
  3. Don M

    I would vote for the lowercase version. I think it helps the keywords become less of the focus and blend into the background a bit. It lets you more easily see the important part of the code. To me, the uppercase keywords are a little like people who SHOUT WITH ALL CAPS.

    Of course, this would cause tons of casing wars. People checking in code just to change the case, etc. Maybe it’s not worth the effort.

    To be honest, I haven’t used VB in years – so I’m not sure my vote should count. C# feels much more clean to me. I don’t want to start a C#/VB war, but if you want more info, let me know.

    Reply
  4. dmurillo

    Wow… the lowercase keywords look really cool.

    I’m a big VB fan and wouldn’t mind at all to be forced into using lowercase keywords

    DM

    Reply
  5. Miles Archer

    If you leave it as non-case sensitive, then it’s just pretty printing. I think I’d prefer it to be the way it is now, but I’m not dogmatic about it. If you make it case sensitive, it might as well be C#.

    Reply
  6. Jonathan Allen

    I always thought lowercase keywords looked childish, like someone too lazy to bother capitalizing sentences.

    Looking at the side-by-side, I now think that was foolish. I’m not saying that I now think VB looks better in lowercase, but rather that I see no difference. My mind seems to parse both versions equally well.

    Reply
  7. Christopher

    Why not, in VB having options make senses.

    we have option for enforces explicit variable declaration or not.

    we have option for implicit data type conversions.

    We have (sadly) the possibility to use a default instances to handle a form (a terrible mistake in my opinion).

    So unlike C#, VB.NET allows people to use the language as they like… so I think it may be a good idea to let people choose the casing of keywords.

    And why not, an option to stop the backgroup compilation which can be annoying when you paste a large amout of code from another project (you have not the time to correct the syntax and you have one hundred errors !!)

    By the way VB.NET really rocks, I use C# sometimes but I love code with VB. I have never had such a pleasure since the good time of hacking my Atari 520st !!!

    Continue this good work, the next features (linq et co) seems great !!

    Sorry for my poor english (french inside)…

    Reply
  8. Bill McCarthy

    I actually like the increase in whitespace lower cases gives us, but not everywhere. I’d still like ProperCase for keywords like Private and Function.

    Ideally what we should have is a dictionary for keywords, where we can specify the case used by pretty formatting. And even nicer if we could have colours i n that dictionary as well.

    <keywords>

    <keyword name="Private" casing="Proper" color="blue" />

    <keyword name="Dim" caisng="lower" color="grey" />

    ….

    </keywords>

    Then load this into memory when VS starts, and pretty the code accordingly :)

    Reply
  9. Boris Yeltsin's Zombie

    I prefer the proper title-cased keywords myself, as it is now.

    I never actually type the keywords that way, I just love that VB fixes them all for me as I go along.

    It’s great the way it does it with the variables too. I only ever capitalize my variables when I first define them and then type them all in lower-case in the code and VB does the grunt-work for me and fixes them all.

    God bless VB.NET and all who use her!

    Reply
  10. Omar Shraim

    I love the lowercase keywords but I think this should be as a user preference to cater for different tastes and to help VB developers fight off the semicolon guys as they try to thrash the language and the only thing they can come up with is that it is verbose!!

    Reply
  11. Roger Jennings

    Lower-casing VB keywords in order to gain a bit of wrongly imagined C# elan is a waste of time and effort. The only worse decision re casing that I can think of is to make VB case-sensitive.

    If VB developers are found to suffer severe C# envy, I suppose it would be possible to all them to insert French braces throughout their code, which the compiler would ignore (except where needed).

    Instead of considering cosmetic changes, I’d suggest bringing VB to full parity with C# by reinstating, for example, array and collection initializers.

    –rj

    Reply
  12. Justin Michel

    I definitely think VB should NOT switch to lower case keywords. 99% of the code already uses the current scheme. However, I think it would be great if VB gave more control over presentation in the IDE. Why should the behind-the-scenes code be so closely tied to what’s displayed on screen?

    VB should keep the current case for what’s saved to the file, but allow the user to pick how it should be displayed.

    Scott’s idea for automatically capitalizing all code is good too, but the only way I can envision it working is to introduce a user-defined separator for words, so that I could type something like "public class my-class-name" and VB would change it to "Public Class MyClassName".

    Reply
  13. Anthony D. Green, MCPD

    #0, I agree with Roger Jennings whole-heartedly, you all really need to focus more intently on all those useful features you teased us with and cut or have been floating from future version to future version; Believe it or not a VB dev might want to declare a nonserialized event in fewer than 10 lines of code. When I suffer C# envy it’s not because of keyword casing – it’s because of the glaringly obvious omissions of useful functionality I find in non-101 applications!

    #1, VB is more verbose than C#, nothing will change that – I actually prefer it.

    #2, COBOL makes VB look beautifully terse.

    #3, for those speaking of "forcing" and "switching" this is a cosmetic change only, the compiler does not and never has cared about the case of anything, keywords included.

    #4, QBasic (my first language) used all UPPERCASE keywords. I find this discussion funny with that in mind. The recasing of keyowrds and identifiers has always been a significant immediate feedback in my coding process (since QB) that I’ve written a valid statement, not doing so would really freak me out.

    #5, I hate it when people use all lowercase keywords in SQL. Blending in is rather distracting. They are keywords, not common local variables (like i) and should be emphasized as such.

    #6, it looks more like javascript than C#.

    #7, the option of turning of background compilation is both good, and would probably implement this "feature" at the same time (hint, hint).

    Reply
  14. LB

    I’m confused why you needed a bootleg of the compiler? As Anthony pointed out above (#3) the compiler does not care about the casing of keywords.

    I would have expected (and I haven’t tried) that the lowercase code above should compile with any VB.NET compiler. This sounds like a none-issue and would perhaps be best suited to a presentation setting within the IDE.

    With so much reference material in-place using proper-case why change to lowercase? Make it an IDE presentation option if it makes people feel better!

    Reply
  15. [ICR]

    I personally prefer lowercase, but I think it could be dangerous to change it.

    As previously mentioned, it could end up with competition between people who prefer different styles if you make it optional (not necessarily concious, but if one person checks in code that’s been formatted to lowercase as per their IDE preferences, and then someone else checks it out and back in with a different casing you would get inconsistencies, though one would hope casing would be standardized on a project).

    Even if you make it a compulsory change you would get a large inconsistency between old and new code.

    Reply
  16. Diego Vega

    Having the option would be cool. I don’t care a little bit about VB looking like C#, but given all the pascal case in names, if every keyword is lower case, code actually a little bit more readable to me.

    Reply
  17. OviB

    I am OK with an option for lower case in itself.

    What I am afraid is that following the persistent trend of bastardizing VB and transforming it to a another C surrogate, the option in next version (eventually checked by default) means the only option in the second version from now, opening the way to case senzitivity to variables or function names and so on.

    After vb6 release, all the changes in vb (at least perceived by me) were to get it to C syntax and spirit. The whole VB spell was trashed back then.

    Now we are already pretty close to C (when I see these a+=1 I fill embarassed that I still am in VB boat).

    It is like cutting the tail of a dog inch by inch. Why not simply kill vb completely ? It stinks anyway – doesn’t it ? ;)

    Such a shame that developers working in C(++/#) seem to have no respect for the users of the language they develop. Wherever a decision was to be made in developing vb.net I feel that the C guys won, infecting Basic syntax and spirit with alien "assemblish" ghost of C.

    I like to some degree .net (except for the IDE performance) and use it BUT from the first .NET beta I played with I somehow regret the easy decision of using and investing in MS Visual Basic 1 back in 1993.

    It is not about learning new things – it is about 100s of thousands of lines of code developed with the belief that MS is carring for compatibility the way as it does developing Windows.

    The way VB developers were treated when moving to .NET will always remain as a bad memory. I will always advice anyone to think twice and try to avoid nice new shining technologies even with more effort.

    Again, the option for all lower case for keywords is OK IMO. What VB became as a whole is not. But than again, this is just my personal opinion ;)

    Reply
  18. klipp

    To make VB less verbose, you can make the If/Function/Sub/Case keyword optional in their relative End statements, as well as the Then on multiple-line If

    Private Function ParseSimpleNameExpression() As SimpleNameExpression

    Dim start As Token = Peek()

    Dim name As SimpleName = ParseSimpleName(False)

    Dim typeArguments As TypeArgumentCollection = Nothing

    If Peek().Type = TokenType.LeftParenthesis

    Dim leftParenthesis As Token = Read()

    If Peek().Type = TokenType.Of typeArguments = ParseTypeArguments(leftParenthesis, False)

    Else

    Backtrack(leftParenthesis)

    End

    End

    Return New SimpleNameExpression(name, typeArguments, SpanFrom(start))

    End

    The "old" End statement should be made forbidden as a way to quit the program.

    Reply
  19. klipp

    Indentation was eaten in my previous comment.

    As for the lowercase keywords: make it only a visualization options as others have suggested.

    Reply
  20. Josh Stodola

    I like the current proper case better than the lower-case. Although, making this an option would be the best, becuase I can understand how people would like lower case better.

    Reply
  21. Mike Hofer

    Look, if you’re worried about how terse the language is, you’re shooting the wrong target. You should be addressing keywords that are spelling out things that the compiler (and the developer) can already tell because the syntax OBVIATES them.

    #1. Get rid of the AS keyword.

    Variable names can’t have spaces in them. So it follows that whatever comes after the variable name is a data type. The As keyword is completely superfluous. It’s just eye candy. The following is more than enough for a compiler and a developer:

    Dim x Integer

    Dim lastName String

    Dim dateOfBirth Date

    #2. Eliminate "End If", "End Case", "End Sub," and "End Function," and all their variants.

    This has been covered eloquently by others above.

    #3. Get Rid of the Sub and Function keywords.

    A method’s type should be obvious based on whether or not the developer has defined a return type for it. For example:

    Public Foo(ByVal connection IDbConnection) Boolean

    ‘ Do something

    End ‘ Assuming we got rid of "End Sub"

    Essentially, anything that the compiler or the developer can *reasonabily* determine, drop or make optional. Thus, you get something quite terse, like this:

    Namespace Foo

    Public Main(ByVal arg String)

    Console.WriteLine(Baz(arg))

    End

    Private Baz(ByVal arg String) String

    Return String.ToLower()

    End

    End

    Now it’s terse.

    Reply
  22. Roger Bonine

    Who says terseness is a good thing? If I wanted terse code, I’d use C# (or APL). I like VB code because it’s relatively self-describing.

    I personally like the End [If|For|Case] construct, for the reasons listed above. As for lowercase keywords, I like it better the way it is now. It’s a better match for the Framework type casing IMO.

    Reply
  23. John

    Personaly since moving to dot net I have onyl ever coded the dot net way with lowercase

    Dim someObject As SomeObject

    It makes code readability so much better especialy now the editor is clever enough to keep the case of variables seperate from those of object types.

    Then theres the question of private member variables. _someObject vs mSomeObject. I go with the underscore.

    Also what abound vb modules, anyone still use these things in vb.net? Never used them in vb.net. I just use static clases with shared members.

    I also never use Integer/Longs etc, I prefer to use Int32,Int64 etc. shorter and far more descriptive. The only downside it there not coloured blue in the editor.

    Oh and one last thing, Mike Hofer, is spot on, you could also lose the ByVal , if you need ByRef params then explicity specify ByRef. It’s never going to happen but we can wish.

    I’d have moved to C# if it wasn’t for the poor IDE experience compared to VB, + I hate those awful semi-colons ;-)

    Reply
  24. Kevin Ryall

    It’s weird: it actually looks ‘shorter’ to me with lower-case keywords – maybe I’ve been corrupted by doing a lot of coding in C# recently.

    It definitely looks ‘geekier’ to me as Pradeep said – that’s good from a job security point of view, but probably not in the spirit of VB…

    I think I have a marginal preference for lower-case keywords, but it’s not based on anything ‘real’ – it’s probably not worth making it an option, and it would be too drastic to enforce the change.

    Reply
  25. Christopher Hawkins

    Have the VB code be proper-cased makes it easier to scan the code. All-lower case might be easier to write, but it is harder to scan when you need to find something.

    This is more important than it might seem at first thought.

    Reply
  26. Leigh Kendall

    I have to agree with Christopher and others in favor of keeping the casing as is… I don’t see any benefit and think it actually takes away from readability.

    Instead of changing the casing, I would rather see more advanced formatting options like in C# (IDE) for spacing between different language elements.

    Reply
  27. Raj Chaudhuri

    Roger Jennings said everything I wanted to say, although an option would be nice.

    I assume you bootlegged the lexer inside Visual Studio, because the current command-line compiler happily compiles both versions.

    Reply
  28. Charl Victor

    I like the lower case syntax.

    I think you should make it an optional setting. That way people can go with their preference.

    Reply
  29. Csaba Urbaniczky

    Hi,

    1. I think you should make lowercase an optional setting. (Better still is capitalize first letter in If, Case, For as in nomal sentences but not the other:

    If some logic then

    doSomething

    else

    doSomethingElse

    end if

    2. Suggestion to improve readability,:

    Get rid of DIM and AS so this can be legal code: "Int32 i = someIntegerValue"

    3 Suggestion to improve readability: An optional setting so someArray[indexInteger] is legal besides someArray(ndexInteger), which today can be mixed up with someSub(someVariable)

    4 "End if" , "End case", "End sub" etc are great, improves readability significantly! Keep it!

    Reply
  30. Roger Wagner

    The thing I like most about the way it is now is that it provides a check when I enter variables and keywords in all lower case. When I enter the correct spelling the case corrects itself and I know it is right if everything was in lower case I would spend a great deal of time searching for spelling errors when I typed the code.

    Reply
  31. Anonymous

    VB’s got much bigger problems than lower casing the keywords. Like to know what would make it look more like C# – CURLY BRACES

    Reply
  32. Mike Schinkel

    Proper casing has in studies been consistently proven to be more readable. Why consider subjecting us to harder to read code just because the C# guys can’t be bothered to press the shift key from time to time?

    Reply
  33. Kirk

    I Agree Mike. Proper Case All The Way. It Simply Looks Better, Reads Easier, And Sounds More Memorable.

    Reply
  34. plinko

    I would hate to see almost all of the suggestions listed here implemented.

    But this does illustrate how varied people’s personal prefrences are. If anything were to be implemented to reduce verbosity, I would hope a ‘reformatter’ function would be included si I could reconstruct someone’s else’s chopped up mess.

    Reply
  35. djs

    One thing to keep in mind is how these options (different casing, spacing between elements, tabs/spaces, etc) is how it affects source control and seeing how the code changes over time. If you have one developer with different settings than the rest of your team then using text diff tools becomes futile as every line in the code file will be different because of different casing, spacing, etc.

    Reply
  36. Phil Jollans

    Am I the only person to work with option

    "Pretty listing (reformatting) of code"

    disabled?

    I’ve had this disabled for so long, that it never occured to me that keywords could not be all lower case. But, this brings me to another point. The pretty listing ability of VB continues to be pathetic. I hate the reformatting that it performs, in particular, because I like to line up Dim statements in vertical columns. On the other hand, I would like VB to fix the case of variable names. The pretty listing option is all-or-nothing, so I choose nothing, but I would like to be able to pick and choose the options, or even configure them.

    By the way, VB6 lets you line up the As in Dim statements, without reformatting it, but vb.net lost this feature.

    Reply
  37. riskfactor

    I’m all about options! That’s why I like VB.NET. If you can give me an option in the IDE to lowercase the keywords then I’m cool with that. The idea I REALLY like is Bill McCarthy’s where you could define the casing/color etc. for key words.

    This would be great when I’m looking through a long section of code that may have an If..Then, a Select Case and a Loop and I need to quickly identify where they each end. If I could define If statements as red, Select as greem and Loop as purple it would make it much easier for me to scan a page for a color than to skim each line for text.

    Reply
  38. Mike Lyons

    I say leave the Proper Casing as it is. It has always been that way, and all the huge base of sample code in both classing and .NET style VB uses the Proper Case form — why change it?

    The quality of your code is far more important than whether it appears more verbose because of some little quirk in human visual perception.

    As for removing the If/Sub/Select… etc. from the End keyword, I think this would be more trouble than it’s worth. You’d have to add comments to help you remember at the end what you were End’ing, especially when you have several stacked up vertically as in some of the proposed code samples in this thread. Someone pointed out that keeping those keywords helps readability, and I agree completely. Readable code is crucial in maintaining and troubleshooting. Read "Code Complete" by Steve McConnell.

    The other point about version control and text file differences is also a good one,particularly in a team development setting. At one place I worked, Source Safe caught as "differences" many cases (no pun intended) where one developer changed the case of SQL keywords in some SQL Server scripts. Functionally it was the same.

    I suppose you could put an option in the IDE to control how it is presented in the code editor, as long as it is actually saved in Proper Case format, so that it remains consistent. Keep in mind that any of these "code beautifying" features just add to the number of things going on in an already sluggish IDE.

    My $0.02 worth.

    Reply
  39. Andy Teece

    I really dont care, uppercase or lowercase… but whatever you do DONT MAKE IT CASE SENSATIVE!

    Case sensativity in a programming language has always seemed backwards to me. If is the same as if is the same as IF is the same as iF

    Reply
  40. [ICR]

    One interesting possibility that Roger Jennings comment inadvertently bought to my mind is to make it purely a cosmetic change in the editor.

    When the file is saved (whatever the casing settings are), upper-casing is used. However, if you load the file and have the preferences set to lower case it will be rendered as lower-case. This should solve mine and others anxieties about conflicts and religious wars. To be honest, this could be extended to most of the cosmetic aspects, such as bracing positioning in C# and others.

    This does come with it’s own problems though, inherent in that what the user is seeing isn’t actually what they are saving. But I think these are minimal.

    Actual implications aside, it does seem to be a very interesting experiment and suffers from the age old "it’s what your used to". Though I have to say lower case keywords actually closer reflect the casing proportions in the English language, presumably making those not used to VB feel more comfortable and thus making scannability for newcomers better. As to what is more effective after training remains debatable though.

    Reply
  41. Kyralessa

    As someone who codes in both VB .NET and C#, I like the lower-casing idea. I submit that it’s _more_ readable, similar to the way lower-case text is more readable than upper-case text because lower-case letters have ascenders and descenders. And I agree with those who say it makes the keywords stand out better in comparison to Pascal-cased class and variable names. I would love to lower-case keywords as an option.

    And no, I don’t think it looks too much like C#. It’s the braces, more than anything, that make C# look like C#.

    Reply
  42. primate

    Lower case looks, feels and is undoubtedly better. Over capitalizing makes everything look to important and is less "readable". The general rule should be to capitalize as little as possible.

    Reply
  43. [david]

    Automatic case of keywords is a dynamic feedback mechanism, with the Intelligent Thinking Machine working with you in real time to develop your program.

    Very ’60s, instead of cleverness by obscurity.

    If you have a different mechanism (highlighting, font, color) for letting the machine do what machines are still good at — basic systematic repetitive checks–, then you can use that instead of capitalization.

    But I think that the only gain is to make it look more familiar by making it look like a case-sensitive language. Better to just drop ‘DIM’ and leave If Then Else capitalised. DIM is wasted space: If Then Else start sentences. Also, remember that Dim originally allowed multiple variable declaration DIM I,J,K; DIM R. The AS syntax broke that. A concise declaration syntax would be welcome, and not to much of a break with BASIC.

    Reply
  44. Steve B

    I like the lower casing a lot!

    I’m a long time vb developer and would definately be in favor of this. I agree with previous post that stated :

    "Over capitalizing makes everything look to important and is less ‘readable’"

    Reply
  45. SB

    Lower case keywords is a bad idea IMO. One thing I like about VB is the fact that I can buzz away in lower case and the IDE will auto-capitalize everything it recognizes. This gives me a visual indication that I haven’t mis-typed something as I work. For this reason I ALWAYS mix-case my definitions as well.

    Reply
  46. Pingback: Panopticon Central

  47. Andrew

    I prefer the capitalizing of keywords, it makes it much easier to read.. But I guess it’s a matter of opinion as some peole here think clearly otherwise..

    I also really hate the ‘pretty listing’ option of VB.NET and really would prefer it if there was an option to Disable this module/projectwise, and not developerwise.. I miss the VB6 prettylisting, because there you could at least indent/outline Dim’s and Cases, with the current prettylisting it completely makes any ‘Dim’ more than one line unreadable…

    Reply
  48. MartinD

    Want to get rid of some of the perceived amateurness of VB? How about a way to not have to use the stupid-sounding AndAlso and OrElse?

    For example, you could provide unique bitwise operators and either:

    * an option whether And and Or map to the shortcutting logical operators or the bit ones.

    * an option that when And & Or are operating on two boolean vales they behave like AndAlso and OrElse, otherwise they behave like the bitwise operators

    Reply
  49. Jon

    Visual Studio 2008 lets me get away with lower case keywords.

    I mUch preFer

    Using AllLowerCase words

    since I think MixedCase Makes

    The Code HardTo Read When YouAre

    Trying to Scan it For AParticularLine of Code

    I also prefer it when things are lined up like so

    dim name as string = "Jon"

    dim reallyLongVarName as string = "line it up"

    but then again I was forced to switch from C# to VB at gunpoint.

    Reply
  50. Jon

    Well, in the above the "as" keywords were supposed to line up but the web page stripped out the extra spaces. In 2008 go to Tools > Options > Basic > VB Specific and uncheck Pretty Listing (reformating) of code to use lowercase.

    Reply
  51. Steve

    I’m way too late on this, and this is even off the subject, but I like that vb is not case sensitive. I try to remember the variable I want in all lower case, and if the case changes, I must have remembered it correctly!

    Reply

Leave a Reply