On Wednesday 20 May 2009, Michael Gogins wrote: > In the real world, this is more important than the elegance of > functional programming. In the music world, elegance of notation helps composers. All my music code written in Haskell runs so fast that I don't have to wait. This is not a computationally demanding domain. Csound takes far longer to run by many orders of magnitude. However, if my code needed to do more work, and was less concerned with musically structure, then I'd start by compiling it and then look at more aggressive ways to improve the performance. I've long been amazed at how many people dismiss languages without even considering the use of a compiler. My first code to make sounds was written in Basic, but I had no compiler for it at that time. My next code was written in Forth, for which I had several compilers (one of which I wrote myself, but that's another story). I've yet to write any music-related code in C/C++, but as I'm using Csound to make the audio, generating the score in C/C++ would be overkill for my modest needs. It already takes less than a second to generate a score that takes Csound minutes to render. How will improving the performance of my score-generating code help me? Will C/C++ improve the quality of the notation for my music? That's unlikely, given the high standard set by Haskore. So for now, I'm content to write my code in languages like Haskell, Scheme, and Common Lisp. On the rare occaision when the runtime is poor and I can't improve it any more by tweaking the code, I identify the bottleneck and rewrite that one bit of code in C. The last time I had to do that was in the mid-90s, and that was some HTML-parsing code. The one of the two C functions I wrote skipped whitespace and the other collected text until it hit a delimiter. With the compilers I use today, I doubt I'd need to do that now. As I said above, Csound itself is the performance bottleneck for me, and that's already written in C. AFAICT the C code is very well optimised. By that I mean that the optimisations have been performed on the source code before the compiler even reads it. (There's an old joke that the C language employs a highly sophisticated optimiser called a C programmer.) However, if/when you find that the Csound runtime is close to or less than the runtime of your score-generating code, then by all means use whatever measures you see fit to improve the performance of the latter. :-) -- Martin Rodgers http://www.wildcard.demon.co.uk