The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] Comments on "C"
@ 2016-08-28 18:21 Dave Horsfall
  2016-08-29  0:37 ` Marc Rochkind
  0 siblings, 1 reply; 32+ messages in thread
From: Dave Horsfall @ 2016-08-28 18:21 UTC (permalink / raw)


Seen on another list...  And I got quoted by Steve Bellovin :-)

-- 
Dave Horsfall DTM (VK2KFU)  "Those who don't understand security will suffer."

---------- Forwarded message ----------
From: Kent Borg
To: cryptography at metzdowd.com
Subject: Re: [Cryptography]
    "NSA-linked Cisco exploit poses bigger threat than previously thought"

On 08/25/2016 06:06 PM, Steven M. Bellovin wrote:

> I first heard more or less that line from Doug McIlroy himself; he 
> called C the best assembler language he'd ever used.

Ancient fun-fact: Years ago there was an article in Byte magazine 
describing how a useful subset of C could be directly assembled into 68000 
code. Not compiled, assembled.

C is a stunning assembly language. When those wild-eyed nerds at AT&T 
decided to write Unix not in assembly but in C (where was management!?), 
it was radical. But C was up to (down to?) the task, it was pioneering 
then and is still doing useful things decades later: From the fastest 
supercomputers to some pretty slim microcontrollers (plus a hell of a lot 
of Android devices) multitudes of computers run a Linux kernel compiled 
from the *same* C source code, with almost no assembly. Big-endian, 
little-endian: no matter. Different word lengths: no matter.

That is one impressive cross-platform assembly language!

Unfortunately, C is also a dangerous language that mortal programmers 
cannot reliably wield.

-kb, the Kent who knows he is pressing his luck on a moderated 
cryptography mailing list, but C deserves a lot of respect, as it also 
deserves to be efficiently sent into a dignified retirement.

_______________________________________________
The cryptography mailing list
cryptography at metzdowd.com
http://www.metzdowd.com/mailman/listinfo/cryptography



^ permalink raw reply	[flat|nested] 32+ messages in thread
* [TUHS] Comments on "C"
@ 2016-09-01  9:17 Norman Wilson
  2016-09-01 15:11 ` Clem Cole
                   ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: Norman Wilson @ 2016-09-01  9:17 UTC (permalink / raw)


Every time someone starts spouting about how unsafe
C is, and how all the world's problems would be solved
if only people would stop using it, I think of Flon's
Axiom, for 35 years my favourite one-liner about
programming and languages:

  There does not now, nor will there ever, exist a
  programming language in which it is the least bit
  hard to write bad programs.

Flon's Axiom comes from a short note On Research
in Structured Programming, published in SIGPLAN
Notices in October 1975.  It's just as true today.

