Content deleted Content added
Jim McKeeth (talk | contribs) m clarify Delphi programming language link |
Jim McKeeth (talk | contribs) Hello World, more syntax |
||
Line 5:
== Unique Features ==
Unlike programming languages descended from [[C programming language|C]], Pascal uses <tt>:=</tt> for assignment instead of <tt>=</tt>. This is an advantage in differentiating comparisons and assignments. In C <tt>==</tt> is comparison, but <tt>=</tt> is an assignment. These can be easily interchanged resulting in an inline assignment instead of a comparison. Also, <tt>=</tt> has always been comparison in [[mathematics]], so to change the meaning in a programming langauge results in confusion. This [[syntax]] leads to many hard-to-track bugs in C code. Since Pascal does not allow inline assignments, and uses distinct syntax for assignments and comparisons, it does not suffer from these bugs.
Another major difference is that Pascal is strongly typed. This means that all variables must be defined with a specific type before they can be used. Also, incompatible variable assignments are not allowed without an explicit type-cast. This prevents common errors where variables are used incorrectly because the type is unknown. It also alleviates the need for [[Hungarian notation]] - the practice of suffixing variable names with type-identifying letters.
Line 35:
Many uninformed people still subscribe to the old belief that Pascal is not for "serious" programming and do not realize the benefits it currently offers. This stigma, more than any actual deficiency, is Pascal's biggest liability.
== Hello World ==
A common example of a language's [[syntax]] is the [[Hello world program]].
PROGRAM HelloWorld;
BEGIN
WriteLn('Hello World!');
END.
All programs start with the "Program" [[keyword]], and a [[block]] of code is indicated with the "Begin" / "End" keywords. Case is ignored in the Pascal language. Simicolons end each statement, and the period ends the program (or unit). For some compilers the Program line is optional. Also, in some instances the simicolon is optional (before an end keyword, for example).
== Further reading ==
|