C的主要缺陷
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
C 可能是有史以来最重要的单一语言。
C 确实实现了所有近期目标,甚至更多。它实际上没有“缺陷”,本身,而是选择,这将其定义为理想的系统实现语言和可接受但不完美的应用程序语言。
当 C 在 20 世纪 70 年代初出现时,它正在与 Fortran、Basic、Cobol,尤其是汇编竞争。正如他们所说,它吃掉了它们各自的午餐,并将它们作为实现语言埋葬了。仅 Fortran 就幸存了下来,尽管很少有程序可以用 Fortran 表达,但不能用 C 表达。
直到今天,C 偶尔还是 Tiobe 索引,在第一名和第二名之间进行权衡,仅次于更专业且非常流行的 Java。
当然,对于动态和符号应用程序,C 可能无法与 Ruby、Lisp 或 Python 相比,但它们当时还不存在,对于实现也没有什么用处。这三个通常都是用 C 实现的,有点“笑到最后”。 Ruby 内部有 200,000 行 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:
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.
我不认为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.
不要误会我的意思,我喜欢 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.
呃..不确定你所说的缺陷是什么意思,但它的核心绝对不是面向对象编程,并且还有更多的工作来控制资源。
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.