Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
2 К ПС(мережі 1, 2 семестр).doc
Скачиваний:
0
Добавлен:
01.03.2025
Размер:
3.75 Mб
Скачать

Defining features

COBOL as defined in the original specification, possessed excellent self-documenting capabilities, good file handling methods, and exceptionally good data typing for the time, owing to its use of the PICTURE clause for detailed field specification. However by modern standards for programming language definition, it had serious flaws, notably verbose syntax and lack of support for local variables, recursion, dynamic memory allocation, and structured programming. Its lack of support for object-oriented programming is understandable, given that the concept was unknown at the time

COBOL has many reserved words, and it is hard to avoid unintentionally using one, without using some convention such as adding an unlikely prefix to all variable names. The original COBOL specification even supported self-modifying code via the famous "ALTER X TO PROCEED TO Y" statement. Consequently, little new code is being written in COBOL. However, the COBOL specification has been redefined over the years to address some of these criticisms. and later definitions of COBOL have remedied many of these lacks, adding improved control structures, object-orientation and removing the ability to use self-modifying code.

21. C programming language. Pascal and c

Pascal was developed about the same time as C, and there are important similarities between the two. Both were strongly influenced by Algol 60 and incorporate many of its essential features, including its block structure and type system, although the approach to type safety is quite different.

Original Pascal and straight C are both small procedural languages implementing structured programming concepts. Both have functionality for the dynamic allocation of memory and some form of pointer manipulation. However, Pascal was designed, mainly, as a teaching language. Error-prone constructs were carefully avoided, and an effort was made to make the syntax easy to understand. The authors of C placed more emphasis on brevity, because C was designed for professional programmers.

The main differences between original Pascal and C are following:

  • C has lots of operations which change their first operand (++ -- += etc.) This feature is good, but may be easily abused.

  • C has bitwise operations (| & ^ ~ << >>), while Pascal has sets.

  • C allows much greater freedom with pointers. In C, you can directly access any address in memory; given a variable a, an operation &a returns its address; there are functions malloc() and calloc() which allocate any number of bytes; pointers and arrays are oftenly interchangeable. This make C more useful for a serious programming than Pascal, but also causes many bugs which are hard to find.

  • Pascal allows passing parameters either by value or by reference. In C, parameters can be passed only by value, and call by reference requires explicitly passing a pointer value.

  • Pascal provides subrange types, which are very useful for early detection of bugs.

  • Pascal lacks separate compilation.

  • Pascal lacks preprocessing. There is nothing in original Pascal which resembles #include, #define, #ifdef etc.

  • C supports different lengths of numbers (short int, int and long int; float and double) and unsigned integer numbers and characters. In Pascal, all numbers are of fixed length, and there are no unsigned numbers.

  • In C, there is no boolean type.

  • Pascal lacks continue and break operators.

  • Pascal permits nested function definitions.

Together, these differences made Pascal significantly simpler and safer than C, but less useful (in fact, almost useless) for profesional programming. However, modern implementations of Pascal eliminate its flaws (and add means for object-oriented programming), making Pascal as useful as C or C++, but also as complicated as these.