PDA

Click to See Complete Forum and Search --> : Why is C# case sensitive?


mendhak
Nov 18th, 2004, 06:28 AM
I am not having a good time running through a small C# article regarding Automation.

While writing code, I don't want to worry about whether I wrote "int" or "INT". I'd rather focus on achieving something, not making it 'look right'. It's going to be those days of JavaScript again, where I had to spend 15 minutes debugging a large function only to find out that I had misspelt the word textArea. :rolleyes:

Why is C# case sensitive? This is really sad... why didn't they just give VB.NET all the features that C# has to itself exclusively and let us live in peace? Or, if they really wanted something that was close to C/C++/Java, why not allow for case insensitivity? It would be a refreshing change. Just because people have been doing something (dare I say dumb) for 20 years does not mean it should continue. Make a change!!

I actually googled this and came across this article (http://msdn.microsoft.com/vcsharp/team/language/ask/case/default.aspx). This has to be the worst excuse I've ever seen:


Perhaps surprisingly to you, we didn't spend a lot of time on this question while designing C#. Rather, we felt that this was clearly a matter that had good arguments on both sides, and was largely a matter of taste, preference, and former experience. Given that, we didn't see a good reason to change from the precedent set by C and C++. In this matter, as with numerous other aspects of the language, such as using curly braces for blocks, ending statements with a semi-colon, the syntax of loop statements, etc. we deliberately chose not to change what C and C++ used. This allowed the basics of the language to be familiar to C and C++ users, so that people can concentrate their attention on a smaller number of features where we felt we could provide significant additional value over C and C++.



:ehh:

I am now going to take a printout of this quote and use it to wipe the grime from underneath my desk.

:mad:

mendhak
Nov 18th, 2004, 09:04 AM
I appreciate the rant I was allowed, but can someone explain to me the advantages of case sensitivity?

john tindell
Nov 18th, 2004, 09:25 AM
the only advantage i can think if would be having multiple variabes with the same name, even though thats not really the best coding.

Pirate
Nov 18th, 2004, 12:53 PM
This makes it more challenging , develop accuracy , and more important nobody can call it toy language like VB :D

Pino
Nov 19th, 2004, 05:26 PM
I have to agree with mendhak me being a long time Vb coder, found it hard switching to c# witht the case sensitive ....

Danial
Nov 20th, 2004, 08:13 AM
Mendhak I can see your furstration if you have come from VB background. I have been doing VB for quite a while before moving on to C#. Intially I did some C++ as a result I find C# more elegent then VB.Net specially the OO stuff. I am not saying VB.Net cant do all that just saying C# syntax looks much more elegent in my humble opinion.

As for case sensitivity you have mentioned a good argument about bugs but I have to say i dont get that a lot. The C# comiler is not bad in picking up those mistakes. You just have to get used to it then it wont become an issue.

I do like the case sensetivity, here is why, i can do and always do :


Contact contact = new Contact();


When i design classes i make then Sentence case where as when i instantiate them i always use lower case.

Now i wouldnt like it any other way since naming contact instead of a new name make the code more readable and slightly elegent.

I am sure these might not be at all an issue to you but I quite like the fact that it is case sensetive. I am sure there are other reason but like its been pointed out it is just matter of preference.

I guess VB has made us all spoilt :)

mendhak
Nov 22nd, 2004, 06:32 AM
I'll agree with that... I'm spoilt thanks to VB.

And I'll mention something else against my case: VB.NET is case sensitive. I depend upon the IDE to correct my capitalization. The other difference being that I can't do something like


dim object as Object


Oh well...

Danial
Nov 22nd, 2004, 08:42 AM
Originally posted by mendhak
I'll agree with that... I'm spoilt thanks to VB.

And I'll mention something else against my case: VB.NET is case sensitive. I depend upon the IDE to correct my capitalization. The other difference being that I can't do something like


dim object as Object


Oh well...
Apart from that VB.Net IDE does a lot of neat auto code genaration for us(e.g compleation of If/End If). I havent use VB.Net too much but i am sure there are hundreds more auto completion.

