From: Richard Heathfield on 30 Oct 2009 06:28 [Followups set to comp.lang.c] In <702c1562-9d1f-42f6-aaed-0c41dce5fb2d(a)15g2000yqy.googlegroups.com>, Nick Keighley wrote: <snip> > why use assembler when you have C? I can think of only two reasons. The first is easily dispensed with: you might use assembly language instead of C because you WANT to. In the professional sphere, this is unlikely to be considered a good enough reason, but it's a perfectly adequate reason for hobbyists (which obviously includes professional programmers in their hobbyist capacity). "Because I want to" requires no further justification for *any* decision whatsoever in any field of endeavour (provided the decision is yours to make and doesn't break any local laws). The second reason is perhaps best considered as a series of conditions: 1) you have measured the performance of the C version AND 2) you have determined that the performance does not meet the constraints of your specification AND 3) you have taken all reasonable steps to optimise your C code (specifically, ensuring that you have chosen good algorithms and implemented them properly in performance terms, and selected an appropriately aggressive optimisation level on your compiler) AND 4) you have taken a few relatively UNreasonable steps to optimise your C code (e.g. loop unrolling, common subexpression elimination that the compiler has somehow missed, etc) AND 5) you have, or can acquire, or can hire, the requisite skill in assembly language for your targeted platforms AND 6) the assembly language version shows significant performance gains over the C version AND 7) performance on the platforms you support is more important than portability to platforms that you don't yet support. THEN you have a case for using assembly language. In other words, almost never. -- Richard Heathfield <http://www.cpax.org.uk> Email: -http://www. +rjh@ "Usenet is a strange place" - dmr 29 July 1999 Sig line vacant - apply within
From: io_x on 31 Oct 2009 05:35 "Nick Keighley" <nick_keighley_nospam(a)hotmail.com> ha scritto nel messaggio news:702c1562-9d1f-42f6-aaed-0c41dce5fb2d(a)15g2000yqy.googlegroups.com... >why use assembler when you have C? because someone has fun on write that asm code? because that is the way for write the hard algoritms or the maths algoritms or input-output algo? because where there is to solve a real problem there must be one assembler?
From: Aleksej Saushev on 1 Nov 2009 15:01 Nick Keighley <nick_keighley_nospam(a)hotmail.com> writes: > why use assembler when you have C? Because some things are way harder to express in C than in assembler. -- HE CE3OH...
|
Pages: 1 Prev: why REVAPPEND? Next: reverse engineering of compiled lisp code |