Programming Languages
A Dave Hillman Project

[Home] [Contact Me] [Site Map] [Search] [References]

Language Basics

 

[Up]
[Template]

[Language Basics]
[C Language]
[C++]
[C#]
[Java]
[JavaScript]
[Visual Basic 6.0]
[VBScript]
[VB.Net]
[.Net Technology]

 

 

Introduction

Most programming languages share a common set of features.

The purpose of this discussion is to provide an overview of general principles found in programming languages.

Language Fundamentals

Program Structure and Organization

bulletMost programs are constructed around:
bulletData declarations - local and global
bulletFunctions that return values to calling agents.
bulletSubroutines that do some work but do not return values.
bulletFunctions and subroutines may be built-in to the programming language.
bulletProgrammers create functions and subroutines to implement an application; typically these are built from existing and other user-defined elements.
bulletDepending on the language, a pre-defined function or subroutine name is the starting point for program execution.
bulletProgram structure:
bulletLinks to other files that have supporting information such as additional functions.
bulletCommenting code: most programming environments allow you to add "English" comments to a program.
bulletLanguage/character sets: a character set for development (many use ASCII text), and a character set for delivery.
bulletIdentifiers and keywords: words and expressions that are "off-limits" to user-defined functions and subroutines, for example:
bulletif, then
bulletfor, do, next
bulletdim, var
bulletsingle, double, float
bulletNote: keywords are specific to a language and do vary.
bulletSource code management: programs are written into files called source code.  Source code files are written with a variety of tools including:
bulletText editors
bulletIntegrated development environments (IDE) that include tools for creating and manipulating program graphical objects.
bulletProgram delivery:
bulletCompiled: source programs are compiled to object files, linked, and executable machine language programs are created.  These are typically operating system specific.  Compiled programs tend to be faster and use memory and processing resources more efficiently.
bulletScript: "English" code is evaluated and executed on the fly.  Tend to be slower than compiled but are easy to develop and deploy.
bulletIntermediate (e.g., byte code): source code is partially compiled and executed via a run-time engine.

Data Types

Data typing enable computers to manage elements of information (data) within the confines of the limited computer memory resources. 

Data typing tends to be "strong" or "weak":

bulletStrongly typed languages (e.g., C, Java, etc.) require that you declare variables before you use them.  This enables efficient memory management.
bulletWeakly typed languages (e.g. JavaScript, VBScript, and Visual Basic) do not require that you declare variables before you use them.  The benefit is rapid development, but the downside is a loss in efficiency (they generally require more memory to manage data and more processing to figure things out).

Data types cover the variety of ways that we represent and use data in the real world:

bulletNumbers
bulletIntegers
bulletReal numbers
bulletAmount of memory (i.e., number of bytes) determines the size of the data, for example:
bullet2 bytes: integer, range: -32,768 to 32,768
bullet8 bytes: double/floating point, range: -1.79769313486232E308 to -4.94065645841247E-324 for negative values;
bulletStrings/characters
bulletCharacters in a character format (e.g., ASCII).
bulletSingle to large sets of characters.
bulletTypically one character = one byte.
bulletBoolean
bulletTrue and False
bulletSome languages use a single 0 (false) or 1 (true); others have an explicit Boolean data types.
bulletVoid/null
bulletNon-value assigned to a variable
bulletOther data types:
bulletDate/time
bulletCurrency
bulletObject
bulletBLOB (binary large object, e.g., graphics)
bulletVariant
bullet"Universal" data type capable of holding numbers, strings, etc.
bulletConstants: built-in terms that have pre-defined values.
bulletArrays
bulletSingle and multi-dimensional structures of data.
bulletTypically arrays are defined prior to use (size and data types).
bulletSome languages allow you dynamically re-dimension an array, others do not.
bulletVariable declaration
bulletMost languages require variables to be declared before use.
bulletDeclaration: name of the variable and type.
bulletMost languages will initialize a variable before it is assigned a value, e.g., a number initializes to 0 or a string to an empty string.
bulletMay also include initializing the value of the variable.
bulletVariable scope
bulletLocal scope: variable exists within the lifetime of a function or subroutine.
bulletGlobal scope: variable available to entire application for duration of the program lifetime.

Expressions and Operators

Math and logical operations are the heart of computer programs.  They enable the data to be manipulated, compared, stored, and processed.

bulletMath operators
bulletBasic arithmetic capabilities including addition, subtraction, multiplication, and division.
bulletBasic math symbols used in most languages (+, -, *, ?).
bulletPrecedence for algebra must be considered, e.g.,
bullet1 + 3 * 2 = 7 -- multiplication precedes addition.
bullet(1 + 3) * 2 = 8 -- use parenthesis to change precedence.
bulletMay include advanced capabilities (e.g., exponent, modulus division, increment, and decrement)
bulletAssignment operators
bulletEnables variables to be set to a value.
bulletTypically represented by equal sign: =
bulletRelational operators
bulletCompare data: equivalency, less-than, greater-than, etc.
bulletMost often deals with numbers; can also deal with text (e.g., "A" is less than "B").
bulletLogical operators
bulletAND, OR, NOT
bulletOften used with relational operators to create complex program logic.

Control Statements

if computers were limited to math operations, they would be called calculators!  Control statements enable data to be evaluated and processed.

bulletIf (expression) - then (action)
bulletMost common method used in program operations to handle choice-based reasoning (if-then logic).
bulletTypically consists of:
bulletif (expression) - an expression that can be evaluated to a true/false state by evaluation.
bulletthen (action) - the action is one or more statements to be accomplished if the if-expression is TRUE.
bulletelse (action) - one or more statements to be accomplished if the if-expression is FALSE.
bulletelse-if (expression) - expressions are evaluated as encountered - assumes prior expressions are evaluated in sequence.
bulletEvaluation expressions may be complex logical operations: e.g., if (a < b AND c > d OR e = 5)
bulletShort-circuit action may occur is "a" is not less than "b" - i.e., no reason to continue evaluation; in some systems, all evaluations may be processed regardless of subordinate logical operations.
bulletSelect/switch
bulletEvaluate a variable and then execute actions depending on the values for each case.
bulletEssentially a form of if-then processing but implementation often makes it more efficient.
bulletDo/While loop
bulletLooping process in which a set of action statements are executed until an evaluation expression evaluates to true.
bulletLoop evaluation may occur at beginning or end.
bulletMany implementations allow premature exit of the loop.
bulletFor loop
bulletLooping mechanism based on the evaluation  of a numeric variable.
bulletVariable has starting point, ending point, comparison (equal, greater than, etc.), and stepping function (increment by one, etc.).
bulletMany implementations allow premature exit of the loop.
bulletObject variations include ability to cycle through a collection of objects or property elements of an object (for-each).
bulletGo To
bulletDirect jump to a labeled segment of code (typically within the same function/sub).
bulletConsidered a weak programming practice.
bulletBreak/exit
bulletVarious statements can be used to prematurely leave a processing loop, function, or subroutine.
bulletThese are typically combined with if-then expressions to trigger the statement.

Input/Output

bulletCommand Line
bulletMost basic level of computer interfaces.
bulletText-based interface.
bulletBased on keyboard and command line via the screen (text only).
bulletProgram typically has explicit functions to get/display data; programs are heavily I/O code dependent.
bulletWindows (GUI interface)
bulletBased on mouse/keyboard and graphic screen interface.
bulletEvent driven metaphor, most programs are driven by clicking, scrolling, etc..
bulletOperating system handles display of window elements and user input; messages are sent to program to deal with user interactions.
bulletFile I/O
bulletBasic file operations: open and close; ability to read, write, or append data to the file.
bulletMany languages enable you to read/write single to large numbers of characters.
bulletReading/writing may be based on set number of characters (fields), lines terminated by carriage return line-feed sequences), or entire file sets.
bulletDatabase
bulletStructured data files.
bulletTypically accessed by intermediate tools and interfaces (e.g., ODBC).
bulletMay involve a data manipulation language such as SQL or intermediate programming interface such as ADO.

Libraries and Support

bulletInternal routines
bulletMany languages have sets of built-in functions and routines for a variety of processes including:
bulletAdvanced string handling (search, replace, locate substrings).
bulletAdvanced math (sin, cosine, etc.).
bulletDate/time functions
bulletFile operations
bulletDatabase operations
bulletAdvanced I/O functions.
bulletProgram libraries:
bulletBuilt-in libraries providing various processing capabilities.
bulletAdditional user-defined, created, and developed libraries.

 

[Home] [Language Basics] [C Language] [C++] [C#] [Java] [JavaScript] [Visual Basic 6.0] [VBScript] [VB.Net] [.Net Technology]

Copyright © 2003-2005 by Dave Hillman