Before you know it, the VB.Net IDE will take control of you and try do all the coding for you ;)

I bet next version will have

"VB.Net has detected that you are trying to write a n00bi worm! Would like MS VB.Net AutoWorm generator to help write your Worm?"

C# IDE lacks some of these features but I still find C# much more attractive then VB.Net.


Yes, its about time you see the light and join the C# force :) .

NoteMe
Nov 22nd, 2004, 02:25 PM
The autocorect variable case thingy was nice in VB. That was the first thing I missed when I moved on to C++. But I have gotten used to it, and don't notice that it is there when I try out some code in VB anymore. But it would probably be easier for those who are comming from VB to C# if it was there. For C/C++ users, there is no diffrence, and we probably woun't kick MS for adding it to the IDE.



ии

nemaroller
Nov 22nd, 2004, 09:09 PM
Originally posted by mendhak
I'll agree with that... I'm spoilt thanks to VB.

And I'll mention something else against my case: VB.NET is case sensitive. I depend upon the IDE to correct my capitalization. The other difference being that I can't do something like


dim object as Object


Oh well...


Dim [object] As Object

That will work..

But I agree with you... I don't mind the case sensitivity much, but I certainly do hate the C# IDE in VS 2003. I imagine 2002 was worse, I don't really remember.

Take for instance the lowly form. The VB.Net IDE lists the methods of the form (the class) you are working on. With C#, you have to press TAB key to have it autogenerate event handlers for you. Man, that's just time better spent somewhere else. May only be 2 seconds longer in C#, but times that by 50 classes and holy crap!

And the autocomplete in C# ide leaves much to be desired. I guess the whole argument there is VB is meant for RAD, where C# is meant for elegant design (ahem okayyyyyyy).

However, I will say this about C#, there's nothing more fun than pressing SHIFT and hitting the '[' key before and after your function body. And please, let's remember that only a proper programming language includes a ; at the end of every statement or call.

mendhak
Nov 22nd, 2004, 11:43 PM
Originally posted by nemaroller

However, I will say this about C#, there's nothing more fun than pressing SHIFT and hitting the '[' key before and after your function body. And please, let's remember that only a proper programming language includes a ; at the end of every statement or call.

:D :D

mendhak
Nov 22nd, 2004, 11:49 PM
Originally posted by Danial


Before you know it, the VB.Net IDE will take control of you and try do all the coding for you ;)

I bet next version will have


Sandpaper...



Yes, its about time you see the light and join the C# force :) .

It'$ going to take $omething big to make me $witch over. :)

Tewl
Nov 23rd, 2004, 11:56 AM
I've done a lot of vb an java programming over the years an lately I have got into c#. Seeing that it was so much like java it didn't take me long to pick up on it. Anyways, I don't know all the reasons why it was written case-sensitive but from an obvious view it is more common in programming languages to be that way. VB being one of the few that is not. This is just the beginning for C# so sure you will probably find things you do not like about the language or the way it is done in the ide. Heck few years from now MS might not even bother making a visual ide who knows. I personally like the ide tho I do not use it as much as I do with visual basic because I enjoy coding my events an things without letting the ide handle it with its vb like event names and other things. If you are really interested in finding out information about why things are they way they are i would suggest joining one of the msdn scheduled chats on c# or vb.net when they come around and ask the development team some questions about it.

nemaroller
Nov 23rd, 2004, 03:46 PM
Tewl,

I agree wholeheartedly with your post at least up until not using an IDE to develop large programs.

I would much rather have the IDE intelligently fill-in the event handlers than force me to recite the same old syntax for the 100th time.
:)

hellswraith
Nov 25th, 2004, 08:25 PM
I found that the VB auto casing your variables was cool when I was working in VB. It helped make sure I wrote it right and gave me visual feedback. BUT, in C# (you can do this in VB as well), I now use something I find much better. That is variable completion. Start typing your variable name, and hit Ctrl-Space. The intellisense window will open if your variable name that you typed so far matches more than one match, but if it doesn't match anything else, it will fill it in for me. Example:

In a C# method, do this:
string myReallyCoolString = "";

