{"id":30132679,"url":"https://github.com/travisbrown/rust-jvm-demo","last_synced_at":"2025-10-04T01:57:29.168Z","repository":{"id":139820131,"uuid":"366703776","full_name":"travisbrown/rust-jvm-demo","owner":"travisbrown","description":"Rust on the JVM","archived":false,"fork":false,"pushed_at":"2021-05-16T14:34:44.000Z","size":85,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-10T19:15:54.626Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/travisbrown.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-12T12:13:29.000Z","updated_at":"2021-05-16T14:34:46.000Z","dependencies_parsed_at":"2023-07-23T20:05:56.867Z","dependency_job_id":null,"html_url":"https://github.com/travisbrown/rust-jvm-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/travisbrown/rust-jvm-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisbrown%2Frust-jvm-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisbrown%2Frust-jvm-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisbrown%2Frust-jvm-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisbrown%2Frust-jvm-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/travisbrown","download_url":"https://codeload.github.com/travisbrown/rust-jvm-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisbrown%2Frust-jvm-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278254465,"owners_count":25956600,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-10T19:02:16.381Z","updated_at":"2025-10-04T01:57:29.164Z","avatar_url":"https://github.com/travisbrown.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust on the JVM\n\n[![Build status](https://img.shields.io/github/workflow/status/travisbrown/rust-jvm-demo/Continuous%20Integration.svg)](https://github.com/travisbrown/rust-jvm-demo/actions)\n\n## Motivation\n\nThis repository is a quick self-contained experiment I put together to check the feasibility of\npublishing build tools written in Rust for use in pure JVM contexts.\n\nI'm working on a parser generator that can output (among other things) Java and Scala code\n(specifically a parser for the provided grammar implemented in Java, and a safe wrapper, ScalaCheck\ninstances, etc. in Scala). The parser generator is implemented in Rust, but ideally I'd want to be\nable to publish it as a pure JVM library and sbt plugin that wouldn't require the user to have any\nRust tooling installed or to have to worry about platform-specific issues.\n\n## This demo\n\nThis project includes implementations of two simple operations in Rust and Scala:\n\n* Parse an arbitrary JSON document and return all strings that look like URLs as a JSON array.\n* Parse an arbitrary JSON document and count all scalar values.\n\nThe Rust implementation uses [Serde](https://docs.serde.rs/serde_json/) and the Scala implementation uses [Circe](https://github.com/circe/circe).\n\nI've [compiled the Rust implementations into WASM](https://rustwasm.github.io/docs/book/)\nand then the WASM into JVM bytecode with a modified version of [Asmble](https://github.com/cretz/asmble)\n(which unfortunately isn't currently maintained). The resulting jar is available in the `lib/` directory, and is currently only 36K.\n\nThere are tests and [JMH](https://openjdk.java.net/projects/code-tools/jmh/) benchmarks for the two implementations on the JVM.\n\nThese operations don't exactly match my actual use case, but they're close:\nin both cases I'm parsing small documents in Rust, using \"real\" Rust libraries, doing some work, and generating new documents as output.\n\n## Results\n\nThere's currently some unpleasant code on both the Rust and Scala sides that's needed to get strings back and forth,\nbut it's fairly generic and could probably mostly be moved into the WASM-to-JVM tooling.\n\nPerformance doesn't matter much for my actual use case, but I wanted to be sure it wasn't excessively bad,\nand it looks okay (definitely better than I expected):\n\n```\nBenchmark                      Mode  Cnt      Score      Error  Units\nExtractUrlsBench.circe        thrpt   20  51351.757 ±  749.093  ops/s\nExtractUrlsBench.serde        thrpt   20  14380.148 ±   30.884  ops/s\nCountScalarValuesBench.circe  thrpt   20  57325.181 ± 2662.133  ops/s\nCountScalarValuesBench.serde  thrpt   20  16471.974 ±  345.556  ops/s\n```\n\nWarning: this code is terrible and this approach might not end up working at all.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravisbrown%2Frust-jvm-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftravisbrown%2Frust-jvm-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravisbrown%2Frust-jvm-demo/lists"}