Open Side Menu Go to the Top
Register
Case sensitivty Case sensitivty

03-30-2011 , 11:42 AM
Can someone please explain what the point of this is. Like seriously, if you have two things called 'House' and 'house' and they are different things, that's just going to cause a major headache for someone at some point somewhere.

Better to compile/interpret case insensitive and force distinct naming convention? It's something I've never understood.
Case sensitivty Quote
03-30-2011 , 11:52 AM
Quote:
Originally Posted by Gullanian
Can someone please explain what the point of this is. Like seriously, if you have two things called 'House' and 'house' and they are different things, that's just going to cause a major headache for someone at some point somewhere.

Better to compile/interpret case insensitive and force distinct naming convention? It's something I've never understood.
I think the reason is just that historically it made the tokenizer part of the compiler simpler to write and it just stuck from there.

Juk
Case sensitivty Quote
03-30-2011 , 12:04 PM
Simpler to implement is the original reason for many Unix conventions.

And now we have lots, lots, lots of stuff that assumes it, so it sticks.
Case sensitivty Quote
03-30-2011 , 04:14 PM
'A' is different from 'a'. Why make everything more complex by trying to treat them the same?
Case sensitivty Quote
03-30-2011 , 05:56 PM
Because everyone at some point has been scratching their head over a bug which was some case related problem!

A may be different to a, but if your naming variables similarly with the only difference being case then your doing it wrong imo.

People will disagree but I've never seen a need for it.
Case sensitivty Quote
03-30-2011 , 06:02 PM
To be honest - the only time that I can ever remember a case related problem it was when I had to do VB.Net programming and I didn't realize that "something" was overwriting my "Something" variable.

My point is that to computers 'A' is different than 'a' - and if every command/language/whatever has to take that into account - there's still going to be bugs.

Edit: And it can often be useful to have conventions like classes starting with capitals and then instances starting with lowercase letters. So its also more flexible.
Case sensitivty Quote
03-30-2011 , 11:13 PM
BECAUSE TYPING LIKE THIS GETS TO BE BORING AFTER A WHILE, ESPECIALLY WITH SOMETHING LIKE COBOL WHERE YOU TOLD PEOPLE WHAT YOU WERE GOING TO, YOU TOLD THEM WHAT YOU WERE DOING, THEN YOU TOLD THEM WHAT YOU HAD JUST DONE. LEARN SOME SIMPLE CAPITALIZATION STANDARDS AND YOU'RE SET.
Case sensitivty Quote
03-31-2011 , 09:04 AM
Quote:
Originally Posted by jjshabado
Edit: And it can often be useful to have conventions like classes starting with capitals and then instances starting with lowercase letters. So its also more flexible.
Yeah, that's a good point.

Juk
Case sensitivty Quote
03-31-2011 , 11:45 AM
I don't see much reason for it in high level script languages, but there's still need for regexp.

I like having 52 instead of 26 options to play with strings.
You have some freedom in formatting error messages at early stages of low level projects. That's like all the creativity and freedom you'll ever use in such projects.

Also, you can flag regexp case-insensitive, in case it's important to you.
Case sensitivty Quote
03-31-2011 , 12:05 PM
Quote:
Originally Posted by Gullanian
Because everyone at some point has been scratching their head over a bug which was some case related problem!

A may be different to a, but if your naming variables similarly with the only difference being case then your doing it wrong imo.

People will disagree but I've never seen a need for it.
If you're having this problem, you need

a) Better coding standards (you should realize on sight when a variable is not capitalized correctly)
b) An IDE. It will show you when you're using an undeclared variable.
Case sensitivty Quote
03-31-2011 , 12:10 PM
Quote:
Originally Posted by Zurvan
If you're having this problem, you need

a) Better coding standards (you should realize on sight when a variable is not capitalized correctly)
b) An IDE. It will show you when you're using an undeclared variable.
So one reason it's there is to force better naming conventions? I actually think it encourages worse naming conventions as it allows people to name things differently.

That's not really a fair criticism either, it's wasn't a problem for me except when I was starting, but when you are given code to maintain written by someone who names everything similarly and with variables differentiated by case, it's a headache.
Case sensitivty Quote
03-31-2011 , 12:17 PM
Quote:
Originally Posted by Gullanian
That's not really a fair criticism either, it's wasn't a problem for me except when I was starting, but when you are given code to maintain written by someone who names everything similarly and with variables differentiated by case, it's a headache.
That's not going to be helped by making things case insensitive. People who make bad variable names are going to make bad variable names. Not to mention it would be annoying to read code that has the same variable look differently based on whatever capitalization someone felt like using at the time.
Case sensitivty Quote
03-31-2011 , 12:42 PM
Case sensitivity is there because it simplifies compilation. Having to convert all code before you compile it is an extra, unnecessary step.

If you follow good programming practices, then it's irrelevant. If you don't, then being able to miscapitalize a variable isn't going to help
Case sensitivty Quote
03-31-2011 , 05:25 PM
Quote:
Originally Posted by jjshabado
Not to mention it would be annoying to read code that has the same variable look differently based on whatever capitalization someone felt like using at the time.
+1
Case sensitivty Quote
03-31-2011 , 05:33 PM
This really seems like something that is only annoying right at the start of programming but once you get use to you don't want to give up.

I hated VB.Net's lack of case sensitivity when I had to use it.
Case sensitivty Quote
03-31-2011 , 05:37 PM
It's one of those things that seems pointlessly confusing at first, but becomes second nature pretty quickly. It does also add some expressiveness through naming conventions. 'foo = Foo()' is succinct and makes it clear what's going on. Without case sensitivity, you'd need to do 'foo = FooClass()' or something. All capitals is also a common way to denote constants. 'FOO = 55' would have to become 'FOO_CONST = 55'. It's not a huge thing, but the added elegance is worth the trade-off imo. Rails would need to be like totally rewritten if you removed case sensitivity from Ruby.
Case sensitivty Quote
04-04-2011 , 02:51 AM
Stick to proper naming conventions and you won't have a problem. I'd posit that if you are running into a case-related bug in your code base, your code base has larger problems that need fixing.
Case sensitivty Quote
04-05-2011 , 06:47 PM
What's the point in anything?
Case sensitivty Quote
04-05-2011 , 06:48 PM
Quote:
Originally Posted by vladul11
What's the point in anything?
lol I don't know! Nothing I suppose.
Case sensitivty Quote
04-09-2011 , 12:34 PM
Quote:
Originally Posted by McGillicutty
Stick to proper naming conventions and you won't have a problem. I'd posit that if you are running into a case-related bug in your code base, your code base has larger problems that need fixing.
I have to say I'm not comfortable with this argument for case sensitivity.

The need for "proper naming conventions" to avoid capitalization issues wouldn't exist if every language were Basic.

I don't think we should pretend that case sensitivity existed for any reason but to allow bytewise comparisons of strings for equality.
Case sensitivty Quote
04-09-2011 , 01:03 PM
I don't think proper naming conventions is only about avoiding collisions. They allow for very efficiently encoding additional information about the item in the name. Knowing that a word that starts with a capital letter is always a class is hugely beneficial. This is especially true with languages that don't require "new" before a constructor.
Code:
c = car()
Is that a bad method name or are me making an instance of the car class? Naming conventions answer this question for you without needing to investigate further.
Case sensitivty Quote
04-14-2011 , 11:41 PM
Quote:
Originally Posted by jjshabado
This really seems like something that is only annoying right at the start of programming but once you get use to you don't want to give up.

I hated VB.Net's lack of case sensitivity when I had to use it.
SQL's lack of case sensitivity bugs me

Most of the responses are justifying in hindsight (case sensitivity somewhat predates OO) but i'd be horrified to lose it now - card = Card() is a lot more expressive than the alternative.
Case sensitivty Quote
04-17-2011 , 11:28 AM
I prefer to use capitalized names for variables passed into a function, and lower case for local variables. Then I use capitalized with an underscore for member variables. Also, pre-processor constants/macros get all caps

ItemType item
ItemType Item
ItemType _Item
or
ItemType Item_
#define ITEM_COUNT 20

When I see item, Item, _Item, or ITEM_COUNT in my code, I know what the scope is. Also, it makes it easy to do things like item = Item.

Without having good reasons to decide when to capitalize, and when not to, it's an easy way to shoot yourself in the foot.
Case sensitivty Quote
04-21-2011 , 12:02 PM
I have spent a lot of time programming on large Fortran codes that have been worked on by many people over many years. Enforced case sensitivity of variables would have been very very very very welcome. Ugh, so horrible working with variables that are referenced in some spots as AGSBU and others as Agsbu or agsbu etc.
Case sensitivty Quote

      
m