Erik de Castro Lopo <mle+s...@mega-nerd.com> writes: > Daniel Pittman wrote: > >> > AFAIAC, C and C++ are for low level code or tasks which are highly >> > performance critical. >> >> Pshaw. What crazy talk is this?
I fear that my intention, of humor, in this statement didn't carry as well as I might have hoped. Anyway... > I have two projects written in C: > > http://www.mega-nerd.com/libsndfile/ > http://www.mega-nerd.com/libsamplerate/ > > which are both relatively performance critical. I would have ported > these to a higher level language a long time ago if I thought I > could get improved perfromance. As it is, I am working with a guy > to improve performance of libsamplerate by redoing some of it in x86 > XMMS intrinsics or assembler. *nod* At the lowest level, nothing beats hand-tuned assembler except for a good compiler and the occasional JIT compiler — and even then, not all that often. The place that the VM can win is when you are dealing with general purpose algorithms that you don't (or can't) hand-optimize every possible code path for, mostly. The advantage they bring to the table is that they can use techniques such as trace compilation that understand not just the static optimization options available, but the dynamic ones based on the current use of the code. Google for "trace tree compilation" for the papers and discussion of the current limits, but the general summary is: Trace trees allow the JIT compiler to dynamically discover the points in your code that are most used, analyse them way they flow — not just inside a function, but at the instruction level, through multiple code blocks — and then generate an optimized inline version of the entire "trace". That can be a substantial win, just as profile-trace guided static optimization can be a substantial win for optimizing your software ... assuming you get the profiling part right. :) > C has another advantage, its the language that is easiest to bind > to from other languages. No question there, from me. :) >> OCaml is significantly faster, in general, because the design is much >> tighter and so offers better static options. > > How much Ocaml code have you written? I've written quite a bit and > Ocaml is, in all non-trivial cases, slower than well written C. Presumably not enough, then. My understanding, on that front, comes from what is probably best summarised as relatively limited personal work, and working with people who used it extensively. I am happy to defer to your experience in the specific language. Regards, Daniel _______________________________________________ coders mailing list coders@slug.org.au http://lists.slug.org.au/listinfo/coders