Re: [Rd] C vs. C++ as learning and development tool for R

From: Roger Bivand <Roger.Bivand_at_nhh.no>
Date: Fri 19 Jan 2007 - 23:56:43 GMT


On Fri, 19 Jan 2007, Kimpel, Mark William wrote:

> Thanks to all for your excellent suggestions. I think will I proceed
> working through the Stroustrup book. He has a section on comparing C
> with C++ and one on working with legacy C code that may prove helpful. I
> also have a "C for Dummies" (something like that, I don't have it right
> next to me) that I have also been reading. A couple of follow-up
> questions:

C with data abstraction (C with Classes) is where C++ came from (that is a hybrid of Simula and C). Clean C is very portable, whereas C++ can get caught by name mangling between compiler versions. Arguably (certainly in cost and probably in elegance) a good deal can still be harvested from another young adult (20+ might be seen as IT archeology by some?) - SICP is online at:

http://mitpress.mit.edu/sicp/full-text/book/book.html

and is excellent on programming in general, just Chapter 1 is refreshing to (re)read every now and then. Kernighan and Pike's "The Practice of Programming" - simplicity, clarity, generality - is also good for one's common sense.

>
> 1. As I understand it, if I just wanted to distribute compiled code, I
> could use whatever extended C or C++ libraries that I wanted to use,
> however, since R is open source and people need to be able to compile
> things themselves, I imagine I would get into trouble (figuratively)
> using, say, the C++ STL. Would I need to distribute these files as well?
> For example, iostream instead of stdio.h. Or, should I just not use
> those?

Very few things are as standardised as they claim. I/O should not be done other than through R (like memory management where possible), so reducing the number of things that can go wrong (on some platform).

>
> 2. For those of you who develop C on Windows (probably a small bunch!),
> what is your preferred development environment? I have the free Borland
> Turbo C++ and Visual C++ 6.0 (I knew enough to stay away from .NET). I
> tried to install the C++ module for Eclipse and, for me at least, it was
> a nightmare. I am not UNIX or DOS savvy and setting path variables and
> the like just made things too complicated.

Just MinGW like R, following the guides to the letter gets you there like marked stones across a marsh. Leaving the path usually gets you at best neck deep in the mire, alternatively just bubbles. The existing code in both base R and the contributed packages is a good guide, but prototyping in R alone, and profiling to see where things take time before implementing in a compiled language, is often prudent.

>
> 3. Lastly, is there a C or C++ community similar to R that I could
> address questions relating to those languages to? I don't want to abuse
> the R list as I learn.
>
> Thanks,
> Mark
>
> Mark W. Kimpel MD
>
>
>
> (317) 490-5129 Work, & Mobile
>
>
>
> (317) 663-0513 Home (no voice mail please)
>
> 1-(317)-536-2730 FAX
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand@nhh.no

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat Jan 20 11:00:30 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 20 Jan 2007 - 09:31:00 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.