2010-02-16 48 views
2

類似:Why are RTOS only coded in C,但: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. 

Why are you still using C

+5

我們以前在這裏討論這一點,但我懶得跑下來的鏈接。部分答案:C編譯器更容易編寫和已經存在於幾乎任何你願意的名字芯片; c足以完成工作;有很多C程序員。 – dmckee

+0

夠好。我以前遇到過這個相同的原因,但是很輕鬆。 –

回答