COMPUTER LANGUAGE SINTAX
Every spoken language has a general set of rules for how words and sentences should be structured. These rules are collectively known as the language syntax. In computer programming, syntax serves the same purpose, defining how declarations,
functions, commands, and other statements should be arranged.
Many computer programming languages share similar syntax rules, while others have a unique syntax design. For example,
C and
Java use a similar syntax, while
Perl has many characteristics that are not seen in either the C or Java languages.
A program's
source code must have correct syntax in order to
compile correctly and be made into a program. In fact, it must have perfect syntax, or the program will fail to compile and produce a "syntax error." A syntax error can be as simple as a missing parenthesis or a forgotten semicolon at the end of a statement. Even these small errors will keep the source code from compiling.
Fortunately, most integrated development environments (
IDEs) include a parser, which detects syntax errors within the source code. Modern parsers can even highlight syntax errors before a program is compiled, making it easy for the programmer to locate and fix them.
NOTE: Syntax errors are also called compile-time errors, since they can prevent a program from compiliing. Errors that occur in a program after it has been compiled are called
runtime errors, since they occur when the program is running.
SOURCE CODE
Every computer program is written in a programming language, such as
Java,
C/C++, or
Perl. These programs include anywhere from a few lines to millions of lines of text, called source code.
Source code, often referred to as simply the "source" of a program, contains variable declarations, instructions, functions, loops, and other statements that tell the program how to function. Programmers may also add comments to their source code that explain sections of the code. These comments help other programmers gain at least some idea of what the source code does without requiring hours to decipher it. Comments can be helpful to the original programmer as well if many months or years have gone by since the code was written.
Short programs called
scripts can be run directly from the source code using a scripting engine, such as a VBScript or
PHP engine. Most large programs, however, require that the source code first be compiled, which translates the code into a language the computer can understand. When changes are made to the source code of these programs, they must be recomplied in order for the changes to take effect in the program.
Small programs may use only one source code file, while larger programs may reference hundreds or even thousands of files. Having multiple source files helps organize the program into different sections. Having one file that contains every variable and function can make it difficult to locate specific sections of the code. Regardless of how many source code files are used to create a program, you will most likely not see any of the original files on your computer. This is because they are all combined into one program file, or
application, when they are compiled.