> C has few of the powerful abstraction features found in modern programming 
> languages

Agreed. C++ provides some of those.

Charles


-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]] On 
Behalf Of Martin Ward
Sent: Tuesday, January 23, 2018 1:26 PM
To: [email protected]
Subject: Re: Fair comparison C vs HLASM

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.

Reply via email to