linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: How to write elegant C coding
@ 2005-01-05  6:44 krishna
  2005-01-05  7:49 ` Coywolf Qi Hunt
  0 siblings, 1 reply; 11+ messages in thread
From: krishna @ 2005-01-05  6:44 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel Mailing List, Con Kolivas

Thank you very much.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to write elegant C coding
  2005-01-05  6:44 How to write elegant C coding krishna
@ 2005-01-05  7:49 ` Coywolf Qi Hunt
  2005-01-05  8:14   ` Al Viro
  0 siblings, 1 reply; 11+ messages in thread
From: Coywolf Qi Hunt @ 2005-01-05  7:49 UTC (permalink / raw)
  To: krishna; +Cc: Alan Cox, Linux Kernel Mailing List, Con Kolivas

I'd say better to study compile theory and a kind of compiler source code.


On Wed, 05 Jan 2005 12:14:19 +0530, krishna
<krishna.c@globaledgesoft.com> wrote:
> Thank you very much.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


-- 
Coywolf Qi Hunt
Homepage http://sosdg.org/~coywolf/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to write elegant C coding
  2005-01-05  7:49 ` Coywolf Qi Hunt
@ 2005-01-05  8:14   ` Al Viro
  2005-01-05 15:17     ` How to write elegant C coding (certainly OT) Adrian von Bidder
  0 siblings, 1 reply; 11+ messages in thread
From: Al Viro @ 2005-01-05  8:14 UTC (permalink / raw)
  To: Coywolf Qi Hunt; +Cc: krishna, Alan Cox, Linux Kernel Mailing List, Con Kolivas

On Wed, Jan 05, 2005 at 03:49:07PM +0800, Coywolf Qi Hunt wrote:
> I'd say better to study compile theory and a kind of compiler source code.

Yes, gcc source definitely makes a great cautionary tale about the need of
writing elegant code and dreadful results of not doing so.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to write elegant C coding (certainly OT)
  2005-01-05  8:14   ` Al Viro
@ 2005-01-05 15:17     ` Adrian von Bidder
  0 siblings, 0 replies; 11+ messages in thread
From: Adrian von Bidder @ 2005-01-05 15:17 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 713 bytes --]

On Wednesday 05 January 2005 09.14, Al Viro wrote:
> On Wed, Jan 05, 2005 at 03:49:07PM +0800, Coywolf Qi Hunt wrote:
> > I'd say better to study compile theory and a kind of compiler source
> > code.
>
> Yes, gcc source definitely makes a great cautionary tale about the need
> of writing elegant code and dreadful results of not doing so.


LOL

I specifically recommend the ARM backend.  It was copied from some other 
RISC target, then a ARM thumb (16bit instruction width) backend was split 
from that, and finally the thumb and 32bit backends were merged again, 
apparently without removing much of the duplicated code.

Fun.

-- vbi

-- 
featured link: http://fortytwo.ch/gpg/subkeys

