Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 3230 Views - Last Post: 16 December 2013 - 10:42 AM

#1 AnalyticLunatic  Icon User is offline

  • D.I.C Lover

Reputation: 221
  • View blog
  • Posts: 1,030
  • Joined: 25-June 12

Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 10 December 2013 - 08:20 PM

My Programming Languages textbook prompted the following:

What are the advantages and disadvantages of having case-sensitive identifiers in a programming language, with respect to program reliability, type checking and compile-time complexity?

According to good 'ole Wikipedia, an Identifier is:

Quote

a name that identifies (that is, labels the identity of) either a unique object or a unique class of objects, where the "object" or class may be an idea, physical [countable] object (or class thereof), or physical [noncountable] substance (or class thereof). The abbreviation ID often refers to identity, identification (the process of identifying), or an identifier (that is, an instance of identification). An identifier may be a word, number, letter, symbol, or any combination of those.


Based on my few years of development, I could see a programming language being more reliable with case-sensitivity since there is less confusion towards the object, or identifier, referenced in code processing. This case-sensitivity I believe would also lessen compile-time complexity for similar reasons, cutting down on ambiguity concerns.

As for type checking, I'm not really sure on the matter.

Anyone care to offer their thoughts?

Is This A Good Question/Topic? 0
  • +

Replies To: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3712
  • View blog
  • Posts: 5,964
  • Joined: 08-June 10

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 10 December 2013 - 09:25 PM

I'm also having a hard time seeing a reason why case-sensitivity would affect type checking. Unless we're talking about things like classes not being case-sensitive, as is the case with PHP. In that respect, the lack of case-sensitivity can sometimes cause problems auto-loading class files, since an autoloader would be expecting the file name to mirror the class name, and if the class is not being called the same way it was defined, that would cause a failure to load it. (On systems that use case-sensitive file names, at least.)
Was This Post Helpful? 1
  • +
  • -

#3 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3479
  • View blog
  • Posts: 10,725
  • Joined: 05-May 12

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 11 December 2013 - 08:00 AM

M$FT's C++ and C programmers rely heavily on case sensitive identifiers because of the heavy use of Hungarian Notation. It gives extra program reliability and "semantic" type checking because the programmer can see what the expected underlying type is (for Systems Hungarian) or expected usage (for Apps Hungarian).

There is a need for case sensitivity to distinguish between:
byte rgbData[MAX];


vs.
typedef struct _bdata
{
    int   nID;
    DWORD dwFlags;
} BDATA;

BDATA rgbdata[MAX];


Was This Post Helpful? 1
  • +
  • -

#4 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5780
  • View blog
  • Posts: 12,595
  • Joined: 16-October 07

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 11 December 2013 - 10:26 AM

*
POPULAR

If there is a golden rule in programming, it's consistency. Case insensitivity breaks this rule.

Additionally, case insensitivity removes 26 basic symbols from being used in a unique name.

So, those are a couple of logical strikes against case insensitivity.

Stylistically, I like being able to call an instance of Foo the name foo. Here, a naming conventions relies on case sensitivity and also allows an implicit relationship to be described.

Put another way, is there any advantage at all to case insensitivity?
Was This Post Helpful? 5
  • +
  • -

#5 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2531
  • View blog
  • Posts: 4,631
  • Joined: 24-September 10

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 11 December 2013 - 12:53 PM

I personally like case sensitivity in the sense of consistency, but outside of that I really don't care. If a language is case-sensitive I go on using it with out even noticing due to my existing style... my existing style being "case-preserving case-insensitivity". In which the case doesn't matter, but I preserve the case when I've defined it.

This way if MAX was the declaration of some constant, I keep using MAX everywhere else.

But why would the language have to be case-sensitive for this? It doesn't... it can be case-insensitive and I still have the consistency. I don't need my language blowing a whistle at me to remember this... I just do it.

The thing is... a lot of the reasons for case-sensitivity make me scratch my head, as it pertains to using the language (compiling and parsing I can see the arguments for case-sensitivity).

