Case Insensitive Vs Syntax

Can someone make a really good case (:-)) for case sensitivity?

C #: case-sensitive VB.NET: case-insensitive C ++: case-sensitive ...

Even worse: XML, which is used internally by a language such as VB.NET , is case sensitive.

I made it so funny and can only be harmful after we discovered an error in our system due to the fact that XML had both V and v node nodes ...

I am asked again and again in the comments

"Perhaps you can come up with one argument for why case insensitivity is the right choice in such a world?"

Here's an example: I see this similarly to the question: Should the URL be case sensitive? www.cnn.com <> Www.cNN.com? Of course, they must be the same, the ID of the theft of heaven! because people do not pay attention to 2 lines that are the same, but may have a different shell. Programmers are people. So getAge () and getage () are the same in most human minds.


Please note: I don’t think we really want the code to have a function defined as getAget (), and then the code that calls it getage (), VS (vb.net) automatically fixes the getaget for getAge. Thus, the code is clear, and the programmer is aware of the correct capitalization. I want to say that a good IDE makes the problem irrelevant, but it works better in a non-case-sesnsetive language like vb.net and then speaks C #. Link: here

+6
case-sensitive
source share
7 answers

The rules of the case depend on the culture. Do you want a programming language where the variable i sometimes considered the same as the one called i , and sometimes these are different variables? (This is not a compiled example, by the way, in Turkish i not uppercase i .

Honestly, it's pretty simple. Do you want the compiler to correct you when you make a typo, or do you want it to guess what you meant? The latter, as you know, leads to errors. VB assumes “oh, you probably meant the same thing, which is good, we won’t stop you”, and XML took you literally.

Your error did not occur because the case sensitivity is bad, it happened because careless is bad. An arbitrary change of case may, at best, not cause problems, and in the worst case, it will cause errors. Assume the worst and agree with your case. Which, by the way, is what makes you make you perceive case sensitive regions. Regardless of whether your tools are case sensitive, the programmer must be case sensitive. Being case sensitive saves a ton of trouble as long as there are no insensitive as well as sensitive tools in the world. If we could remake the world so that everything was case insensitive, many reasons for sensitivity would disappear. but we cannot.

A short note: In many languages, it is customary to specify variables and types with the same name, but with different capitalization:

 Foo foo; // declare a variable foo of type Foo 

Of course, you can argue that “you should not do this,” but it’s convenient, and immediately tells the reader what type the variable has. This allows us to create a log class and a log object. And since the purpose of this object is to register, the name is obvious.

And the last thing to consider:

The point is in real languages. A word that starts with an upper case is different from one, but with a leading lower case. The word "worD" is misused in English. Information is encoded in the case, which facilitates the reading of the text. This tells us when we come across a name, for example, or when a sentence begins, which is convenient. Allowing people to ignore the rules of the matter makes it difficult to read the text. And since code should usually be written as readable as possible, why shouldn't we do the same in programming? Let the case encode important information. In many languages, Foo is a type, and Foo is a variable. This is important information. I want to know this when I program. If I see a function called "Getage", I wonder what English word I have never heard before. But when I see “GetAge”, I immediately know that it should be read like the word “Get”, followed by the word “Age”.

By the way, here is a good example of funny surprises that you can come across case sensitive languages.

+11
source share

Slop is never a good idea in a programming language. You want everything to be as specific as possible. You never want your language to guess, and it should allow as few ways as possible to solve a given problem.

As for the specific answer, what about readability? Is stoRetroData visually a bit different from storeTRodAtA? Not that anyone could do this, but what is the point of resolving it?

I cannot think of any reason to ignore the case.

At least my opinion - but your mileage may vary.

Edit: I probably should have started this with a disclaimer:

I learned to program mainly and had the same thought fleetingly about 18 years ago. Believe me, this is one of those things that you will look back after 20 years and go "Oh, yes, I was pretty wrong about that" (as I am now)

+4
source share
  • History This is how it was done. XML is VB.NET case sensitive because it requires the XML standard
  • Internationalization Will we support the cause in all languages ​​(French, Japanese, Hebrew, Klingon, etc.)?
+2
source share

There are currently several case-sensitive languages, because the languages ​​they were based on are case-sensitive, and the transition will be easier. Personally, I prefer to be case sensitive, but Jeff Atwood wrote a good article about why case sensitivity is no longer needed.

+2
source share

A few reasons.

  • Searching for things, case insensitive, I have to have a case insensitive flag everywhere. With UTF-8, who also needs to know about the small Klingon case.

  • More importantly, CamelCasing, CAMelcaSing. This is ugly, but it has used a lot and is quite reasonable. It is almost impossible to exclude case insensitivity.

  • Language parity, such as xsd.exe (shipped with VS200x), can generate classes for the xsd that you supply. What will be your "meaning" when you also have a "value"? Thus, this gives another possible impedance.

+2
source share

The case is good in programming languages, but instead of using it in character names, we should use it as it was originally intended to distinguish between the beginning of a sentence or command or its own name. For example:

 Var test = 0; Console.writeline(test); Test = test + 1; Console.writeline(test); 

So beautiful ...: P

+1
source share

I find case insensitive just plain stupid. You must follow the capitalization of the initial declaration. I see no good reason not to do it too lazy to type TheRealName instead of TheRealName .

In fact, I would not even consider the case-insensitive language.

0
source share

All Articles