From murdoch.duncan at gmail.com  Mon Jan 17 18:53:58 2011
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Mon, 17 Jan 2011 12:53:58 -0500
Subject: [Rd] R vs. C
In-Reply-To: <4D347F59.5060100@pburns.seanet.com>
References: <AANLkTikbHjP7JvwfWjSaWds7fa4Ek=8LEo14h-Rm5igq@mail.gmail.com>
	<4D347F59.5060100@pburns.seanet.com>
Message-ID: <4D348236.6060701@gmail.com>

On 17/01/2011 12:41 PM, Patrick Burns wrote:
> Everyone has their own utility
> function.  Mine is if the boredom
> of waiting for the pure R function
> to finish is going to out-weight the
> boredom of writing the C code.
>
> Another issue is that adding C code
> increases the hassle of users who might
> want the code to run on different
> architectures.

... and also makes it harder for you and your users to tweak your code 
for different uses.

It is not uncommon for C code to run 100 times faster than R code (but 
it is also not uncommon to see very little speedup, if the R code is 
well vectorized).  So if you have something that's really slow, think 
about the fundamental operations, and write those in C, then use R code 
to glue them together.  But if it is fast enough without doing that, 
then leave it all in R.

Duncan Murdoch

> On 17/01/2011 17:13, Patrick Leyshock wrote:
> >  A question, please about development of R packages:
> >
> >  Are there any guidelines or best practices for deciding when and why to
> >  implement an operation in R, vs. implementing it in C?  The "Writing R
> >  Extensions" recommends "working in interpreted R code . . . this is normally
> >  the best option."  But we do write C-functions and access them in R - the
> >  question is, when/why is this justified, and when/why is it NOT justified?
> >
> >  While I have identified helpful documents on R coding standards, I have not
> >  seen notes/discussions on when/why to implement in R, vs. when to implement
> >  in C.
> >
> >  Thanks, Patrick
> >
> >  On Sun, Jan 16, 2011 at 3:00 AM,<r-devel-request at r-project.org>   wrote:
> >
> >>  Send R-devel mailing list submissions to
> >>          r-devel at r-project.org
> >>
> >>  To subscribe or unsubscribe via the World Wide Web, visit
> >>          https://stat.ethz.ch/mailman/listinfo/r-devel
> >>  or, via email, send a message with subject or body 'help' to
> >>          r-devel-request at r-project.org
> >>
> >>  You can reach the person managing the list at
> >>          r-devel-owner at r-project.org
> >>
> >>  When replying, please edit your Subject line so it is more specific
> >>  than "Re: Contents of R-devel digest..."
> >>
> >>
> >>  Today's Topics:
> >>
> >>     1. RPostgreSQL 0.1.7 for Windows 64 causes R.2.12.1 Win64 crash
> >>        (Xiaobo Gu)
> >>
> >>
> >>  ----------------------------------------------------------------------
> >>
> >>  Message: 1
> >>  Date: Sat, 15 Jan 2011 10:34:55 +0800
> >>  From: Xiaobo Gu<guxiaobo1982 at gmail.com>
> >>  To: r-devel at r-project.org
> >>  Subject: [Rd] RPostgreSQL 0.1.7 for Windows 64 causes R.2.12.1 Win64
> >>          crash
> >>  Message-ID:
> >>          <AANLkTinvoub-z_Le1GVPYswnqTsW1P6MZzLZsztois9K at mail.gmail.com>
> >>  Content-Type: text/plain; charset=ISO-8859-1
> >>
> >>  Hi,
> >>  I build the binary package file of RPostgreSQL 0.1.7 for Windows 2003
> >>  Server R2 64 bit SP2, the software environments are as following:
> >>           R 2.12.1 for Win64
> >>           RTools212 for Win64
> >>           DBI 0.2.5
> >>           RPostgreSQL 0.1.7
> >>           Postgresql related binaries shipped with
> >>  postgresql-9.0.2-1-windows_x64.exe from EnterpriseDB
> >>
> >>  The package can be loaded, and driver can be created, but the
> >>  dbConnect function causes the whole RGui crashes,
> >>
> >>  driver<- dbDriver("PostgreSQL")
> >>  con<- dbConnect(driver, dbname="demo", host="192.168.8.1",
> >>  user="postgres", password="postgres", port=5432)
> >>
> >>
> >>
> >>  ------------------------------
> >>
> >>  _______________________________________________
> >>  R-devel at r-project.org mailing list  DIGESTED
> >>  https://stat.ethz.ch/mailman/listinfo/r-devel
> >>
> >>
> >>  End of R-devel Digest, Vol 95, Issue 14
> >>  ***************************************
> >>
> >
> >  	[[alternative HTML version deleted]]
> >
> >  ______________________________________________
> >  R-devel at r-project.org mailing list
> >  https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>



[Rd] R vs. C
Duncan Murdoch