[opensuse-es] [OT] C++ en el kernel Linux (era Quitar la sombra del texto en los iconos del escritorio)
El día 13 de diciembre de 2008 14:54, Shinji Ikari escribió:
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
Del los link que posteaste, dentro de la pagina 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
____________________________________________________________________
Me faltó para cerrar el tema, citar laopinión de Linus Torvalds al respecto:
http://thread.gmane.org/gmane.comp.version-control.git/57643/focus=57918
From: Linus Torvalds
When I first looked at Git source code two things struck me as odd: 1. Pure C as opposed to C++. No idea why. Please don't talk about portability, it's BS.
*YOU* are full of bullshit. C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C. In other words: the choice of C is the only sane choice. I know Miles Bader jokingly said "to piss you off", but it's actually true. I've come to the conclusion that any programmer that would prefer the project to be in C++ over C is likely a programmer that I really *would* prefer to piss off, so that he doesn't come and screw up any project I'm involved with. C++ leads to really really bad design choices. You invariably start using the "nice" library features of the language like STL and Boost and other total and utter crap, that may "help" you program, but causes: - infinite amounts of pain when they don't work (and anybody who tells me that STL and especially Boost are stable and portable is just so full of BS that it's not even funny) - inefficient abstracted programming models where two years down the road you notice that some abstraction wasn't very efficient, but now all your code depends on all the nice object models around it, and you cannot fix it without rewriting your app. In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C. And limiting your project to C means that people don't screw that up, and also means that you get a lot of programmers that do actually understand low-level issues and don't screw things up with any idiotic "object model" crap. So I'm sorry, but for something like git, where efficiency was a primary objective, the "advantages" of C++ is just a huge mistake. The fact that we also piss off people who cannot see that is just a big additional advantage. If you want a VCS that is written in C++, go play with Monotone. Really. They use a "real database". They use "nice object-oriented libraries". They use "nice C++ abstractions". And quite frankly, as a result of all these design decisions that sound so appealing to some CS people, the end result is a horrible and unmaintainable mess. But I'm sure you'd like it more than git. Linus __________________________________________________________ "CADA REGLA TIENE SU EXCEPCION" Por algo el articulo de arriba, habla de "excepciones". Salu2
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 El 2008-12-16 a las 20:33 -0200, Juan Erbes escribió:
Del los link que posteaste, dentro de la pagina hay uno que apunta a: http://netlab.ru.is/exception/LinuxCXX.shtml
C++ in the Linux Kernel
¿Porqué envías el documento entero en PDF a la lista, y dos veces? Ya lo podremos obtener nosotros; pon el enlace, no el documento. Pesa mucho.
Me faltó para cerrar el tema, citar laopinión de Linus Torvalds al respecto:
http://thread.gmane.org/gmane.comp.version-control.git/57643/focus=57918
From: Linus Torvalds
Subject: Re: [RFC] Convert builin-mailinfo.c to use The Better String Library. Newsgroups: gmane.comp.version-control.git Date: 2007-09-06 17:50:28 GMT (1 year, 14 weeks, 3 days, 22 hours and 27 minutes ago) On Wed, 5 Sep 2007, Dmitry Kakurin wrote:
When I first looked at Git source code two things struck me as odd: 1. Pure C as opposed to C++. No idea why. Please don't talk about portability, it's BS.
*YOU* are full of bullshit.
C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C.
¡JO***! No se muerde la lengua el señor Torvalds, no. Para los que no entiendan el inglés, traduzco ese párrafo inicial: *Usted* está lleno de mierda de vaca. C++ es un lenguaje horrible. Lo hace más horrible el hecho de que un montón de programadores sub-estándar lo usan, hasta el punto donde es mucho más fácil generar total y completa basura con ello. Muy francamente, incluso si la elección de C no fuera más que para *nada* excepto mantener fuera los programadores de C++, eso en si mismo sería una enorme razón para usar C. No se muerde la lengua, no. Si lo digo yo, me matan. Pero el es quien es y puede decirlo. Caray. Y sin embargo, prefiere el kde al gnome. Muy curioso. Y no sigo traduciendo, pero no lo suaviza mucho, no. Explica los porqués. Y que el C produce código más eficiente que el C++. Si lo dice él, es cierto. My case rests. >:-)
Linus
__________________________________________________________
"CADA REGLA TIENE SU EXCEPCION" Por algo el articulo de arriba, habla de "excepciones".
No creo que ni por las excepciones convenzas a Mr. Torvalds de las bondades del C++ :-P - -- Saludos Carlos E.R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAklIS6MACgkQtTMYHG2NR9V/kgCdH2U0nb/iGzaT+LCASR4ErFTW VVwAn2dYO5W0bNbiCf2Rsx1Z2PDpuR6Q =Y8HI -----END PGP SIGNATURE-----
Carlos E. R. escribió:
Y sin embargo, prefiere el kde al gnome. Muy curioso.
No tiene nada de curioso, KDE no es un kernel ni tampoco un sistema de control de versiones como GIT. -- "We have art in order not to die of the truth" - Friedrich Nietzsche Cristian Rodríguez R. Platform/OpenSUSE - Core Services SUSE LINUX Products GmbH Research & Development http://www.opensuse.org/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 El 2008-12-17 a las 02:00 -0300, Cristian Rodríguez escribió:
Carlos E. R. escribió:
Y sin embargo, prefiere el kde al gnome. Muy curioso.
No tiene nada de curioso, KDE no es un kernel ni tampoco un sistema de control de versiones como GIT.
¡Claro que es curioso! Podrá ser justificable, tendrá sus motivaciones, pero sigue siendo curioso. Si piensa que los programadores de C++ son malos por el simple hecho de usar C++, pos entonces son malos y punto :-P Yo hasta ahora pensaba C para el kernel, C++ para las aplicaciones. Pero resulta que el GIT es también una aplicación... ¿porqué no en C++? Pues no, piensa que es malo. Ergo... es malo para todas las aplicaciones. Incluso pa'l kde :-p Yo, mientras no se entere que sigo programando en Pascal, estoy a salvo :-P - -- Saludos Carlos E.R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAklI6KwACgkQtTMYHG2NR9VSsgCfZDdwI2uWlTTdcywMASuWUW59 uiIAn3TSAoxim7v8UwSEiJdMpE34e+5g =0XWE -----END PGP SIGNATURE-----
Hola :) El Wednesday 17 December 2008, Carlos E. R. escribió:
El 2008-12-17 a las 02:00 -0300, Cristian Rodríguez escribió:
Carlos E. R. escribió:
Y sin embargo, prefiere el kde al gnome. Muy curioso.
No tiene nada de curioso, KDE no es un kernel ni tampoco un sistema de control de versiones como GIT.
¡Claro que es curioso! Podrá ser justificable, tendrá sus motivaciones, pero sigue siendo curioso.
Si piensa que los programadores de C++ son malos por el simple hecho de usar C++, pos entonces son malos y punto :-P
Yo hasta ahora pensaba C para el kernel, C++ para las aplicaciones. Pero resulta que el GIT es también una aplicación... ¿porqué no en C++? Pues no, piensa que es malo. Ergo... es malo para todas las aplicaciones. Incluso pa'l kde :-p
Yo, mientras no se entere que sigo programando en Pascal, estoy a salvo :-P
Menos mal que no programo 0;) Fuera de si es mejor uno que otro (no puedo opinar porque no programo), hay que tener en cuenta la personalidad del Sr. Torvalds: es un poco "directo" y tajante (IMHO, a veces un poco maleducado). Por lo que habría que andarse al loro con lo que dice, igual que cuando habla el Sr. Stallman. Hablando con gente que programa, me han dicho de todo (opiniones hay tantas como personas ... y más). Algunos me han dicho que C para no orientación a objetos y C++ para orientación a objetos, claro que luego tienes GNOME con C y orientado a objetos. También es verdad que ni GNOME ni KDE son "puros" ya que no sólo hay c o C++ sino que hay python y más. Posiblemnete Rodrigo (Moya) pueda darnos su opinión. IMHO, ocmo siempre, no creo que haya una herramienta perfecta y única, depende de lo que quieres hacer, cómo lo quieres hacer, los conocimientos que tienes, el tiempo del que dispones, la pasta que te van a pagar, ... Rafa -- "We cannot treat computers as Humans. Computers need love." rgriman@skype.com -- Para dar de baja la suscripción, mande un mensaje a: opensuse-es+unsubscribe@opensuse.org Para obtener el resto de direcciones-comando, mande un mensaje a: opensuse-es+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 El 2008-12-17 a las 13:18 +0100, Rafa Grimán escribió:
usar C++, pos entonces son malos y punto :-P
Yo hasta ahora pensaba C para el kernel, C++ para las aplicaciones. Pero resulta que el GIT es también una aplicación... ¿porqué no en C++? Pues no, piensa que es malo. Ergo... es malo para todas las aplicaciones. Incluso pa'l kde :-p
Yo, mientras no se entere que sigo programando en Pascal, estoy a salvo :-P
Menos mal que no programo 0;)
Fuera de si es mejor uno que otro (no puedo opinar porque no programo), hay que tener en cuenta la personalidad del Sr. Torvalds: es un poco "directo" y tajante (IMHO, a veces un poco maleducado). Por lo que habría que andarse al loro con lo que dice, igual que cuando habla el Sr. Stallman.
Ya veo, ya... :-) ...
IMHO, ocmo siempre, no creo que haya una herramienta perfecta y única, depende de lo que quieres hacer, cómo lo quieres hacer, los conocimientos que tienes, el tiempo del que dispones, la pasta que te van a pagar, ...
Claro. Los negros y blancos puros no existen, son grises. - -- Saludos Carlos E.R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAklJAKAACgkQtTMYHG2NR9VHyACbBcBKR4BLFbNTCPCyNVESxAb6 65oAn17ulFZSE9Y86B94IwmQk2F28RnL =5VMb -----END PGP SIGNATURE-----
El 17/12/08, Carlos E. R. escribió:
Si piensa que los programadores de C++ son malos por el simple hecho de usar C++, pos entonces son malos y punto :-P
A mi me parece que, leyendo el hilo del git, se trata más bien del punto de vista de un "padre" (Linus) defendiendo a su "criatura" (Git), es decir, poco o nada objetivo O:-) Saludos, -- Camaleón -- Para dar de baja la suscripción, mande un mensaje a: opensuse-es+unsubscribe@opensuse.org Para obtener el resto de direcciones-comando, mande un mensaje a: opensuse-es+help@opensuse.org
O Wednesday 17 December 2008 12:55:15 Carlos E. R. escribiu:
El 2008-12-17 a las 02:00 -0300, Cristian Rodríguez escribió:
Carlos E. R. escribió:
Y sin embargo, prefiere el kde al gnome. Muy curioso.
No tiene nada de curioso, KDE no es un kernel ni tampoco un sistema de control de versiones como GIT.
¡Claro que es curioso! Podrá ser justificable, tendrá sus motivaciones, pero sigue siendo curioso.
Si piensa que los programadores de C++ son malos por el simple hecho de usar C++, pos entonces son malos y punto :-P
Yo hasta ahora pensaba C para el kernel, C++ para las aplicaciones. Pero resulta que el GIT es también una aplicación... ¿porqué no en C++? Pues no, piensa que es malo. Ergo... es malo para todas las aplicaciones. Incluso pa'l kde :-p
Yo, mientras no se entere que sigo programando en Pascal, estoy a salvo :-P Bueno, yo tampoco programo :p pero los que conozco que lo hacen, lo que he leído y me han contado... lo que necesitas siempre es un buen programador. Un buen lenguaje sólo le hará las cosas más fáciles. Es mejor un buen programador en Pascal que uno malo de C.
Según Stroustrup, C++ tiene la enorme virtud de ser un lenguaje "para todo": programación procedural, orientada a objetos... Se supone que un buen código bien ejecutado y con un buen compilador tiene que dar lugar a un objeto igual al que generaría un código en C, ya que C++ no es más que un super-conjunto de C. Otra cuestión es por qué usas C++ si sólo utilizas las capacidades de C... Bueno, el fuerte tipeado es un buen motivo :P :D Creo sinceramente que el uso de C de forma preferente tiene más que ver con haber comenzado por él que a otra cosa. Aquí una listilla de software desarrollado con C++. Vemos algún S.O.: http://www.research.att.com/~bs/applications.html Salud!! -- ------------- karl -- Para dar de baja la suscripción, mande un mensaje a: opensuse-es+unsubscribe@opensuse.org Para obtener el resto de direcciones-comando, mande un mensaje a: opensuse-es+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Content-ID:
Yo, mientras no se entere que sigo programando en Pascal, estoy a salvo :-P
Bueno, yo tampoco programo :p pero los que conozco que lo hacen, lo que he leído y me han contado... lo que necesitas siempre es un buen programador. Un buen lenguaje sólo le hará las cosas más fáciles. Es mejor un buen programador en Pascal que uno malo de C.
:-)
Según Stroustrup, C++ tiene la enorme virtud de ser un lenguaje "para todo": programación procedural, orientada a objetos... Se supone que un buen código bien ejecutado y con un buen compilador tiene que dar lugar a un objeto igual al que generaría un código en C, ya que C++ no es más que un super-conjunto de C. Otra cuestión es por qué usas C++ si sólo utilizas las capacidades de C... Bueno, el fuerte tipeado es un buen motivo :P :D
Creo sinceramente que el uso de C de forma preferente tiene más que ver con haber comenzado por él que a otra cosa.
Es un motivo, pero Linus dice, si no le he entendido mal, que si usaran C++ limitandose a la funcionalidad de C, alguien podría equivocarse y usar funcionalidades que no deben. In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C. And limiting your project to C means that people don't screw that up, and also means that you get a lot of programmers that do actually understand low-level issues and don't screw things up with any idiotic "object model" crap. No, no dice exactamente lo que he dicho. Pero vaya, que no quiere usar C++ ni siquiera limitandose a la funcionalidad del C. - -- Saludos Carlos E.R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAklJUJ0ACgkQtTMYHG2NR9XL1QCdEuNWkTRKpdKBSS5fT5cgpt+A 43kAoJU4/0K1peQJj3s/H1SCUriTgWo1 =bkDM -----END PGP SIGNATURE-----
participants (6)
-
Camaleón
-
Carlos E. R.
-
Cristian Rodríguez
-
Juan Erbes
-
Karl García Gestido
-
Rafa Grimán