then type this:

myR

Hit Ctrl-Space and it will fill in with:

myReallyCoolString


This saves me A LOT of time typing. I hardly ever type out a variable name completely anymore. If you don't use it yet, use it, it will save you a lot of time.

mendhak
Nov 29th, 2004, 02:32 AM
I can imagine the problems all of us would be having if we were given notepad instead of VS.NET. :D

Tewl
Dec 5th, 2004, 03:31 AM
I've never used anything but notepad/wordpad when with java. It made me even more aware of my small mistakes such as typos, ect.

asdf1234
Dec 29th, 2004, 06:18 PM
Why is C# case sensitive? This is really sad... why didn't they just give VB.NET all the features that C# has to itself exclusively and let us live in peace? Or, if they really wanted something that was close to C/C++/Java, why not allow for case insensitivity? It would be a refreshing change. Just because people have been doing something (dare I say dumb) for 20 years does not mean it should continue. Make a change!!

I couldn't agree with you more. It's a known fact that case-sensitivity is a stumbling block, especially for beginners. The creator of Python even admitted this (case-sensitivity) is one of the things wrong with Python (along with int division: where 7/4 = 1 instead of 1.75).

There is no reason why the Microsoft developers could not add a case-insensitive option to the C# compiler (you could turn it on or off however you choose). I implemented a case-insensitive option myself for the boo programming language: http://jira.codehaus.org/browse/BOO-128
I also fixed the int division thing: http://jira.codehaus.org/browse/BOO-208

There is one reason FOR case-sensitivity though, it makes source code a little more readable and standardized. Case-insensitivity though is much more easily writeable than it is less readable.

Magiaus
Dec 30th, 2004, 12:34 PM
case senative == streangth == not lazy == advantage == frog (base data var for the frog database class) Frog (class you use)

It's not super useful but I think it's better to know what your typing than not.... and things like operator overloading are possible because of all the rules in C#

Face it C# is a dumbed up version of C++ based on the framework. VB is a even dumber version of a powerful language(don't throw stuff at me). VB 6 is like lego block that don't match being put together with a mallet. GPF in subclass.dll....

If this is giving you trouble stick with VB :thumb:

Magiaus
Dec 30th, 2004, 12:36 PM
I found that the VB auto casing your variables was cool when I was working in VB. It helped make sure I wrote it right and gave me visual feedback. BUT, in C# (you can do this in VB as well), I now use something I find much better. That is variable completion. Start typing your variable name, and hit Ctrl-Space. The intellisense window will open if your variable name that you typed so far matches more than one match, but if it doesn't match anything else, it will fill it in for me. Example:

In a C# method, do this:
string myReallyCoolString = "";

then type this:

myR

Hit Ctrl-Space and it will fill in with:

myReallyCoolString


This saves me A LOT of time typing. I hardly ever type out a variable name completely anymore. If you don't use it yet, use it, it will save you a lot of time.

sweet

Dillinger4
Jan 3rd, 2005, 08:24 PM
Comming from coding in Java for quite a number of years learning C# should pose less of a problem for me than someone comming from Vb but some of C#'s syntax seems a bit weird. Why is a language specific class type such as string defined as lower case and it's methods defined as starting in uppercase?

Magiaus
Jan 3rd, 2005, 09:09 PM
Because the .net framework is based on Uppercase starting methods and properties.... System.String is simple pointed to by string. string is lowercase because it s more the way things work in C++ System.String the members it provides are uppercase for all .net framework languages.


If I made my own language we'll call it Bob the Builder I could make a string type for my language called bob_string or _string or __bs it would still have the same mebers and member name case as System.String....

For that matter I can make the bob_string type in C# if I wanted to let's say add some extra string methods like Encrypt or something.....

Dillinger4
Jan 3rd, 2005, 09:38 PM
Posted by Magiaus

Because the .net framework is based on Uppercase starting methods and properties....

So i guess C# and Java are opposites in that respect.

String s = "hello"; // Java
int i = s.length();

string s = "hello";
int i = s.Length(); // I guess C# please correct me if i am wrong

