You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
R is an amazing interpreted language, giving a flexible and agile foundation for Data Science.
15
15
Efforts such as Rcpp and reticulate have established that it can be an advantage
16
-
to pair R with another programming language. Sometimes for speed, but most importantly
17
-
to have alternative options of expression.
16
+
to pair R with another programming language. Sometimes for speed, sometimes to
17
+
have alternative options of expression, sometimes to have access to existing
18
+
libraries.
18
19
19
-
> Maybe mention that we sometimes want to use existing implementations?
20
-
21
-
[Go](https://golang.org) is an open source programming language that makes it easy to
20
+
Go (`https://golang.org`) is an open source programming language that makes it easy to
22
21
build simple, reliable and efficient software. It is sometimes said to be the language
23
22
C++ should have been, in particular if it did not carry a strong commitment to backwards
24
23
compatibility to C and a taste for complexity.
25
24
26
25
Go is beautiful and simple, its standard library is one of the most impressive
27
26
for a programming language. It comes with concurrency built in, which includes
28
27
(but is not limited to) running code in parallel. The static site generator [hugo](https://gohugo.io),
29
-
the containerization plaform [docker](https://www.docker.com/), and the profiling utility [pprof](https://github.com/google/pprof) are examples
28
+
the containerization plaform [docker](https://www.docker.com/), and the profiling
29
+
utility [pprof](https://github.com/google/pprof) are examples
30
30
of systems that are built with Go.
31
31
32
32
There currently is no end to end solution to easily connect R and Go, i.e. invoke Go code
@@ -38,28 +38,22 @@ interesting avenues for R package development.
38
38
39
39
## Rcpp
40
40
41
-
The Rcpp package by Eddelbuettel and François is the current state of the practice to connect C++ code with R, used by over 1300 CRAN packages.
42
-
With Rcpp it is very easy to make a C++ function callable from R: mark the function with [attributes](https://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-attributes.pdf), and Rcpp generates the glue code that takes care of converting input and output data and propagating errors.
43
-
Rcpp offers the `Vector` class, with specializations like `IntegerVector`, `CharacterVector`, and `List`, that allow accessing R data structures in a way idiomatic to C++.
44
-
Rcpp sugar supports writing C++ code that almost looks like R code but implements the operations internally without roundtripping to R.
41
+
The Rcpp package (`https://github.com/RcppCore/Rcpp`) is the current state of the practice to connect C++ code with R,
42
+
used by over 1300 CRAN packages. With Rcpp it is very easy to make a C++ function callable from R: mark the function with [attributes](https://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-attributes.pdf), and Rcpp generates the glue code that takes care of converting input and output data and propagating errors.
43
+
Rcpp offers classes such as `NumericVector`, and `List`,
44
+
that allow accessing most R data structures in a way idiomatic to C++.
45
45
46
46
## rmq
47
47
48
-
The rmq package (https://github.com/glycerine/rmq) by Jason E. Aten is scoped
48
+
The rmq package (`https://github.com/glycerine/rmq`) is scoped
49
49
as a proof of concept to embed a Go library in an R package.
50
50
The code uses msgpack, a serialization protocol, to pass data between R and Go,
51
51
and implements a client-server system using websockets.
52
-
According to the author, the project is finished.
53
-
Unfortunately, installation of this package requires tweaking the code, so far I
54
-
was unable to install the package and test the code on OS X and Ubuntu.
55
-
56
52
57
53
## r-go proof of concept
58
54
59
-
Independently of rmq, I have written four blog posts at
60
-
https://purrple.cat/tags/go/ that describe how to
61
-
embed a Go library in an R package so that it is compiled when
62
-
the R package is installed.
55
+
Independently of rmq, I have written a series of blog posts at `https://purrple.cat/tags/go/` that describe how to
56
+
embed Go code in an R package so that it is compiled when the R package is installed.
63
57
I show how to call functions in the library and how to pass data to and from Go.
64
58
Even though the code in the blog posts has been written manually, it is explicitely
65
59
divided in two different categories:
@@ -77,14 +71,14 @@ As opposed to `Rcpp` which is a dependency in all stages (development, build, r
77
71
code to interface R and Go via their respective C apis. From the point of view of the user of `ergo`,
78
72
the workflow will be:
79
73
80
-
- Write code in idiomatic Go
74
+
- Write code in idiomatic Go somewhere standard in the package
81
75
- Generate boiler plate (Go, R, C) with functions from `ergo`
82
-
- Call that code from R
76
+
- Call that code from R functions of the package
83
77
84
78
The role of `ergo` is to hide the C layer entirely, so that users can focus on writing Go and R code.
85
-
In a way, this is similar to the feature of
86
-
Rcpp attributes,
87
-
but it goes further. Once `ergo` has generated the code, the target package is autonomous.
79
+
In a way, this is similar to the feature of Rcpp attributes,
80
+
but it goes further. Once `ergo` has generated the code, the target package is autonomous. This gives
81
+
more control to the package authors and eliminate a set of issues related to dependency.
88
82
89
83
## First iteration
90
84
@@ -131,11 +125,13 @@ to imagine the importance of Rcpp when it was first developed.
131
125
132
126
## About the author
133
127
128
+
I have more than 12 years professional experience with R and a strong commitment
129
+
to open source development.
130
+
134
131
I am a co-author of Rcpp that now has more than 1000 downstream dependencies,
135
132
the experience of having written Rcpp is extremely valuable in the pursuit of this project.
133
+
136
134
Curiosity about Go led me to incept this project in the summer of 2017.
137
-
I have more than 12 years professional experience with R and a strong commitment
0 commit comments