Skip to content

Refactor to rely solely on Rapi#266

Closed
pachadotdev wants to merge 4 commits into
r-lib:mainfrom
pachadotdev:Rapi
Closed

Refactor to rely solely on Rapi#266
pachadotdev wants to merge 4 commits into
r-lib:mainfrom
pachadotdev:Rapi

Conversation

@pachadotdev
Copy link
Copy Markdown

Dear later maintainers:

I hope you are doing well.

Later is a great package that I am using for my research.

I found a few oddities using this on HM Government infrastructure.

Instead of using cpp11, or cpp4r with is my own mod, I went to a more "bare metal" approach and rewrote later internals to use only R's C API (or Rapi).

I hope this PR can be merged. My changes were:

  1. Update src/ in a very classic way
  2. Update the vignettes with cpp11 (Posit) or cpp4r (independent) examples
  3. Add a dummy package with examples of how to use the package (with unit tests)

This PR does not add new dependencies.

Be safe and well,
MVS

@pachadotdev
Copy link
Copy Markdown
Author

the checks are failing but because of a GHA-related thing

I opened a side PR for it

Run r-lib/actions/setup-r@v2
(node:2309) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
(Use `node --trace-deprecation ...` to show where the warning was created)

@jcheng5
Copy link
Copy Markdown
Member

jcheng5 commented May 12, 2026

Hello! Can you say more about what "found a few oddities" means? This would be an enormous change, to a much more brittle and demanding coding style, so I'm wondering what the motivation is.

@pachadotdev
Copy link
Copy Markdown
Author

Hello! Can you say more about what "found a few oddities" means? This would be an enormous change, to a much more brittle and demanding coding style, so I'm wondering what the motivation is.

Hi!

On the university cluster, and others as it looks from an rOpenSci chat, there are frequent Rcpp-ABI issues that lead to all kinds of unexpected behaviours. This affects Shiny apps and others.

The R's C API is very stable. I rewrote the same with some extra boilerplate with the idea of reducing friction.

@pachadotdev
Copy link
Copy Markdown
Author

Same as with 'httpuv' (rstudio/httpuv#437 (comment)), please let me know if it would be simpler that I create a new branch to do the same but using cpp11/cpp4r. The ABI issues are too time consuming, I am ok with working extra but for a "productive" goal.

@wch
Copy link
Copy Markdown
Member

wch commented May 12, 2026

Do you have a link to the rOpenSci chat where this has come up? It would be helpful for us to see that to better understand the issues people are running into.

@pachadotdev
Copy link
Copy Markdown
Author

Do you have a link to the rOpenSci chat where this has come up? It would be helpful for us to see that to better understand the issues people are running into.

Yes! I sent it to your maintainer email (I am too coward like to send Slack chats here without asking the admins).

I'll open another C++ branch to have a "mirror" of this change. If Rcpp is French, cpp11/cpp4r is Italian while Rapi is Latin (the Roman's language)

@pachadotdev pachadotdev mentioned this pull request May 13, 2026
@pachadotdev
Copy link
Copy Markdown
Author

Dear @wch:

I hope you are doing well.

Following this thread and httup's 437, I created a side PR using cpp4r: #268.

That PR is the same but with more abstractions, and therefore a more "smooth" change. Such approach has advantages and disadvantages:

  1. Advantages: Many changes are just a "ctrl+f" and replace [[Rcpp::export]] with [[cpp4r::register]]. The more substantive changes involve less "invasive" edits.
  2. Disadvantages: cpp4r has a more """formal""" approach and intentionally does not compile snippets. I had to move the examples in inst/ to a side package. This additional annoyance adds a side advantage: we test the later API using a side package and we can see more moving parts than directly compiling snippets for the unit tests.

I have no idea if my multiple commits are a good approach. For httup I edited by creating multiple local copies and then created one commit. Now I did the opposite, I followed more or less a "logical" approach by commiting different steps until it works.

Regarding tests, also commented in the httpuv, I added a Makefile that loops and tests the different {GCC, CLANG} and {CXX17, CXX20, CXX23} pairs. That may sound like a boring step but it is needed as Clang often does not like "informal" grammar that GCC is ok with it, and that is often a soure of problems for ARM architectures.

Please let me know if the other PR is better suited. I installed the cpp4r version in my cluster, and so far it works the same with less "hacks" than using only R's C API.

Best,
MVS

@pachadotdev
Copy link
Copy Markdown
Author

moved to #268

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants