> There is an old saying "C combines the power of assembly language
> with the flexibility of assembly language": the point being
> that C as a language is very close to assembly language.


LOL. We are discussing HLASM. Have you used the assemblers in the comparison.

> Both require the programmer to express 
> their code at a very low level: "close to the metal".

LOL. To the contrary, HLASM is often used to abstract the programmer from the 
hardware. In the past, it was used for IO, CICS and IMS definitions. I believe 
it was used for the MVS stage 1 build. It's used for TSO parsing. I used it to 
allow easy form creation. I'm sure there are many more. 

The alternative in C would require the creation of new languages because C does 
not allow for this flexibility. Case in point is XML where the C solution is 
the new programming language called "schema" (which by the way has many varied 
flavors). Instead of creating new languages, the developers were able to 
quickly, easily and consistently create these solutions and concentrate on 
their product design.

> The main advantage of C over HLASM is that C has an optimizing compiler.

C programmers are given a task and they do it well within the limitations of 
that tool. It's not their fault but "garbage in, garbage out". You can do all 
the mechanical optimization possible, but at the end of the day, the language 
forces certain techniques. Case in point is XML. Over the years with several C 
implementations, the basic design has not changed. HLASM can on the other hand 
uses abstraction to allow programmers to easily and optimally generate code. In 
fact, HLASM is one of the only languages that can significantly alter it's 
behavior on the fly. For instance, Ed Jaffe specifically mentioned SPM (e.g. IF 
opcode).

Regards, Jon.
On Tuesday, January 23, 2018 1:26 PM, Martin Ward <[email protected]> wrote:



There is an old saying "C combines the power of assembly language
with the flexibility of assembly language": the point being
that C as a language is very close to assembly language.

C has few of the powerful abstraction features found in modern
programming languages: automated memory allocation and
garbage collection, first class functions, higher order functions,
closures, hash tables, abstract data types and so on.

C and HLASM both have support for basic, low-level programming
features such as prodecure calls, conditional statements
and while/repeat loops. Both require the programmer to express
their code at a very low level: "close to the metal".

The main advantage of C over HLASM is that C has an optimising compiler.
If performance is of ultimate importance (and why would anyone
use such low-level languages otherwise?) then the C compiler
can automatically provide register allocation, loop unrolling
and procedure inlining where heuristics indicate these
transformations will improve performance.

A good assembler programmer might make reasonable choices
for register allocation on first writing the program:
but will they be willing to recalculate a new register
allocation after each addition or modification to the program?
Will they choose to write optimal, but unstructured
and unmaintainable spaghetti code or readable but
less efficient structured code? With a compiler,
the programmer can write structured code and allow
the optimiser to apply common subexpression elimination,
pointer chasing, loop unrolling, procedure inlining,
and so on, creating mode efficient code which would be
unmaintainable if it had been written that way
in the first place.

Finally, modern C compilers, such as gcc, can perform
whole program optimisation, applying interprocedural
optimisation to all functions and variables, including
statically-linked libraries.

-- 
            Martin

Dr Martin Ward | Email: [email protected] | http://www.gkc.org.uk
G.K.Chesterton site: http://www.gkc.org.uk/gkc | Erdos number: 4

Reply via email to