C的主要缺陷

发布于 2024-10-28 02:32:25 字数 57 浏览 2 评论 0原文

C语言的主要缺陷是什么?面试时应该如何回答这个问题?我的意思是,与较新的语言相比,C 现在缺少什么?

What are the major defects of the C Language? How should one answer this question in an interview? I mean what does C Lack now compared to newer languages?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

回心转意 2024-11-04 02:32:25

C 可能是有史以来最重要的单一语言。

C 确实实现了所有近期目标,甚至更多。它实际上没有“缺陷”,本身,而是选择,这将其定义为理想的系统实现语言和可接受但不完美的应用程序语言。

当 C 在 20 世纪 70 年代初出现时,它正在与 Fortran、Basic、Cobol,尤其是汇编竞争。正如他们所说,它吃掉了它们各自的午餐,并将它们作为实现语言埋葬了。仅 Fortran 就幸存了下来,尽管很少有程序可以用 Fortran 表达,但不能用 C 表达。

直到今天,C 偶尔还是 Tiobe 索引,在第一名和第二名之间进行权衡,仅次于更专业且非常流行的 Java。

当然,对于动态和符号应用程序,C 可能无法与 Ruby、Lisp 或 Python 相比,但它们当时还不存在,对于实现也没有什么用处。这三个通常都是用 C 实现的,有点“笑到最后”。 Ruby 内部有 200,000 行 C 代码。

所以,是的,它并没有实现所有可能的编程范例。并回答您的具体问题:

  1. C 不是反射
  2. C 没有垃圾收集
  3. C 不直接实现闭包
  4. 静态类型: C 是最终的“编译时”语言处理器。
  5. C 不是直接面向对象的,C 中的类似对象的包往往很笨重,没有人使用它们。
  6. C 不是类型安全的。 (但可以以类型安全的方式使用。)
  7. C 不是内存安全的。 (没有保证,但有时可以使用最安全的方式。)
  8. 操作员优先级太多。
  9. 某些运算符优先级似乎没有最有用的优先级。
  10. C 是纯粹命令式的。

从总体上看,C 是一种结构化的高级语言,可以构建任何东西,但它不具有反射和面向对象的属性,而这些属性往往允许更大、更复杂的程序和抽象。编写 C 的天才可以做任何事情,但我们大多数人应该在问题域允许的情况下使用更高级的语言。

C is probably the most important single language ever invented.

C really accomplished all of its immediate goals and then far more. It really doesn't have "defects", per se, but rather choices, which defined it as an ideal system implementation language and as an acceptable although not perfect application language.

When C burst on the scene in the early 1970's, it was competing with Fortran, Basic, Cobol, and, particularly, assembly. It ate all their respective lunches, as they say, and buried them as implementation languages. Fortran alone has survived although there are few programs that can be expressed in Fortran but not C.

To this day C is occasionally #1 on the Tiobe index, trading off first for second only to the much more specialized and also-insanely-popular Java.

Sure, C may not compare to Ruby, Lisp, or Python for dynamic and symbolic applications, but they didn't exist back then and aren't useful for implementations. And all three are typically implemented in C, in a sort of "last laugh". Ruby is 200,000 lines of C, internally.

So yes, it didn't implement every possible programming paradigm. And to answer your specific question:

  1. C is not reflective
  2. C does not have garbage collection
  3. C does not directly implement closures
  4. Static typing: C is the ultimate "compile-time" language processor.
  5. C is not directly object-oriented, and object-like packages in C tend to be clunky and no one uses them.
  6. C is not type-safe. (But can be used in a type-safe style.)
  7. C is not memory-safe. (No guarantees, but sometimes can be used a mostly-safe way.)
  8. There are too many operator priorities.
  9. Some of the operator priorities don't seem to have the most useful precedence.
  10. C is purely imperative.

In the big picture, C is a structured high-level language in which anything can be built, but which doesn't have reflective and object-oriented properties that tend to allow larger and more sophisticated programs and abstractions. A genius writing C can do anything but most of us should use higher level languages when our problem domain allows it.

猫烠⑼条掵仅有一顆心 2024-11-04 02:32:25

我不认为C有缺陷。它是一种功能强大的语言,已被用来编写大量成功的软件。

与较新的技术相比,C 需要更多的工作并且需要更多的技能。此外,较新的语言具有强大的新功能。由于这些原因,C 不再被使用。但这很难说它有缺陷。

I don't consider C defective. It's a powerful language that has been used to write tons of successful software.

Compared to newer technologies, C requires more work and requires more skill. Also, newer languages have powerful new features. For reasons like these, C isn't used much any more. But that hardly makes it defective.

傾旎 2024-11-04 02:32:25

不要误会我的意思,我喜欢 C,但没有命名空间确实很痛苦。查看任何大量使用 C 库的代码,并尝试以不同的方式告诉我。

Don't get me wrong, I love C, but not having namespaces is a real pain. Look at any code that makes heavy use of a C library and try and tell me differently.

满栀 2024-11-04 02:32:25

呃..不确定你所说的缺陷是什么意思,但它的核心绝对不是面向对象编程,并且还有更多的工作来控制资源。

uhh..not sure what you mean by defective, but at the core it's definitely not focused on OO programming and there is more work to keeping resources under control.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文