gpt4 book ai didi

C WikiBooks - C 是一种小型 "what you see is all you get"语言吗?

转载 作者:太空狗 更新时间:2023-10-29 15:11:28 25 4
gpt4 key购买 nike

我无法理解 WikiBooks 中的以下句子之一:

为什么是 C,而不是汇编语言?

" C is a compiled language, which creates fast and efficient executable files. It is also a small "what you see is all you get" language: a C statement corresponds to at most a handful of assembly statements, everything else is provided by library functions. "


网站链接: C Programming/Why learn C? - Wikibooks, open books for an open world

注意 :我是一个完全的初学者,我已经开始学习 C 了。所以,我需要准确解释上面这句话的意思。

最佳答案

汇编是针对单个处理器家族的语言,直接编译成处理器运行的机器码。如果一个程序在汇编中,则需要为不同的处理器系列重写整个代码。手机通常使用 ARM 处理器,而台式计算机则使用 32 位或 64 位 x86 兼容处理器。其中每 3 个都可能需要一个完全独立编写的程序,甚至可能不仅限于此。

相比之下,标准 C 是一种可移植的语言 - 如果您编写所谓的严格符合标准的程序。 C11 4p5 :

A strictly conforming program shall use only those features of the language and library specified in this International Standard. (3) It shall not produce output dependent on any unspecified, undefined, or implementation-defined behavior, and shall not exceed any minimum implementation limit.

footnote 5注意到:

Strictly conforming programs are intended to be maximally portable among conforming implementations. Conforming programs may depend upon nonportable features of a conforming implementation

不像汇编程序,其细节因处理器而异,可以用 C 编写程序,然后移植它们到各种平台,而无需对源代码进行任何更改,但这些程序仍然是编译成汇编语言,并且在使用现代高质量优化编译器时,性能可能 - 而且通常会 - 超过手写汇编。

此外,C 标准库是任何符合规范的托管实现都需要提供的,它提供了一种可移植的方式来管理文件、动态内存、输入和输出,所有这些不仅是处理器,而且使用汇编程序时特定于操作系统。

但是,C 仍然非常接近汇编,甚至被一些人称为“高级汇编语言”。

关于C WikiBooks - C 是一种小型 "what you see is all you get"语言吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44327724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com