从我那里读到的:Why is Objective-C not very popular outside of the Apple community?
Objective-C is a superset of C (much more strictly than C++, in fact) so the issue of backward compatibility does not arise. Anything you can do in C you can do in Objective-C.
Being a superset is binary, like being pregnant. Obj-C is a superset of C, and C++ is not.
他们所说的超集是什么意思? Objective-C 以何种方式更接近//向后兼容 C? Objective-C 在哪些方面比 C++ 更接近 C 哲学?
Objective-C 编译器可以在不修改的情况下编译任何 C 程序(100% 兼容性)吗?
这更多是关于编程语言设计和兼容性的问题,而不是关于哪个更好的 war 。
最佳答案
我准备了一个简单的图表;它不是很漂亮,但希望能明白这一点:
- 红色:在 C、C++ 和 Objective-C 中有效的所有程序的集合(相对较小)
- 绿色:所有程序在 C 和 Objective-C 中有效,但在 C++ 中无效(甚至更小)的集合
- 灰色:在 Objective C 和 C++ 中有效但在 C 中无效的所有程序的集合(据我所知是空的)
- 蓝色:仅在 Objective C 中有效的所有程序集(相对较大)
- 黄色:仅在 C++ 中有效的所有程序的集合(最大)
有效 C 程序集(红色和绿色)是有效 Objective C 程序集(蓝色)的严格子集
关于c++ - "Objective-C is a superset of C more strictly than C++"到底是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19366134/