开发者

C - only scalar operations?

Reading on Wikipedia:

"The terms high-level and low-level are inherently relative. Some decades ago, the C language, and similar languages, was most often considered "high-level", as it supported concepts such as expression evaluation, parameterised recursive functions, and data types and structures, while assembly language was considered "low-level". Many programmers today might refer to C as low-level, as it lacks a large runtime-system (no garbage collection etc), basically supports only scalar operations, and provides direct memory addressing. It therefore readily blends with assembly language and the machine level of CPUs and microcontrollers."

开发者_运维百科

http://en.wikipedia.org/wiki/High_level_language

What does this mean exactly? What operations do other programming languages provide which C does not?


Given the context and topic of the article, what the article is referring to is the term "scalar" as it is defined in C language itself. In C language arithmetic types and pointer types together are called scalar types (see 6.2.5/21). In everyday language we often see these types referred to as basic types or built-in types (while the proper formal term is, again, scalar). The point is that scalar types are intended to be the types that are immediately (or almost immediately) supported by hardware. Most non-conceptual operations in C operate on scalar types and scalar types only.

If you take a look at the history of C language, you'll see that early versions of C were so restrictively scalar, that you couldn't even assign one struct object to another struct object (or pass it to a function/return from a function by value). The ability do the struct copying in the core language was added to C later. And to this day it remains essentially the only non-scalar operation in the entire core language.

C++, on the other hand, as well as other higher-level languages, supports operations on user-defined types, which are by definition not scalar, or on other types that have no immediate support from hardware.

P.S. No, the point the article is trying to make has nothing to do with vector operations, as opposed to scalar operations. Support for vector operations is, of course, completely orthogonal to the level of the language. You can have vector operations in low-level languages as well as in high-level languages. The term scalar is used in a sense that I described above.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