From: Eivind Eklund Date: 2007-11-29T04:22:44+09:00 Subject: Re: Most elegant way to do this? On Nov 28, 2007 4:25 PM, William James wrote: > On Nov 28, 7:10 am, Lloyd Linklater wrote: > > > William James wrote: > > > That C-code is hideous. Let's compare it to something > > > that isn't insanely low-level. > > > > OOOOO! I know this one! > > > > If you meant this as pascal, this is the code: > > > > function roll( n: integer ): integer; > > var i: integer; > > begin > > for i := 1 to n do result := inc(result, random(6) + 1); > > end; > > > > There is no += in pascal. If only... :) Your version where you init > > the result so you do not have to add may run faster but I golfed it a > > bit. Still, it is far better than the C version. I liked seeing it > > here too. :) > > Glad you liked it. It strikes me as bizarre that so many Ruby > users who want more speed descend from the dizzying heights of > Ruby to the chthonic depths of ultra primitive C. Why not use > Pascal? I would guess because more people know C than Pascal, and it is easier to link Ruby to C than to Pascal? Apart from that, having programmed both C and Pascal, I only see small differences in level. Object Pascal aside, as far as I can remember from my Pascal programming days (15 years since I wrote my last line of Pascal - how time flies...), there's little abstraction available in Pascal that's not there in C - the most I can think of would be "with" and a nicer integration of the export/import module system. Care to enlighten me as to how you see these as being at very different levels? Eivind.