Take for example that case-insensitivity removes 26 basic symbols from being used in a unique way. I don't know about you guys, but most of my variables aren't single characters (and I've heard many preach that single character variables are a no-no)... I name my variables words usually (with the minor exception of 'i' for index, or 'e' for event, etc). When I'm human parsing (just reading) text and I see the two following... I don't quickly make a distinction between them:

someObject
SomeObject
SomeObjEct
Someobject
someobject
SoMeObJeCt

I read... someobject

I would never say:

var foo = new Foo();

personally I don't like my variable being the same name as the type. I may say:

var fooObj = new Foo();

or

var foo1 = new Foo();

or if say a field:

private _foo = new Foo();

the underscore denoting it's a private field

I don't see the added benefit of getting to say:

var a = 5;
var A = 6;


Now there are a couple times where I might see it. Like the all cap constant... like "MAX". Ok, I see this benefit, because all caps will register in my head real-quick as being distinct from "max" (but not Max from max). So the following is pretty nice:

const MAX = 5;
var max = MAX - 1; (this acting as a temporary max in some local scope)

But I don't mind forfeiting it when I use case-insensitive languages. Doesn't bother me at all. Main reason is I seldom would have a const called "MAX" and instead give it an even more descriptive name like "MAX_HEIGHT" or something. Then I can still have my "max" variable elsewhere in the local scope. The only time I could see MAX as a constant is on a simple struct. Like Integer.MAX, but really MAX and max would only clash case wise if you had a var in side the Integer struct called max... and well, the likelihood of that is slim.

(note, my entire opinion is relative to a C-like syntax)



But eh... to each their own.

I'd have more little opinionated things for and against both case-sensitive and case-insensitive. But I gotta get back to some work right now.

In the end the, the short and sweet of it is most the arguments I've seen for case-sensitivity relate to enforcing a rule on the developer. I don't need my language to enforce that rule, I can enforce it myself. This same argument though can be used to say that it doesn't matter if its case-sensitive then because the consistency rules you may come up with work either way. And that's why I personally don't give a fuck that C-like languages are case-sensitive... I never notice it. But I also never exploit it... because code that actually makes use of the case-sensitivity isn't readable by me. I just don't make distinctions about case when human parsing text as I read, unless that case distinction is overt (all caps namely).

This post has been edited by lordofduct: 11 December 2013 - 01:01 PM

Was This Post Helpful? 3
  • +
  • -

#6 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3479
  • View blog
  • Posts: 10,725
  • Joined: 05-May 12

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 11 December 2013 - 08:32 PM

It's funny that you mentioned consistency with identifiers. I noticed that when I write code in a language that I know is not case sensitive, I am almost to the point of being anal about ensuring that I always use the same case for identifiers, but I could careless about the language keywords being consistent. It's as if I were daring the language parser to mark me wrong when I use IF in one context, and the If in another, and if in yet another.
Was This Post Helpful? 2
  • +
  • -

#7 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1940
  • View blog
  • Posts: 4,028
  • Joined: 11-December 07

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 12 December 2013 - 09:11 AM

Visual basic and visual studio offer a strange mix. The language is not case sensitive but the IDE corrects the line you just typed to match the declaration. The implementation is not perfect but it's a nice idea. I can type how I want and the IDE fixes it.

I remember learning Java. I had been programming for nearly 10 years in case insensitive languages and case sensitivity must have been a cause of at least half my compile time errors. It's second nature to me now (and I would be consistent even if I didn't have to) but I wonder just how big an obstacle it is to learners.
Was This Post Helpful? 0
  • +
  • -

#8 depricated  Icon User is offline

  • DLN-000

Reputation: 591
  • View blog
  • Posts: 2,112
  • Joined: 13-September 08

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 12 December 2013 - 09:35 AM

I'm case sensitive out of habit. Baavgai pretty much summed up my views on it. I might have WAFFLE Waffle and waffle all referenced in one function. All Caps for constants, capital first character for methods, camelCase for variables. It's rare that I'd have all 3, but there might be a reason at some point. Like if I was Waffling between having a WAFFLE or this waffle.WasOnTheFloor.

View PostSkydiver, on 11 December 2013 - 08:32 PM, said:

It's funny that you mentioned consistency with identifiers. I noticed that when I write code in a language that I know is not case sensitive, I am almost to the point of being anal about ensuring that I always use the same case for identifiers, but I could careless about the language keywords being consistent. It's as if I were daring the language parser to mark me wrong when I use IF in one context, and the If in another, and if in yet another.

I admire your fast and loose approach to keywords
Was This Post Helpful? 0
  • +
  • -

#9 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2241
  • View blog
  • Posts: 9,412
  • Joined: 29-May 08

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 12 December 2013 - 10:08 AM

I prefer case-insensitive over case-sensitive as in reduces a lot of errors and bugs do mistyping something. I'm dyslexic so this helps too.
I also notice from the replies members using a Case-Sensitive follow some form of stylistic formatting to convey additional meaning to the identifier.
Was This Post Helpful? 0
  • +
  • -

#10 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3243
  • View blog
  • Posts: 10,882
  • Joined: 12-December 12

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 12 December 2013 - 12:17 PM

I always assume case-sensitivity. However, in VB and Visual Studio specifically, I tend to type in lowercase and let the IDE correct it for me. The editor is excellent for VB and this is a good way to confirm that I've spelt things correctly.

