找回密码
 立即注册
搜索
热搜: 生活 中国

C语言是当代最优秀的程序设计语言

[复制链接]
admin 发表于 2013-10-3 21:36:32 | 显示全部楼层 |阅读模式
C语言是当代最优秀的程序设计语言

C语言是当代最优秀的程序设计语言

早期的C 语言主要是用于UNIX系统。由于C语言的强大功能和各方面的优点逐渐为人们认识,到了八十年代,C开始进入其它操作系统,并很快在各类大、中、小和微型计算机上得到了广泛的使用,成为当代最优秀的程序设计语言之一。

下面,介绍一下C语言的优秀之处:

1. 语言简洁,使用方便灵活

C语言是现有程序设计语言中规模最小的语言之一,而小的语言体系往往能设计出较好的程序。C语言的关键字很少,ANSI C标准一共只有32个关键字,9种控制语句,压缩了一切不必要的成份。C语言的书写形式比较自由,表达方法简洁,使用一些简单的方法就可以构造出相当复杂的数据类型和程序结构。

2. 可移植性好

用过汇编语言的读者都知道,即使是功能完全相同的一种程序,对于不同的单片机,必须采用不同的汇编语言来编写。这是因为汇编语言完全依赖于单片机硬件。而现代社会中新器件的更新换代速度非常快,也许我们每年都要跟新的单片机打交道。如果每接触一种新的单片机就要学习一次新的汇编语言,那么也许我们将一事无成,因为每学一种新的汇编语言,少则几月,多则上年,那么我们还有多少时间真正用于产品开发呢?

C语言是通过编译来得到可执行代码的,统计资料表明,不同机器上的C语言编译程序80%的代码是公共的,C语言的编译程序便于移植,从而使在一种单片机上使用的C语言程序,可以不加修改或稍加修改即可方便地移植到另一种结构类型的单片机上去。这大大增强了我们使用各种单片机进行产品开发的能力。

3. 表达能力强

C语言具有丰富的数据结构类型,可以根据需要采用整型、实型、字符型、数组类型、指针类型、结构类型、联合类型、枚举类型等多种数据类型来实现各种复杂数据结构的运算。C语言还具有多种运算符,灵活使用各种运算符可以实现其他高级语言难以实现的运算。

4. 表达方式灵活

利用C语言提供的多种运算符,可以组成各种表达式,还可采用多种方法来获得表达式的值,从而使用户在程序设计中具有更大的灵活性。C语言的语法规则不太严格,程序设计的自由度比较大,程序的书写格式自由灵活。程序主要用小写字母来编写,而小写字母是比较容易阅读的,这些充分体现了C语言灵活、方便和实用的特点。

5. 可进行结构化程序设计

C语言是以函数作为程序设计的基本单位的,C语言程序中的函数相当于汇编语言中的子程序。C语言对于输入和输出的处理也是通过函数调用来实现的。各种C语言编译器都会提供一个函数库,其中包含有许多标准函数,如各种数学函数、标准输入输出函数等。此外C语言还具有自定义函数的功能,用户可以根据自己的需要编制满足某种特殊需要的自定义函数。实际上C语言程序就是由许多个函数组成的,一个函数即相当于一个程序模块,因此C语言可以很容易地进行结构化程序设计。

6. 可以直接操作计算机硬件

C语言具有直接访问单片机物理地址的能力,可以直接访问片内或片外存储器,还可以进行各种位操作。

7. 生成的目标代码质量高

众所周知,汇编语言程序目标代码的效率是最高的,这就是为什么汇编语言仍是编写计算机系统软件的重要工具的原因。但是统计表明,对于同一个问题,用C语言编写的程序生成代码的效率仅比用汇编语言编写的程序低10%~20%。

尽管C语言具有很多的优点,但和其他任何一种程序设计语言一样也有其自身的缺点,如不能自动检查数组的边界,各种运算符的优先级别太多,某些运算符具有多种用途等。但总的来说,C语言的优点远远超过了它的缺点。经验表明,程序设计人员一旦学会使用C语言之后,就会对它爱不释手,尤其是单片机应用系统的程序设计人员更是如此。

C language is the best of contemporary programming languages

Early C language is mainly used for UNIX systems. Since the C language, powerful features and advantages of various aspects of people gradually realize, in the 1980s, C began to enter other operating systems, and soon in all kinds of large, medium, small and micro-computers have been widely used as The most outstanding contemporary programming languages.

Now, tell us about the C language excellent place:

1 language is simple, easy to use and flexible

C language is a programming language in the existing language of one of the smallest, and small language system can often design a better program. C language keywords rarely, ANSI C standard a total of only 32 keywords, nine kinds of control statements, compress all unnecessary ingredients. C language written form freer to express method is simple, using a few simple ways you can construct a fairly complex data types and program structure.

2 portability

Used assembly language readers know, even if a program is functionally identical for different microcontroller, must adopt a different assembly language. This is because the assembly language is totally dependent on microcontroller hardware. The new devices in modern society replacement very fast, maybe we every year to deal with the new chip. If every contact with a new chip assembly would have to learn a new language, then maybe we will achieve nothing, because every school a new assembly language, ranging from a few months, as many as last year, how much time we really for product development do?

C language is to get through the compiler executable code, statistics show that different machines of the C language compiler 80% of the code is public, C language compiler portability, so that in use on a single-chip C language program, you can not add or modify slightly modified to be easily ported to another structure type microcontroller up. This greatly enhances our product development using various microcontroller capabilities.

3. Presentation skills

C language has a rich data structure type that can be used as needed integer, real, character, array types, pointer types, structured types, union types, enumerated types, and other data types to achieve a variety of complex data structures operation. C language also has a variety of operators, operator flexibility can be achieved using a variety of other high-level languages ​​is difficult to achieve operational.

4 flexible expression

The use of C language provides a variety of operators, can be composed of a variety of expressions, but also uses a variety of methods to get the value of an expression, allowing the user to program design for greater flexibility. C language syntax rules are less stringent, relatively large degree of freedom in the design of the program, the program's writing format freedom and flexibility. Program is mainly written in lowercase letters, and lowercase letters are easier to read, these fully reflects the C language, flexible, convenient and practical features.

5 can be structured programming

C programming language is a function as the basic unit, C language programming in assembly language function is equivalent to a subroutine. C language, the input and output processing is also achieved by the function call. Various C language compiler will provide a library, which contains many of the standard functions, such as various mathematical functions, such as the standard input and output functions. Besides the C language also has a self-defined function, users can according to their own needs to meet certain special needs preparing custom function. In fact, from the C language program is composed of a number of functions, a function which is equivalent to a program module, the C language can be easily structured programming.

6 can operate the computer hardware

Microcontroller C language has direct access to the physical address of the ability to directly access the on-chip or off-chip memory, can also be a variety of bit operations.

7 high quality of the generated object code

As we all know, assembly language programming object code efficiency is the highest, which is why writing assembly language is still an important tool for computer system software causes. But statistics show that, for the same problem, using C language program to generate efficient code than just a program written in assembly language by 10% to 20%.

Although the C language has many advantages, but, and any other kind of programming languages ​​also has its own disadvantages, such as not automatically check array bounds, a variety of operator precedence too much, some operators have a variety of uses and so on. But in general, C language, the advantages far outweigh the disadvantages. Experience has shown that programmers using C language once you learn, the will love it, especially the SCM application system programmers even more so.

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|生活导航|生活导航 ( 新ICP备12003026-1号 )

GMT+8, 2024-5-10 02:17 , Processed in 0.088125 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表