Magiaus
Jan 3rd, 2005, 10:12 PM
I guess so. There is no String in C++ only char. You have to include a header to get String. When adding a string class to the base language I assume they wanted to keep the convection where int, bool, double, float and so on where already lowercase it only makes since that when adding String it would be string not String.

Dillinger4
Jan 3rd, 2005, 10:26 PM
Posted by Magiaus

When adding a string class to the base language I assume they wanted to keep the convection where int, bool, double, float and so on where already lowercase it only makes since that when adding String it would be string not String.
Yes but sbyte int short ect.... are primative types whereas string is a composite type. I would think that when creating a language you would want to support some type of syntactical differentation.

Magiaus
Jan 3rd, 2005, 10:37 PM
In the framework they are complex types though. Provinding new and extended functionality. int in C++ is int16 int in C# is int32. All the C# keywords are lower and string is a C# keyword. It's the convection the language takes to hold with C/C++ look at int.Parse and so on the entire language is this way and string is a base part of the language.

At least you don't have to worry with __gc class and all the C++ extras need to use the framework. Casting pointers and so on can be insane in c++ to managed code.

It's all about the framework, the language is up to you. C# has operator overloading. Meaning I can make a collection call the add method by going mCustomArray++ object; if I overloadd the + operator. That's about the biggest thing C# does that say VB doesn't. Or I could make an int class that ++ would subtract.

Dillinger4
Jan 3rd, 2005, 10:58 PM
Posted by Magiaus
look at int.Parse and so on the entire language is this way and string is a base part of the language.

int.Parse just looks to me like an automatic boxing operation for a language that has a lack of wrapper types which then means the type system is unified such that a value of any type can be treated as an object.

Magiaus do you know where i can find C# API documentation? I looked all over microsofts site with no luck. Thank you for the help. :thumb:

Magiaus
Jan 4th, 2005, 12:53 AM
Honestly I havent looked into it for a year or two. You have to look into Reflection, Interop, and Marshaling. Basicly you declare the API simular to the way you would in VB6. You have to do this for any structs and so on. It is a bit frustrating. I went as far as making a C++ wrapped .net API lib but I lost the work. I wrapped around 60 of the Win32 API but the deeper I went into the API and the framework the more redundent it got. I can usually find a way without API. Unless I want to do hooks or something.

Truthfully I got to the memory API and my brain melted because CopyMemory was returning the same handle for any framework type a unique handle for each type but the same on every instance. Even if I made like 1,000. I got all dizzy thinking about garbage collection, object instances and I went into a C++ indused comma.

I couldn't think of unified for some reason. That's what it is is a unified type system. As far as the boxxing and unboxxing goes it's beyond me. I gave up on learning C++ until someone is going to pay me to use it....

Dillinger4
Jan 4th, 2005, 01:52 PM
:lol: All i wanted was a link to the API.

Magiaus
Jan 26th, 2005, 11:36 AM
:lol: All i wanted was a link to the API.

Sorry I'm slow. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/windows_api_start_page.asp

nemaroller
Jan 29th, 2005, 08:27 AM
So i guess C# and Java are opposites in that respect.

String s = "hello"; // Java
int i = s.length();

string s = "hello";
int i = s.Length(); // I guess C# please correct me if i am wrong




//C#
String s = "hello";
works just the same as using a lower 'string s'. It creates the same intermediate language instructions.

Magiaus
Jan 29th, 2005, 08:30 AM
//C#
String s = "hello";
works just the same as using a lower 'string s'. It creates the same intermediate language instructions.

as long and you have using System;

nemaroller
Jan 29th, 2005, 08:33 AM
lol, i suppose, but then you're not getting much written without the system library.

Magiaus
Jan 29th, 2005, 09:37 AM
I'm just being picky, but I forced myself to not use any using statements for the past year to ingrain the framework into my brain. I think I must be crazy. I know I typed twice as much junk for no reason....

nemaroller
Jan 29th, 2005, 09:59 AM
I've done that too.. .except where I work now... its considered back programming practice (against their defined standards) to use the fully qualified name.. instead of placing a using statement at the top.