El día 13 de diciembre de 2008 14:54, Shinji Ikari
On Saturday 13 December 2008 09:17:10 Carlos E. R. wrote:
El 2008-12-13 a las 01:37 -0200, Juan Erbes escribió:
El día 12 de diciembre de 2008 11:00, Carlos E. R.
No estoy diciendo que sea peor. C++ es mejor. Pero un programa hecho en C++, que usa las cosas especiales que añade, es más lento por narices. Y encima, como el compilador GCC de hace unos años no generaba código bien optimizado para C++, pues teníamos una rémora considerable, que afectaba al KDE. La gente de KDE estuvo dando la lata a la gente del GCC para que corrigieran ese problema, y estuvieron trabajando mucho en eso. Supongo que ya lo habrán conseguido.
Esto lo explicó Rafa en su dia.
Ahí tenemos el kernel, que está hecho en C, no C++. Cuando cuenta la velocidad y la optimización y el control, no se usa C++. Por muy bueno que sea, cada lenguaje tiene sus usos optimos y los que no o son. Como todo lo que hacemos las personas.
Vuelvo a citar el texto original, sin recortes: For the vast majority of problems out there, I state that C++ provides
Y yo vuelvo a cortarlo. Quien lo queira leer, lo tiene en los correos anteriores.
...
So, if you believe me, we have established that "C++ is not significantly worse than C". Let's have a look at what it is that makes C++ a better C:
Pues como ya he explicado, no le creo. Que sea mejor, si. Que ha establecido esos puntos anteriores, no. Los niego.
En los primeros años del desarrollo del kernel Linux, no había ningun compilador C++ de GNU, así que forzosamente debían hacerlo en C. Hoy en dia la situación ha cambiado en cuanto a compiladores para C++, pero por inercia, continuan con C a secas. No se si realmente los craneos del kernel Linux, se habran tomado la molestia de estudiar el C++, y hacer las evaluaciones correspondientes.
Dudo muchísimo que digas en serio que el señor Torvalds no conozca C++.
Por otro lado, con la cantidad de lineas de codigo que tiene el kernel linux, ponerse a reescribirlo, sería como desarrollar un kernel nuevo desde cero. Y eso solamente lo puede hacer alguien que conozca al dedillo los fuentes del kernel, al igual que la programación en C++, y le sobre mucho tiempo.
Podras ver, de acuerdo con las lineas anteriores, que el kernel Linux no está escrito en C, porque el ejecutable sea mas rapido que el escrito en C++, sino por otras razones completamente ajenas a eso.
Está escrito en C por muchas razones, incluyendo la velocidad.
Por otro lado, pasate por alto el hecho de que algunos programas (o kernel) hechos en C, si no estan bien depurados, tienden a tener problemas con el uso de memoria, ya que no limpian la memoria una vez que ha sido usada, cosa que rara vez sucede en C++, y que ademas el codigo escrito en C++, ademas de tener la tercera parte de la cantidad de lineas, se presta menos a los errores de tipeo.
¿Y porqué lo voy a pasar por alto? Ya he dicho que el C++ es mejor. Simplemnte niego que sea más rápido el C++. No lo es.
Tienes la manía de cerrarte en redondo con una idea y no querer comprender que las cosas no son blancas y negras: hay matices y multitud de motivaciones.
Sobre el enlace que pase: http://www.linuxquestions.org/questions/programming-9/c-or-pure-c-for-linux- kernel-module-linux-device-driver-development.-what-to-use-353924/
estoy.. intentando acabar con el post pero.... estoy mas perdido que en las clases de computación gráfica. Si es que pueden entender lo que describen allí vale. =P
De los links que posteaste, hay uno que apunta a: http://netlab.ru.is/exception/LinuxCXX.shtml C++ in the Linux Kernel We have implemented a complete kernel level run-time support for C++ in the Linux kernel. In particular our run-time support enables the full use of C++ exceptions in the Linux kernel, but notably also includes support for global constructors and destructors, and dynamic type checking. Our kernel level support is based on open source commodity components, specifically the GNU gcc/g++ compiler and its exception implementation, the C++ ABI version independent standard interface. Currently only the i386 architecture is supported. Furthermore the kernel patch has only been tested with gcc version 3.3.3, and (with the 0.0.3 release) 3.4.3 Release Notes for version 0.0.3 C++ runtime support for 2.6.6, version 0.0.3 (Last update 26 January 2005) C++ runtime support for 2.6.9, version 0.0.3 (Last update 26 January 2005) C++ runtime support for 2.6.10, version 0.0.3 (Last update 26 January 2005) Using the C++ runtime support for Linux Installing the C++ runtime support for Linux The code is installed by applying a patch to the Linux kernel and enables the full use of C++ using the GNU g++ compiler. Programmers that have used C++ in Linux kernel modules have primarily been using classes and virtual functions, but not global constructors. dynamic type checking and exceptions. Using even this small part of C++ requires each programmer to write some supporting routines. Using the rest of C++ includes porting the C++ ABI that accompanies GNU g++ to the Linux kernel, and to enable global constructors and destructors. The implementation of the C++ ABI is based on the implementation provided with the source of the GNU g++ compiler. We modified it to run in kernel space, and performed optimizations that reduces the cost of exceptions and dynamic cast considerably. Our paper contains thorough explanations of these optimizations. The cost of throwing an exception one level on a 990 MHz Intel Pentium is around 12-13 micro seconds in the plain GNU g++ implementation, which we reduced to 2.1 micro seconds by modifying the runtime library, including unwinding the stack in one phase, and caching information on exception paths. In contrast the cost of a trivial printk operation -- printk("Error\n") -- is 18 micro seconds. In addition, we modified the linux kernel module loader to handle C++ weak symbols correctly. GNU g++ associates with each class a type information object that encodes the type of the class as a mangled string and puts a pointer to this object in the virtual table for the class. GNU g++ uses weak symbols to reduce the dynamic type checking to a pointer comparison, thus avoiding the more expensive string comparison. Each time a class, containing virtual functions, is used in a source file, GNU g++ generates the virtual table, type information object and type name string as weak symbols and the user space linker ensures that there is only one copy of this object, which renders the simple pointer comparison sufficient. However, the kernel module loader, which in the 2.6 versions of the kernel is exclusively in kernel space, does not handle these weak symbols correctly and always relocates references to weak symbols to the weak definition within each object file that is being loaded. Therefore multiple type information objects may exist for the same class and pointer comparison becomes insufficient when doing dynamic type check across kernel modules. To avoid this overhead we have modified the kernel module loader to handle these weak symbols; the first time a weak symbol is encountered it is added to the symbol map, and on subsequent encounters the relocation is done to the first symbol. Paper: Exceptional Kernel: Using C++ exceptions in the Linux kernel Halldor Isak Gylfason, Gisli Hjalmtysson Submitted for publication October 2004 Abstract Full version