[Melbourne-pm] Still performing well..

Alfie John alfiejohn at gmail.com
Thu May 20 05:26:47 PDT 2010


On Thu, May 20, 2010 at 2:32 PM, Daniel Pittman <daniel at rimspace.net> wrote:

>   my $x = '.' x 10000;    # preallocate
>  sysread(FH, $x, 5000);  # ...and use that storage
>

C-C-C-Combo Breaker.

As you can see from above, always know what your system is doing. In
Abrash's Zen of Code Optimization, he shows that simple C can outperform
simple assembly. I hear you say that's impossible because assembly is
*closer* to the bare metal than C. In fact it *is* the bare metal! Later in
the book, after you realise what the CPU and memory bus is doing, what
Daniel said comes closer to the truth: you (almost) can't beat hand-tuned
assembly.

But again, it all depends on what you're doing. For equivalent code paths of
different languages, if nothing is firing off in the background like GC or
you're not thrashing your language's malloc etc then is all O(1), so who
cares. Once performance comparisons get to O(1) for different languages,
then I would rather optimise my typing and comprehension (i.e. easiest
language for the job).

Once again. It all depends on what you're doing. If you run your program on
different architectures like an i7, amd64, P4, core2duo, then you'll
probably see huge differences on where the performance spectrum languages
sit. You'd be surprised what nasties might bite.

>I don't know of any compiled language that performs better than
well-written
> C for many cases, because C is close to the metal, and allows the
programmer
> to do things their own way.

And as for that one: FORTRAN.

Alfie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20100520/20dcde13/attachment.html>


More information about the Melbourne-pm mailing list