Friday, November 20, 2009

Identifiers


This post is part of my ongoing effort to familiarize the readers with the commonalities & variabilities of C++/Java/C# programming languages. A tentative outline of this series can be found at Contents.

I want to start today's post with a good news. Microsoft has announced to open source .Net Micro Framework under the Apache 2.0 license. It is a big news for Open Source enthusiasts. MS has come forward a step closer to open source the complete .Net Framework in the future. Does it mean the beginning of the end of Mono? I believe Mono is more than .Net framework. Our cross-platform hexeditor will conver both .Net and Mono platform, so it is a good experiment to distinguish the commonalities and variabilities of these two platforms.

Today's post will be short. I will explain the most important constituents of programming syntax - the identifiers. We need words in natural language to communicate with each other. Similarly, in programming languages Identifiers are used to communicate with the system. The compiler gives us a set of names called Keywords which have predefined meanings. In contrast, identifiers are the names we supply to our programs. The identifiers and keywords form statements that define the syntax of the program similar to sentences of natural languages. The identifiers must be different from the keywords. So it is important that you have a fair amount of knowledge on the keywords in your programming language.

There are various types of identifiers we use for naming the entities of the programs - variables, function names, constants, user-defined types, labels etc. Most programmers follow some convention for naming them. There are some well accepted naming conventions in different languages for identifiers e.g. - Pascal Case, Camel Case, Hungarian Notation. There are coding guidelines from Microsoft for C# and from Sun for Java. Many programmers who code both in Java and C++, uses the Java conventions. If I can hold my energy, I will write a complete post on various coding conventions.

Identifier naming rules common to C++/Java/C#:
  1. case sensitive
  2. only characters(A-Z, a-z), digits(0-9), underscore(_) can be used
  3. can't start with a digit
  4. no space is allowed inside the identifier name
Examples:
   doSum, _tryit, transform3D
   do Sum (space inside), /tryit (invalid char), 3DTransform (can't start with digit)



1 comment:

  1. Can you please write the next post for this release? The source code of C++ hello world is missing from the subversion though it exists in zip file. Thanks for your writing.

    ReplyDelete