【史料】【K之批判】原始时代 Pascal 的弊病
pascal吧
全部回复
仅看楼主
level 1
http://www.lysator.liu.se/c/bwk-on-pascal.html
《为何 Pascal 不是我喜欢的编程语言》中 Kernighan 总结了如下问题:
1. Since the size of an array is part of its type, it is not possible to write general-purpose routines, that is, to deal with arrays of different sizes. In particular, string handling is very difficult.
1. 因为数组之大小是其类型的一部分,故不可能写通用的子程序,即处理不同大小的数组者。尤其是字符串处理非常困难。
2. The lack of static variables, initialization and a way to communicate non-hierarchically combine to destroy the ``locality'' of a program - variables require much more scope than they ought to.
2. 静态变量、初始化的缺乏和交流方式非层次性地组合在一起,将程序的“局部性”破坏——变量要求多于其应有的作用域。
3. The one-pass nature of the language forces procedures and functions to be presented in an unnatural order; the enforced separation of various declarations scatters program components that logically belong together.
3. 语言的单趟特性强制过程和函数以非自然的顺序出现;各种声明的强制分离将逻辑上共在的程序内容割碎。
4. The lack of separate compilation impedes the development of large programs and makes the use of libraries impossible.
4. 缺乏分离编译阻碍大型程序开发,并使得库的使用不可行。
5. The order of logical expression evaluation cannot be controlled, which leads to convoluted code and extraneous variables.
5. 逻辑表达式的顺序不可控,这导致回卷的代码和额外变量。
6. The 'case' statement is emasculated because there is no default clause.
6. case 语句被阉割了,因为没有默认子句。
7. The standard I/O is defective. There is no sensible provision for dealing with files or program arguments as part of the standard language, and no extension mechanism.
7. 标准 I/O 有缺陷。提供文件或程序参数作的处理作为语言标准的一部分没有意义,并且没有扩展机制。
8. The language lacks most of the tools needed for assembling large programs, most notably file inclusion.
8. 语言缺乏组建大型程序的大部分工具,最主要的是文件包含。
9. There is no escape.
9. 没有转义序列。
2017年03月17日 10点03分 1
level 1
注意:除了第二条,现在都已经完全解决了。
相比之下, C/C++ 在第四、第八条上还不如近代的 Pascal 。
2017年03月17日 10点03分 2
level 10
Pascal不只有这些弊端。
Pascal历史确实比较久远,但是它的功能并不少。可能在界面等方面它不如C/C++,但是Pascal也有其语言的特色。楼主也说了C/C++在某些方面上还不如Pascal。在语言方面,不能就妄加评判"这个语言好,那个语言差",究竟哪个语言好还是应该看个人的习惯。而且,多接触一些语言,取长补短不是也很好吗?
所以我感觉不应该就这样批判Pascal,楼主的"批判"观点我不敢苟同。
2017年03月17日 13点03分 3
这不是我的观点,是 K 的,而且都有四十多年历史了。现在看来 C 反而显得不思进取。
2017年03月18日 04点03分
1