[comp.object] C as a replacement for assembler

schwartz@groucho.cs.psu.edu (Scott Schwartz) (04/09/91)

In article <1576@acf5.NYU.EDU> sabbagh@acf5.NYU.EDU (sabbagh) writes:
   Finally, I want to point out that the invention of C++, Eiffel and a 
   number of other languages have pointed out the true value
   of C: as a replacement to assembly language! I predict that most future
   languages will compile to C instead to machine language. This is a
   tremendous achievement for the software community: true resuability of
   language and concepts.

The problem with compiling to C is that certain things are impossible
to express properly and/or safely.  For example, modula 3 has
difficulty with garbage collection when the C compiler's optimizer
decides to rearrange or elide code.  There are other things that crop
up, but you get the idea.

diamond@jit345.swstokyo.dec.com (Norman Diamond) (04/09/91)

In article <4o5G2erk1@cs.psu.edu> schwartz@groucho.cs.psu.edu (Scott Schwartz) writes:
>In article <1576@acf5.NYU.EDU> sabbagh@acf5.NYU.EDU (sabbagh) writes:
>   Finally, I want to point out that the invention of C++, Eiffel and a 
>   number of other languages have pointed out the true value
>   of C: as a replacement to assembly language!
>The problem with compiling to C is that certain things are impossible
>to express properly and/or safely.  For example, modula 3 has
>difficulty with garbage collection when the C compiler's optimizer
>decides to rearrange or elide code.

Indeed, the C compiler users and vendors and standardizing committees
forgot the original purpose of C.  In order to use C as originally
intended, as a replacement for assembly language, it is necessary to
take these steps:
(1)  Use only a subset of the C language;
(2)  Do the optimizations yourself (or in your high-level language compiler);
(3)  Use an old C compiler or disable optimizations in your C compiler.

Follow-ups to comp.misc.
--
Norman Diamond       diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.

bvs@BitBlocks.COM (Bakul Shah) (04/10/91)

In <4o5G2erk1@cs.psu.edu> schwartz@groucho.cs.psu.edu (Scott Schwartz) writes:
|The problem with compiling to C is that certain things are impossible
|to express properly and/or safely.  For example, modula 3 has
|difficulty with garbage collection when the C compiler's optimizer
|decides to rearrange or elide code.

This seems like a perfect opportunity for overloading `volatile' --
declare a piece of code volatile to prevent any rearrangement or
elision.  As in

	volatile {
		i = 1;
		i = 2;
		j = 3;
		k = 4;
		for (i = 0; i < 10; i++)
			j += 10*k;
	}

The idea is that every variable within a volatile block is treated
as if stored in volatile storage (with possible side effects).  Now,
to make this even more useful one would need `nonvolatile' so that
access to selected variables can be optimized even within a volatile
block.  Nonvolatile also appeals to my sense of symmetry.

Has anyone done (or thought of doing) this?  Anyway, just an idea
for you language designer wannabes.

Bakul Shah
bvs@bitblocks.com