[-- Attachment #2: Type: application/pgp-signature, Size: 388 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to write elegant C coding
@ 2005-01-06 15:17 krishna
  0 siblings, 0 replies; 11+ messages in thread
From: krishna @ 2005-01-06 15:17 UTC (permalink / raw)
  To: vonbrand, Linux Kernel

Hi,

Thank you very much for refering me for "programming pearls".

Regards,
Krishna Chaitanya

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to write elegant C coding
  2005-01-05  3:43   ` krishna
  2005-01-05  3:55     ` Tim Hockin
  2005-01-05  4:11     ` Alan Cox
@ 2005-01-05 15:11     ` Horst von Brand
  2 siblings, 0 replies; 11+ messages in thread
From: Horst von Brand @ 2005-01-05 15:11 UTC (permalink / raw)
  To: krishna; +Cc: Linux Kernel, Con Kolivas

krishna <krishna.c@globaledgesoft.com> said:

[...]

> What I mean is both elegant and _efficient_ best practices in C coding.

Look for "Writing Efficient Programs", by Jon Bentley (sadly out of print),
and his "Programming Pearls" (2nd edition).

Keep in mind that "efficient" is mostly a thing of overall organization and
careful design (and data structure definition), not detailed programming.
Microoptimizations are usually counter-productive, at least by making the
code unnecessarily hard to read; current compilers aim at generating code
from "normally written C" that is at least as good as that a competent
assembly programmer would write with care (and often writing "more
efficient source code" just confuses the compiler into giving worse
results). Better aim at understandable, easy to get right code. If you
_measure_ later that it is too slow/large/..., _then_ go back and see how
to make it better. So Documentation/CodingStyle is an excellent starting
point.
-- 
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to write elegant C coding
  2005-01-05  3:43   ` krishna
  2005-01-05  3:55     ` Tim Hockin
@ 2005-01-05  4:11     ` Alan Cox
  2005-01-05 15:11     ` Horst von Brand
  2 siblings, 0 replies; 11+ messages in thread
From: Alan Cox @ 2005-01-05  4:11 UTC (permalink / raw)
  To: krishna; +Cc: Linux Kernel Mailing List, Con Kolivas

On Mer, 2005-01-05 at 03:43, krishna wrote:
> What I mean is both elegant and _efficient_ best practices in C coding.

Documentation/CodingStyle is well worth a read. Also for that matter
just reading a lot of good code helps you write good code as reading
helps you learn a language better.

Efficiency is a harder subject: Remember that efficient code still must
be easy to understand so often is about algorithms not language, and in
part about hardware.

On the hardware side - the book "Unix systems for modern architectures"

But as Tim righly said "practice"

Alan


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to write elegant C coding
  2005-01-05  3:43   ` krishna
@ 2005-01-05  3:55     ` Tim Hockin
  2005-01-05  4:11     ` Alan Cox
  2005-01-05 15:11     ` Horst von Brand
  2 siblings, 0 replies; 11+ messages in thread
From: Tim Hockin @ 2005-01-05  3:55 UTC (permalink / raw)
  To: krishna; +Cc: Linux Kernel, Con Kolivas

On Wed, Jan 05, 2005 at 09:13:04AM +0530, krishna wrote:
> 
> What I mean is both elegant and _efficient_ best practices in C coding.

practice.

> Con Kolivas wrote:
> 
> >krishna wrote:
> >
> >>Hi All,
> >>     Can any one tell me sources to refer to write elegant C coding/ 
> >>best practices in C coding.
> >
> >
> >Check the kernel sources under Documentation/CodingStyle
> >
> >Cheers,
> >Con
> >
> >
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Tim Hockin
thockin@hockin.org
Soon anyone who's not on the World Wide Web will qualify for a government 
subsidy for the home-pageless.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to write elegant C coding
  2005-01-05  3:42 ` Con Kolivas
@ 2005-01-05  3:43   ` krishna
  2005-01-05  3:55     ` Tim Hockin
                       ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: krishna @ 2005-01-05  3:43 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Con Kolivas


What I mean is both elegant and _efficient_ best practices in C coding.

Con Kolivas wrote:

> krishna wrote:
>
>> Hi All,
>>      Can any one tell me sources to refer to write elegant C coding/ 
>> best practices in C coding.
>
>
> Check the kernel sources under Documentation/CodingStyle
>
> Cheers,
> Con
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to write elegant C coding
  2005-01-05  3:26 krishna
@ 2005-01-05  3:42 ` Con Kolivas
  2005-01-05  3:43   ` krishna
  0 siblings, 1 reply; 11+ messages in thread
From: Con Kolivas @ 2005-01-05  3:42 UTC (permalink / raw)
  To: krishna; +Cc: Linux Kernel

krishna wrote:
> Hi All,
>      Can any one tell me sources to refer to write elegant C coding/ 
> best practices in C coding.

Check the kernel sources under Documentation/CodingStyle

Cheers,
Con

^ permalink raw reply	[flat|nested] 11+ messages in thread

* How to write elegant C coding
@ 2005-01-05  3:26 krishna
  2005-01-05  3:42 ` Con Kolivas
  0 siblings, 1 reply; 11+ messages in thread
From: krishna @ 2005-01-05  3:26 UTC (permalink / raw)
  To: Linux Kernel

Hi All,
   
    Can any one tell me sources to refer to write elegant C coding/ best 
practices in C coding.

Regards,
Krishna  Chaitanya

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-01-06 15:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-05  6:44 How to write elegant C coding krishna
2005-01-05  7:49 ` Coywolf Qi Hunt
2005-01-05  8:14   ` Al Viro
2005-01-05 15:17     ` How to write elegant C coding (certainly OT) Adrian von Bidder
  -- strict thread matches above, loose matches on Subject: below --
2005-01-06 15:17 How to write elegant C coding krishna
2005-01-05  3:26 krishna
2005-01-05  3:42 ` Con Kolivas
2005-01-05  3:43   ` krishna
2005-01-05  3:55     ` Tim Hockin
2005-01-05  4:11     ` Alan Cox
2005-01-05 15:11     ` Horst von Brand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).