【发布时间】:2011-01-17 11:55:06
【问题描述】:
类似于:Why are RTOS only coded in C,但是:
除了关于 C++ 的众多神话之外,为什么它没有像 C/nesC (TinyOS) 那样用于 WSN?知道 C++ 可以用于Simulating Wireless Sensor Networks with OMNeT++ 很难不认为它也可以用于实时嵌入式系统,因为 C 是用来完成事件处理的。
我不想发起一场 C++ 比 C 更好的火焰大战,但有足够的证据表明,整个 C 比 C++ 更快、更通用是一个完全的神话。看看:
C vs. C++ 论文强调了以下几点:
- C++ is slower than C: Wrong! Many C programs are valid C++ programs as well - and such a C program should run at identical speed when translated with either the C and with the C++ compiler.
- C++ specific features give overhead: Wrong! The so-called overhead introduced by certain C++ specific features (such as virtual function calls or exceptions), is comparable to the overhead you yourself would introduce should you choose to go thru the pain it would be to implement a similar feature in C.
- C++ is object oriented: Wrong! The C++ language contains some language extentions over C, that make object oriented programming and generic programming more convenient. C++ does not force object oriented design anywhere - it merely allows for it if the programmer deems OO feasible. C allows for object oriented programming as well, C++ only makes it simpler and less error prone.
【问题讨论】:
-
我们之前已经在这里讨论过这个问题,但我懒得跑掉链接。部分答案:c 编译器更容易编写,并且几乎已经存在于您想要命名的任何芯片上; c 足以完成工作;并且有很多关于 c 的程序员。
-
足够好。我以前也遇到过同样的原因,但轻描淡写。
标签: c++ c networking wireless sensors