This is a little pedantic I know but, personally, I think that anything that encourages care, and attention to detail, particularly in beginner programmers, is a good thing. (Typing in lowercase is an exception particularly for VB and Visual Studio, simply because the editor is so good.)
Was This Post Helpful? 0
  • +
  • -

#11 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5780
  • View blog
  • Posts: 12,595
  • Joined: 16-October 07

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 12 December 2013 - 02:04 PM

View PostSkydiver, on 11 December 2013 - 11:32 PM, said:

It's funny that you mentioned consistency with identifiers.


You know I kind do the same thing... My own symbols need consistency. However, is it ElseIf or Elseif? You know, if the language can even be bothered to worry about it, why the hell should I?

Actually, that's part of the problem. At some point the inconsistency will probably irk me to the point that I have to fix it. Or, conversely, the IDE might decide what case I should use. At which point, why the hell was allowed the option in the first place?

Perhaps it's helpful editors I have the real problem with. In SQL Server, various interfaces will get me getdate(), GetDate(), or GETDATE(), depending on version number, solar flares, whatever. I need to be protected not from myself, but overly "helpful" tools.
Was This Post Helpful? 0
  • +
  • -

#12 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3712
  • View blog
  • Posts: 5,964
  • Joined: 08-June 10

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 12 December 2013 - 04:03 PM

View Postbaavgai, on 12 December 2013 - 09:04 PM, said:

In SQL Server, various interfaces will get me getdate(), GetDate(), or GETDATE(), depending on version number, solar flares, whatever. I need to be protected not from myself, but overly "helpful" tools.

Yea, this is also true for MySQL. I've always typed all SQL keywords and functions in all upper case, following the examples in the manual, but the recently added code-complete thing in Workbench will automatically insert them in all lower case. Annoying as hell.
Was This Post Helpful? 0
  • +
  • -

#13 AnalyticLunatic  Icon User is offline

  • D.I.C Lover

Reputation: 221
  • View blog
  • Posts: 1,030
  • Joined: 25-June 12

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 13 December 2013 - 06:58 AM

View PostAtli, on 12 December 2013 - 11:03 PM, said:

View Postbaavgai, on 12 December 2013 - 09:04 PM, said:

In SQL Server, various interfaces will get me getdate(), GetDate(), or GETDATE(), depending on version number, solar flares, whatever. I need to be protected not from myself, but overly "helpful" tools.

Yea, this is also true for MySQL. I've always typed all SQL keywords and functions in all upper case, following the examples in the manual, but the recently added code-complete thing in Workbench will automatically insert them in all lower case. Annoying as hell.


Very annoying indeed. Here we are trying to be all proper and follow the "NORM", and workbench ruins everything.
Was This Post Helpful? 0
  • +
  • -

#14 mojo666  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 352
  • View blog
  • Posts: 770
  • Joined: 27-June 09

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 14 December 2013 - 01:38 PM

Quote

If there is a golden rule in programming, it's consistency. Case insensitivity breaks this rule.

Additionally, case insensitivity removes 26 basic symbols from being used in a unique name.

So, those are a couple of logical strikes against case insensitivity.

Stylistically, I like being able to call an instance of Foo the name foo. Here, a naming conventions relies on case sensitivity and also allows an implicit relationship to be described.

Put another way, is there any advantage at all to case insensitivity?


I used to agree with this and defend this way of thinking, but it is easy to abuse and just plain screw up. I have had to deal with code like

class Myclass
class MyClass
MyClass myclass
Myclass myClass


The fact that case insensitivity prevents this is a huge plus. If you have already used a similar identifier, you now must be more explicit with the new identifier you are trying to add. Removing the 26 symbols adds a restriction that encourages the programmer to put more care into his code.

Also, we can make the argument that consistent treatment of the same letters regardless of their case is more consistent.

Quote

This case-sensitivity I believe would also lessen compile-time complexity for similar reasons, cutting down on ambiguity concerns.


I don't think it would affect complexity. All the compiler really has to do is scan through the source code and convert all non-data characters to the same case and then compile as normal. This step is trivial.
Was This Post Helpful? 1
  • +
  • -

#15 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5780
  • View blog
  • Posts: 12,595
  • Joined: 16-October 07

Re: Advantages/Disadvantages of Case-Sensitivity in a Prog. Language?

Posted 14 December 2013 - 03:19 PM

View Postmojo666, on 14 December 2013 - 04:38 PM, said:

it is easy to abuse and just plain screw up.


Bad code is bad. You can write crap in any language, in any paradigm.

You can use FooBar and FoobAr in case sensitive or FOObar and FO0BAR in case insensitive. Same problem. If you can't get your own declarations sorted, you'll fail regardless of language.

Still, interesting case.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2