我们自己的'深C秘密' [英] Our OWN 'Deep C Secrets'

查看:68
本文介绍了我们自己的'深C秘密'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你知道,这本书的所有这一切让我在亚马逊上查了一下。我从来没有读过这本书......但是我从亚马逊的合法可用的目录,摘录和索引中可以看到,它

看起来更像是教我新手C这本书不是发现深奥的价值,而是B $ MYSTERIES C !!有点暧昧。


我有个更好的主意!让我们来讨论我们

拥有的'Deep C Secrets'!我会开始的。


测试 - 如果你没有经过测试证明它是正确的,它几乎可以证明肯定是错误的b $ b。在C中拧一些东西是非常容易的,导致缓冲区溢出和未定义的行为。

它已经达到了我不会的地步在编写测试之前,我很乐意调用编码

。 C可以咬太多的地方

你。


我在其他编程语言中不是这种偏执...你知道,

那些花费1/10的时间来编写,并且运行速度慢100倍,比如VB。

因为你没有对代码进行细粒度的控制,还有更少的地方搞砸了一些根本性的东西。但是你付出了代价,因为你不得不依赖于其他程序员的错误代码,因此失去了控制,速度损失以及不太稳定的开发环境。 。

如果它是你的错误代码,你至少有一个战斗机会

弄清楚它的错误并修复它。


呃,看那里。智慧之珠!抓住它并开始你的OWN书。

:-P

You know, all this furor over this book caused me to go look it up on
Amazon. I''ve never read this book... but from what I can see from the
legally available table of contents, excerpt, and index at Amazon, it
looks more like a "Teach me newbie C" book than a "UNCOVER DEEP
MYSTERIES OF C!!" sort of affair.

I''ve got a better idea! Let''s discuss some ''Deep C Secrets'' of our
own! I''ll start.

Testing - If you haven''t tested to prove it right, it can almost
certainly be proven to be WRONG. It''s terribly easy to screw
something up in C, causing buffer overruns and undefined behavior.
It''s gotten to the point where I don''t feel comfortable calling coding
done until the tests are written. There''s too many places C can bite
you.

I wasn''t this paranoid in other programming languages... you know, the
ones that take 1/10 the time to write, and run 100x slower, like VB.
Because you didn''t have fine-grained control over the code, there were
fewer places to screw up something fundamental. But you paid for it in
loss of control, loss of speed, and a less stable development
environment, because you had to rely on OTHER programmer''s buggy code.
If it''s YOUR buggy code, you at least have a fighting chance of
figuring out what''s wrong with it and fixing it.

Uh, look there. A pearl of wisdom! Grab it and start your OWN book.
:-P

推荐答案

Kamilche写道:
Kamilche wrote:
你知道,这本书的这一切都让我在亚马逊上查了一下。我从来没有读过这本书......但是从亚马逊合法可用的目录,摘录和索引中我可以看到,它看起来更像是一个教我新手 C"本书不是发现深奥的神秘面纱。事情。

我有一个更好的主意!让我们来讨论一下我们自己的'Deep C Secrets'!我会开始的。

测试 - 如果你没有经过测试证明它是正确的,它几乎肯定会被证明是错误的。用C语言搞砸某些东西非常容易,导致缓冲区溢出和未定义的行为。
You know, all this furor over this book caused me to go look it up on
Amazon. I''ve never read this book... but from what I can see from the
legally available table of contents, excerpt, and index at Amazon, it
looks more like a "Teach me newbie C" book than a "UNCOVER DEEP
MYSTERIES OF C!!" sort of affair.

I''ve got a better idea! Let''s discuss some ''Deep C Secrets'' of our
own! I''ll start.

Testing - If you haven''t tested to prove it right, it can almost
certainly be proven to be WRONG. It''s terribly easy to screw
something up in C, causing buffer overruns and undefined behavior.




除了你几乎*永远不会*证明什么是正确的通过测试。那个

是一个非常危险的思维模式,必然会让你早点搞砸,或者稍后再支付
。证明程序正确的唯一可靠方法是写一个

数学证明。测试仅在输入的大小为b
有限且可以全部测试时才有效。 (但测试很好,因为他们可以用一段代码来证明某些东西是错误的。)

-

Daniel Sj? blom

删除_NOSPAM通过邮件回复



Except you can almost *never* prove anything right by testing it. That
is a very dangerous mind set that is bound to screw you over sooner or
later. The only sure way to prove a program correct is to write a
mathematical proof. Testing only works if the size of the input is
bounded and it can all be tested. (But tests are good because they can
prove something is *wrong* with a piece of code.)
--
Daniel Sj?blom
Remove _NOSPAM to reply by mail


