Fantastic exchange from DConf

Dibyendu Majumdar via Digitalmars-d digitalmars-d at puremagic.com
Sat May 13 17:05:56 PDT 2017


On Saturday, 6 May 2017 at 06:26:29 UTC, Joakim wrote:
> Walter: I believe memory safety will kill C.
>

Hi,

I think that comparing languages like D to C is not appropriate. 
C is a high level assembler and has different design goals. A 
useful document to refer to is:

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1250.pdf

In particular: (although note the addition of facet f, which 
echoes the sentiment that security is important)

Keep the spirit of C. The Committee kept as a major goal to 
preserve the traditional
spirit of C. There are many facets of the spirit of C, but the 
essence is a community
sentiment of the underlying principles upon which the C language 
is based. For the Cx1
revision there is consensus to add a new facet f to the original 
list of facets. The new
spirit of C can be summarized in phrases like:

(a) Trust the programmer.
(b) Don't prevent the programmer from doing what needs to be done.
(c) Keep the language small and simple.
(d) Provide only one way to do an operation.
(e) Make it fast, even if it is not guaranteed to be portable.
(f) Make support for safety and security demonstrable.

Proverb e needs a little explanation. The potential for efficient 
code generation is one of the most important strengths of C. To 
help ensure that no code explosion occurs for what appears to be 
a very simple operation, many operations are defined to be how 
the target machine's hardware does it rather than by a general 
abstract rule. An example of this willingness to live with what 
the machine does can be seen in the rules that govern the 
widening of char objects for use in expressions: whether the 
values of char objects widen to signed or unsigned quantities 
typically depends on which byte operation is more
efficient on the target machine.

I think Linus Torvalds makes an important observation - he says 
in one of his talks is that the reason he likes C is that when he 
write C code he can visualize what the machine code will look 
like.

My feeling is that the C has traditionally been used in contexts 
where probably it should not be used - i.e. as a general purpose 
application development language. But I don't see how languages 
like D or Rust can replace C for certain types of use cases.

Regards
Dibyendu




More information about the Digitalmars-d mailing list