This Hacker News discussion centers around the capabilities and implications of WebR, a project that brings the R programming language to the web using WebAssembly. Key themes emerge regarding its technical underpinnings, interoperability with other web technologies, potential use cases, and the perennial concern of file size.
Performance and BLAS Integration
A significant portion of the conversation revolves around the performance of WebR, particularly concerning its handling of linear algebra operations, a common bottleneck in R. Users inquire about the inclusion of optimized Basic Linear Algebra Subprograms (BLAS) libraries, with a general understanding that R's default reference BLAS can be slow.
- "Does it include a decent BLAS? If I remember correctly R ships with reference BLAS, but for decent performance you need something external. Wonder what they picked for wasm based R." - stabbles
- "Isn’t the linear algebra conventional wisdom that matrix ops are ALWAYS the bottleneck? I’m sure this is true in scientific computing. In R maybe a bunch of resampling would be expected to dominate?" - fn-mote
The underlying technical implementation is touched upon, with speculation about LLVM Flang being used to compile Fortran components, including reference BLAS and LAPACK.
- "Probably uses LLVM Flang to make the Fortran parts happen, compiling reference BLAS and LAPACK. As the main dev for WebR is also the one who did this [0]." - shakna
Despite these performance discussions, one user offers a tempered perspective on R's typical usage:
- "I wonder what kind of edge cases you deal with when blas is your bottleneck in R. Stan code aside, I’ve seen few problems that are neither instant (i.e. sub hours) nor impossible (I.e years of compute)." - uniqueuid
Interoperability with HTML, CSS, and JavaScript
A major point of excitement is WebR's potential to integrate R seamlessly with standard web technologies like HTML, CSS, and JavaScript. This opens up possibilities for creating interactive web applications where R code can be executed directly in the browser, generating visualizations or performing computations.
- "What does this mean in practice? Does this mean you could start with a blank .html file, and use html, css, and javascript (like normal), but then somehow run R too? e.g. to generate a ggplot using the browser (as opposed to server, as a shiny app may)?" - nomilk
- "I created it as a side project from using WebR to execute code LLM-generated code (https://quesma.com/blog-detail/sandboxing-ai-generated-code-...). While we migrated away from it, I saw that WebR is cool, and I wanted to share it with you." - stared
- "Yes you can use R in the middle of HTML with this ( and even combine R and JavaScript)." - ekianjo
Providing practical, minimal examples is seen as crucial for understanding these capabilities:
- "Has anyone got a minimal reproducible examples (e.g. tiny html file that runs, say 2 * 2 in R)? The example linked to in the article has the key line
<script type="module" src="repl.mjs"></script>
, but that mjs file goes over my head." - nomilk
Several users share links to examples demonstrating this integration, including generating ggplot2
charts.
- "If you want to use it to create ggplot2 charts, here is an open source demo: https://github.com/QuesmaOrg/demo-webr-ggplot/" - stared
- "Here’s a ggplot2 example: https://webr.sh/#code=eJxtkLFOwzAQhsWapzh5ckSUpEgsSBkY2RAVrN..." - georgestagg
- "There’s a simplified example here: https://github.com/r-wasm/webr/tree/main/src/examples/eval" - georgestagg
Support for R Markdown and Quarto
The discussion also covers the compatibility of WebR with R's document generation tools, specifically R Markdown and Quarto. The ability to run these directly in the browser is seen as a significant feature for creating reproducible research and interactive documents.
- "Does this also support Rmd? That would be pretty cool if you could publish an rstudio notebook and have a flow to edit a copy of the notebook straight in the web." - tovej
- "it should via the Rmarkdown library." - ekianjo
- "There is a quarto-webr extension to do this. A bunch of real world examples are at https://quarto-webr.thecoatlessprofessor.com/qwebr-community-examples.html" - thebelal
Offline Capabilities and Progressive Web Apps (PWAs)
The possibility of using WebR offline, perhaps as a Progressive Web App (PWA), is raised as a desirable feature. While no concrete examples are provided, the potential exists.
- "Can you install it as a progressive web app, to work offline as well?" - Qem
- "Someone did a demo on mobile a while ago, offline, so yes it is possible but I have never seen an actual code example on how to do that." - ekianjo
File Size Concerns
A recurring sentiment is the concern over the WebR WASM blob's size, with 12MB being noted as potentially substantial for web deployment.
- "Cool but 12MB WASM blob. I wish there was a way of making these WASM builds significantly smaller." - tlarkworthy
Counterarguments suggest that this size might be justifiable for a full R runtime and that optimization could reduce the payload for specific use cases.
- "Usually they are shipped in a compressed form. If 12MB is compressed it could be that it represents the entire R runtime to support the general R REPL. It could be possible to reduce the payload by compiling only what's necessary to run a particular R program into the wasm binary. That should cut down size considerably." - ModernMech
Interestingly, one user contrasts the WASM blob's performance favorably with traditional web applications:
- "The funny thing is that the performance of a 12MB WASM blob is probably superior to most Shiny apps with more than light traffic." - calmbell
Julia Comparison and WebAssembly for Scientific Computing
The conversation briefly touches upon similar efforts for other languages, specifically Julia, to gauge the broader landscape of bringing scientific computing languages to the web via WebAssembly.
- "Is there "Julia in the browser" that runs locally?" - ForceBru
- "Yeah check out https://plutojl.org/" - vehicles2b
- "Pluto needs a server process and simply shows a nice UI, while WebR literally runs R in the browser on your machine with WebAssembly, so it's not the same" - ForceBru
- "I don't think so, not yet. There's been Julia-on-wasm efforts that have been inching along for a while, but it's not nearly at a mature point afaik. I remember reading that some new developments (maybe shifting more of the compiler work to Julia with JuliaLowering.jl, maybe something else) have made wasm a lot more feasible, but it's gonna need some people with a need for it to actually work on it." - sundarurfriend
General Enthusiasm and Accessibility
Underlying the technical discussions, there is a clear sense of excitement and appreciation for projects that make R more accessible and usable in modern web environments.
- "I really like R. I find it a nice language to work in. I'm glad to see projects like this that make it more accessible." - ants_everywhere