Subj : Re: Compiler and an interpreter To : comp.programming From : Jon Harrop Date : Fri Aug 05 2005 06:31 pm Gerry Quinn wrote: > In article <1123159636.278503.19720@g43g2000cwa.googlegroups.com>, > robert.thorpe@antenova.com says... >> Gerry Quinn wrote: > >> > Either takes seconds to write. > >> But on a larger scale writing more of the OCaml is quicker. It may >> take you 30 seconds to write the above, but it may take Jon 10 seconds >> to write his. It all adds up. > > Given that in either case one could write thousands of LOC in a day if > this were the bottleneck, I don't think it's a real issue. The real issue is that the ratio of OCaml to C++ code size increases as the absolutely code size increases. On 100 LOC programs I typically find C++ to be twice as verbose. On 1,000 LOC programs C++ is more like 5x as verbose. The largest project of my own projects replaced ~100kLOC of C++ with 4kLOC of OCaml. >> I'm pretty sure you can do this in C++ anyway, with "transform". > > What I wrote is a C++ cliche that will be equally recognisable. As your "cliche" fails to factor out a HOF it is necessarily less powerful. >> So, what would be really interesting to know is: >> * Could one write a more concise C++ version, regardless of efficiency >> * Could one write a faster C++ version, regardless of conciseness >> * Could both be done > > My guess is that the second could probably be done, but not the first. > C++ is designed so you can go as low-level as C to please the hardware, > so it should be feasible to write a very fast program. That is a common misconception that only applies to trivial problems. For anything non-trivial, you need a HLL to get good performance. >> It's not that complex, though it's certainly more complex than average. >> Perhaps one function in a twenty a programmer would have to write >> would be that complex, I'd guess. > > I doubt that, unless he really hates short functions! Maybe we could > say that writing such functions, even if they are one in a hundred, > might well take a significant fraction of the programmer's time, if the > task is math-intensive. What exactly do you mean by "math intensive", e.g. are algorithms and data structures "math"? -- Dr Jon D Harrop, Flying Frog Consultancy http://www.ffconsultancy.com .