C++用于无线传感器网络

发布于 2024-08-21 07:49:37 字数 1674 浏览 12 评论 0原文

类似于:为什么 RTOS 只用 C 编码 ,但是:

除了关于 C++ 的众多神话之外,为什么它不像 C/nesC 那样被广泛使用 (TinyOS< /a>) 无线传感器网络?了解 C++ 可用于使用 OMNeT++ 模拟无线传感器网络 很难不认为它也可以用在实时嵌入式系统中,就像C语言一样完成事件处理。

我不想引发一场 C++ 比 C 更好的激烈战争,但足够的证据表明整个 C 比 C++ 更快、更通用完全是一个神话。请看一下:

C 与 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

Similar to: Why are RTOS only coded in C, but:

Besides the numerous myths about C++, why is it not used as much as C/nesC (TinyOS) for WSN? Knowing C++ can be used for Simulating Wireless Sensor Networks with OMNeT++ it is hard not to think that it can also be used in real-time embedded systems as C is to accomplish event handling.

I do NOT want to start a C++ is better than C flame war, but enough evidence suggests that the whole C is faster and more versatile than C++ is a total myth. Take a look at:

C vs. C++ paper where the following points were highlighted:

- 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.

Why are you still using C

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

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

发布评论

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

评论(1

梦在深巷 2024-08-28 07:49:37

我相信以下问题的答案适用于此。

有吗为什么使用C而不是C++进行嵌入式开发?

I believe the answers to the following question apply here.

Is there any reason to use C instead of C++ for embedded development?

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