Google Answers Logo
View Question
 
Q: Computer language efficiency ( No Answer,   2 Comments )
Question  
Subject: Computer language efficiency
Category: Computers > Programming
Asked by: kaoin-ga
List Price: $4.50
Posted: 28 Mar 2004 18:42 PST
Expires: 27 Apr 2004 19:42 PDT
Question ID: 321420
What computer languages are the most and least efficient in the
different categories of assembler (x86, mips, sparcasm, etc),
procedural (C, fortran, etc), object-oriented (Java, Python, etc),
functional (Haskell, O'caml, etc). I realize comparisons between
different assembler languages are of little relevance but any
information is interesting. Languages where multiple compilers and
platforms are present, x86 and the most efficient compiler are the
most interesting.

Execution speed, code size and memory demands are the judging criterias.

Clarification of Question by kaoin-ga on 29 Mar 2004 09:57 PST
I really don't need a complex answer, just a quick "X seems to be the
fastest in this category, while Y slowest."
Answer  
There is no answer at this time.

Comments  
Subject: Re: Computer language efficiency
From: rerdavies-ga on 30 Mar 2004 21:18 PST
 
Assemblers are obviously the most efficient, but compilers are good
enough these days (and processors complicated enough) that it's pretty
difficult to realize dramatic performance improvements writing
assembler by hand. The last time I did a serious major optimization in
assembler, I gained about 10% on the compiled code. However, there are
rare cases where SIMD instructions (which current-generation compilers
don't really use well) may yield two or 3x speed improvements.

C,C++, Fortran are all blindingly fast. Careful coding can usually
realize performance that is within 5 to 10% of hand-coded assembler.

Compile-on-demand languages like Java and C# are probably next on the
list. It's pretty common for code generated by these languages to run
2 or 3x slower. However, there are circumstances where these languages
run 10x or 20x slower (heavy array manipulation in C#, for example).

Interpreted languages like Python and Javascript run anywhere from 10x
to 300x slower depending on the problem at hand.

Functional languages: I'm not sure. I've never worked with a
functional languages that doesn't use an interpreter (and therefore
run 10x to 300x slower). In theory, functional languages can acheive
performance comparable to C, or C++ under limited circumstances. And,
in practice, if you were to try to write C or C++ programs that tried
to used functional programming approaches to problem solving,
functional languages would probably win. But don't expect to do real
time audio or graphics with a functional language.

In all cases, it really depends what kind of programming task you are
trying to solve. Assembler programming is pretty much a dead art. C or
C++ will handle almost anything. And Fortran is good for
high-performance scientific programming. But for most problems,
performance really isn't an issue. Computers are fast enough these
days that it's pretty difficult to max out a CPU.

Comparing different processors is like comparing apples and oranges.
Some have great memory systems, some have great floating point, some
have great super-scalar execution.

Interestingly, most performance problems on modern processors are
caused by memory subsystems, not CPUs. A good intel processor spends
most of its time waiting for memory accesses to complete. That's the
major reason why it's hard to improve on C or C++ code. If you write
the code to access memory in sensible patterns, you can usually
acheive equivalent performance whether the program is written in C++
or assembler.
Subject: Re: Computer language efficiency
From: kaoin-ga on 31 Mar 2004 03:48 PST
 
Thank you very much for your answer! It was quite interesting to read.
One thing I might add is that the O'Caml functional language gets
C/C++ execution speeds in compiled form.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy