From b.rowlingson at lancaster.ac.uk  Mon Jan 17 20:16:31 2011
From: b.rowlingson at lancaster.ac.uk (Barry Rowlingson)
Date: Mon, 17 Jan 2011 19:16:31 +0000
Subject: [Rd] R vs. C
In-Reply-To: <891858.34031.qm@web113714.mail.gq1.yahoo.com>
References: <AANLkTikbHjP7JvwfWjSaWds7fa4Ek=8LEo14h-Rm5igq@mail.gmail.com>
	<19764.34512.640668.433147@max.nulle.part>
	<891858.34031.qm@web113714.mail.gq1.yahoo.com>
Message-ID: <AANLkTi=7EwptjwsrqyR_OKYXCNP2Gn5uR-RMFdmNUpzC@mail.gmail.com>

On Mon, Jan 17, 2011 at 6:57 PM, David Henderson <dnadavewa at yahoo.com> wrote:
> I think we're also forgetting something, namely testing. ?If you write your
> routine in C, you have placed additional burden upon yourself to test your C
> code through unit tests, etc. ?If you write your code in R, you still need the
> unit tests, but you can rely on the well tested nature of R to allow you to
> reduce the number of tests of your algorithm. ?I routinely tell people at Sage
> Bionetworks where I am working now that your new C code needs to experience at
> least one order of magnitude increase in performance to warrant the effort of
> moving from R to C.
>
> But, then again, I am working with scientists who are not primarily, or even
> secondarily, coders...

If you write your code in C but interface to it in R, you can use the
same R test harness system. I recently coded something up in R, tested
it on small data, discovered it was waaay too slow on the real data,
rewrote the likelihood calculation in C, and then used the same test
set to make sure it was giving the same answers as the R code. It
wasn't. So I fixed that bug until it was. If I'd written the thing in
C to start with I might not have spotted it.

 Sometimes writing a prototype in R is a useful testing tool even when
you know it'll be too slow - as an interpreted language R gives you a
rapid development cycle and handy interactive debugging possibilities.
Things that do exist in C but require compilation....

Barry



[Rd] R vs. C
Barry Rowlingson