Daniel Sj?blom< ds ****** @ mbnet.fi_NOSPAM>写道:
Daniel Sj?blom <ds******@mbnet.fi_NOSPAM> writes:
除了你几乎*从不*通过测试证明任何事情。那个
是一个非常危险的思维模式,必然会让你早日或以后再搞砸。证明程序正确的唯一可靠方法是编写一个
数学证明。


但是,人类创建的数学证明可能包含逻辑上的b
谬误,因此您还必须证明证明是正确的。而且,由于证明证据可以再次包含逻辑谬误,因此您还可以使用

来证明它是正确的,等等无限期。

只有在输入的大小有限且可以全部测试时,测试才有效。 (但测试很好,因为他们可以用一段代码来证明某些东西是错误的。)
Except you can almost *never* prove anything right by testing it. That
is a very dangerous mind set that is bound to screw you over sooner or
later. The only sure way to prove a program correct is to write a
mathematical proof.
However, a mathematical proof created by a human can contain logical
fallacies, so you also have to prove the proof correct. And as the
proof of the proof can again contain logical fallacies, you also have
to prove it correct, and so on ad infinitum.
Testing only works if the size of the input is bounded and it can all
be tested. (But tests are good because they can prove something is
*wrong* with a piece of code.)




给出1000万行之间的选择代码程序来了

带有正确性的数学证明,但尚未经过测试,并且

a彻底测试了1000万行代码程序尚未完成

证明是正确的,我更信任后者。


正如斯坦福数学家Donald E. Knuth曾经说过的那样[1]:谨防

上面代码中的错误;我只证明它是正确的,没有尝试过。 :)


Martin

[1] http://www-cs-faculty.stanford.edu/~knuth/faq.html


- -

, - 。 Martin Dickopp,德国德累斯顿,=, - _-。 =。

/, - ) http://www.zero -based.org/ ((_ /)oo(\_))

\` - ''` - ''(。)` - ''

` - 。 Debian,GNU操作系统的一种变体。 \ _ /



Given the choice between a 10 million lines of code program which comes
with a mathematical proof of correctness, but has not been tested, and
a thoroughly tested 10 million lines of code program which has not been
proven correct, I''d trust the latter more.

As Stanford mathematician Donald E. Knuth once put it [1]: "Beware of
bugs in the above code; I have only proved it correct, not tried it." :)

Martin
[1] http://www-cs-faculty.stanford.edu/~knuth/faq.html

--
,--. Martin Dickopp, Dresden, Germany ,= ,-_-. =.
/ ,- ) http://www.zero-based.org/ ((_/)o o(\_))
\ `-'' `-''(. .)`-''
`-. Debian, a variant of the GNU operating system. \_/


Daniel Sj?blom写道:
Daniel Sj?blom wrote:
Kamilche写道:
Kamilche wrote:



.. .. snip ...


.... snip ...


测试 - 如果你没有经过测试证明它是正确的,它几乎可以肯定被证明错了。用C语言搞砸某些内容非常容易,导致缓冲区溢出和未定义的行为。

Testing - If you haven''t tested to prove it right, it can almost
certainly be proven to be WRONG. It''s terribly easy to screw
something up in C, causing buffer overruns and undefined behavior.



除了你几乎*从不*通过测试证明任何事情。
这是一个非常危险的思维模式,迟早会把你搞砸。证明程序正确的唯一可靠方法是编写数学证明。测试仅在输入的大小有限且可以全部测试时才有效。 (但是测试很好,因为他们可以通过一段代码来证明某些内容是错误的。)



Except you can almost *never* prove anything right by testing it.
That is a very dangerous mind set that is bound to screw you over
sooner or later. The only sure way to prove a program correct is
to write a mathematical proof. Testing only works if the size of
the input is bounded and it can all be tested. (But tests are
good because they can prove something is *wrong* with a piece of
code.)




循环不变量技术可以证明一些关于

各种惯例的断言。他们还可以帮助记录所需的

前提条件。不幸的是,几乎没有人烦恼。

证明了这些结果后,它们可以用于更大的

区域,只要你保持整个系统的整洁和干净

结构化。


-

fix(vb。):1。纸张覆盖,模糊,隐藏在公众视野之外; 2.

以一种产生意想不到的后果的方式来解决,比原来的问题更糟糕。用法:Windows ME

修复了Windows 98 SE的许多缺点。 - 和记



The technique of loop invariants can prove some assertions about
various routines. They can also help to document the
preconditions required. Unfortunately virtually nobody bothers.
Having proved those results, they can then be used in larger
areas, provided you keep the overall system well and cleanly
structured.

--
fix (vb.): 1. to paper over, obscure, hide from public view; 2.
to work around, in a way that produces unintended consequences
that are worse than the original problem. Usage: "Windows ME
fixes many of the shortcomings of Windows 98 SE". - Hutchison


这篇关于我们自己的'深C秘密'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