Slide 1

Slide 1 text

ergo [email protected] @romain_francois http://bit.ly/ergo-rr2018

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

•Open source •Google •Simple •Fast enough

Slide 5

Slide 5 text

https://www.docker.com

Slide 6

Slide 6 text

https://bookdown.org/yihui/blogdown/

Slide 7

Slide 7 text

https://www.rstudio.com/products/connect/

Slide 8

Slide 8 text

example

Slide 9

Slide 9 text

package main import "fmt" func fahrenheit(celcius float64) float64 { return celcius * 1.8 + 32 } func main() { var freezing float64 = fahrenheit(0.0) boiling := fahrenheit(100.0) fmt.Printf("Water freezes at %4.2f F\n", freezing) fmt.Printf("Water boils at %4.2f F\n", boiling) }

Slide 10

Slide 10 text

package main import "fmt" func fahrenheit(celcius float64) float64 { return celcius * 1.8 + 32 } func main() { var freezing float64 = fahrenheit(0.0) boiling := fahrenheit(100.0) fmt.Printf("Water freezes at %4.2f F\n", freezing) fmt.Printf("Water boils at %4.2f F\n", boiling) }

Slide 11

Slide 11 text

$ go run fahrenheit.go Water freezes at 32.00 F Water boils at 212.00 F

Slide 12

Slide 12 text

research

Slide 13

Slide 13 text

bit.ly/ergorigin purrple.cat/tags/go/

Slide 14

Slide 14 text

bit.ly/ergorigin purrple.cat/tags/go/

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

http://bit.ly/grrr-join

Slide 17

Slide 17 text

wttr.in/Rennes

Slide 18

Slide 18 text

library(rvest) library(glue) library(fahrenheit) library(tibble) library(dplyr) temperature <- function(where = "Rennes"){ glue("https://wttr.in/{where}") %>% read_html() %>% html_node("span:nth-child(3)") %>% html_text() %>% as.numeric() } temperature("Rennes") %>% tibble(celcius = .) %>% mutate(fahrenheit = fahrenheit(celcius)) #> # A tibble: 1 x 2 #> celcius fahrenheit #> #> 1 19 66.2 #' Created on 2018-07-05 by the [reprex package](http://reprex.tidyverse.org) (v0.2.0).

Slide 19

Slide 19 text

romain@purrplex ~/git/rstats-go/rencontresr2018/fahrenheit $ tree . !"" DESCRIPTION !"" NAMESPACE !"" R # $"" fahrenheit.R !"" fahrenheit.Rproj !"" man $"" src !"" Makevars !"" fahrenheit.h !"" fahrenheit.so $"" go $"" src !"" fahrenheit # $"" fahrenheit.go $"" main !"" main.c $"" main.go 7 directories, 10 files fahrenheit main } }

Slide 20

Slide 20 text

package fahrenheit func Fahrenheit(celcius float64) float64 { return celcius * 1.8 + 32 } src/go/src/fahrenheit/fahrenheit.go

Slide 21

Slide 21 text

package main import "C" import "fahrenheit" //export Fahrenheit func Fahrenheit(x float64) float64 { return fahrenheit.Fahrenheit(x) ; } func main() {} src/go/src/main/main.go

Slide 22

Slide 22 text

#include #include #include "_cgo_export.h" SEXP _fahrenheit(SEXP x){ return Rf_ScalarReal(Fahrenheit(REAL(x)[0]); } src/go/src/main/main.c

Slide 23

Slide 23 text

#' @useDynLib fahrenheit #' @export fahrenheit <- function(celcius) { .Call("_fahrenheit", celcius, PACKAGE = "fahrenheit" ) } R/fahrenheit.R

Slide 24

Slide 24 text

.PHONY: go CGO_CFLAGS = "$(ALL_CPPFLAGS)" CGO_LDFLAGS = "$(PKG_LIBS) $(SHLIB_LIBADD) $(LIBR)" GOPATH = $(CURDIR)/go go: CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) \ GOPATH=$(GOPATH) /usr/local/go/bin/go \ build -o $(SHLIB) -x -buildmode=c-shared main src/Makevars

Slide 25

Slide 25 text

future

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

ergo [email protected] @romain_francois http://bit.ly/ergo-rr2018