Over the years I've seen people misinterpret the
Axiom as an argument against looking for better
programming languages at all, but that's not what
it means.  (Read the original note--it's a page
and a half--for full context; it is, alas, behind
ACM's Digital Library paywall.)  There are certainly
languages that make certain sorts of mistakes easier
or harder, or are easier or harder to read, but in
the end most of that really is up to the programmer.

Programming well requires a lot of thought and care
and careful rereading, and often throwing half the
code out and re-doing it better, and until we can
have a programming community the majority of whom
are up to those challenges, we will continue to have
crashes and security vulnerabilities and other
embarrassing bugs aplenty, no matter what language
is used.

Norman Wilson
Toronto ON


^ permalink raw reply	[flat|nested] 32+ messages in thread
* [TUHS] Comments on "C"
@ 2016-09-08 12:35 Doug McIlroy
  2016-09-09 17:07 ` scj
  0 siblings, 1 reply; 32+ messages in thread
From: Doug McIlroy @ 2016-09-08 12:35 UTC (permalink / raw)


> After about 30 years of C, there are only three things I would
have liked to see:

> 1.  Computed goto

...

> Computed goto's are good for interpreters.

A computed goto, of course, is merely an optimized switch.
Dennis installed this optimization early in the evolution of C. The
main driving force was the performance and size of the PDP-11 Unix
kernel. As functionality grew, resource usage was repeatedly tamped
down by improving C's code generation.

The switch optimizer chose among three strategies: naive, binary
decision tree, and computed goto, depending on the number and density
of switch alternatives. Hybrid strategies may have been used, too,
but my memory is hazy on this point. In particular the optimization
improved system-call dispatch--thus achieving the objective,
"good for interpreters". I assume (I hope not unrealistically)
that this optimization has been in the repertoire of mainline C
compilers ever since.

> (Or perhaps require C to support tail recursion.)

I can imagine making a strong recommendation in the standard for
optimizing switches and (at least direct) tail recursion.

Doug


^ permalink raw reply	[flat|nested] 32+ messages in thread
* [TUHS] Comments on "C"
@ 2016-09-08 13:30 Noel Chiappa
  2016-09-08 14:22 ` Tony Finch
  2016-09-09 21:15 ` Mary Ann Horton
  0 siblings, 2 replies; 32+ messages in thread
From: Noel Chiappa @ 2016-09-08 13:30 UTC (permalink / raw)


    > From: Blake McBride

    > After about 30 years of C, there are only three things I would have
    > liked to see:

    > 1.  Computed goto

Can't you make a switch statement do what you need there? 

The two things I really missed were:

- BCPL's ValOf/ResultIs, for making more complex macros (although with the
	latest modern compilers, which inline small functions, this is less
	of an issue)
- The ability to 'break' out of more than one level of nesting; one either
	has to stand on one's head (code-wise), or use a goto

	Noel


^ permalink raw reply	[flat|nested] 32+ messages in thread
* [TUHS] Comments on "C"
@ 2016-09-09  2:43 Doug McIlroy
  0 siblings, 0 replies; 32+ messages in thread
From: Doug McIlroy @ 2016-09-09  2:43 UTC (permalink / raw)


I sent a similar message some time ago, but I haven't
seen it appear in the mailing list, so here goes again.
Apologies if it ends up as a duplicate.

> After about 30 years of C, there are only three things I would have liked
> to see:
> 
> 1.  Computed goto
> ...
> Computed goto's are good for interpreters.

A computed goto is an optimized switch, and that optimization
goes back to the original C compiler. Mostly driven by
considerations of size and speed of the Unix kernel, Dennis
quite early on taught the compiler to choose among three
compilation strategies for a switch: a chain of comparisons, 
a tree of comparisons, or a computed goto, depending on the
number and density of alternatives.

The compilation of the system-call dispatch table was
a perfect example of "good for interpreters."

I have always assumed that other mainline compilers behave
similarly, but I have no solid knowledge about that.

doug


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2016-09-09 21:15 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-28 18:21 [TUHS] Comments on "C" Dave Horsfall
2016-08-29  0:37 ` Marc Rochkind
2016-08-29  0:42   ` Larry McVoy
2016-08-29  1:54     ` Steve Nickolas
2016-09-08  1:19     ` Blake McBride
2016-08-29  3:16   ` Greg 'groggy' Lehey
2016-08-31 10:02     ` Tim Bradshaw
2016-08-31 12:59       ` John Cowan
2016-08-31 13:32         ` Ron Natalie
2016-08-31 14:37           ` John Cowan
2016-08-31 13:57   ` Brantley Coile
2016-09-01  9:17 Norman Wilson
2016-09-01 15:11 ` Clem Cole
2016-09-01 21:47 ` Tim Bradshaw
2016-09-02  0:11   ` Mary Ann Horton
2016-09-02  7:10     ` Steve Simon
2016-09-02 10:02       ` Steve Nickolas
2016-09-02 14:13       ` Random832
2016-09-02 21:23 ` Dave Horsfall
2016-09-04 17:03   ` scj
2016-09-05 13:07     ` Ron Natalie
2016-09-04 22:24   ` Nemo
2016-09-08 12:35 Doug McIlroy
2016-09-09 17:07 ` scj
2016-09-08 13:30 Noel Chiappa
2016-09-08 14:22 ` Tony Finch
2016-09-08 19:20   ` Ron Natalie
2016-09-08 22:06     ` Dave Horsfall
2016-09-09  3:02       ` Ronald Natalie
2016-09-09  6:06         ` Diomidis Spinellis
2016-09-09 21:15 ` Mary Ann Horton
2016-09-09  2:43 Doug McIlroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).