from Hacker News

Zeroperl: Sandboxing Perl with WebAssembly

by ccakes on 2/11/25, 8:11 PM with 34 comments

  • by dang on 2/11/25, 10:43 PM

    Since this is Part 1, we merged the comments from the Part 2 thread hither:

    Get in loser. We're rewinding the stack - https://news.ycombinator.com/item?id=43014070

    Readers may want to look at both articles of course!

  • by ncruces on 2/11/25, 11:35 PM

    Oh I'm so interested in this.

    I've wanted to use wazero to run my Exiftool [1] for quite a while. Just as I use wazero to sandbox dcraw [2].

    But WASI Perl never materialized.

    This may just be what I'm missing.

    [1]: https://github.com/ncruces/go-exiftool

    [2]: https://pkg.go.dev/github.com/ncruces/rethinkraw@v0.10.7/pkg...

  • by adolph on 2/11/25, 5:49 PM

    Subhead is "Sandboxing Perl with WebAssembly - Part 2."

    The subhead sounds weird, but part 1 makes more sense and is pretty interesting. Perl has many modules to deal with file formats nobody has used since Perl's prime. It isn't totally clear to me if the goal is to compile the Perl interpreter into WASM or interpreter + modules. In any either case the goal is to re-use the original tools within new tooling.

    I’m building a new startup and file metadata plays an important role. There are thousands of file formats, each format may have dozens of versions, and each stores metadata differently.

    Our use-case also needs metadata to be present when a file is uploaded - extracting the data on our servers means we add considerable overhead to upload post-processing & we lose data that is useful to customers.

    So we need to extract metadata client-side and staple it to the upload. Herein begins a journey of self-inflicted pain and suffering.

    ExifTool is written in Perl.

    https://andrews.substack.com/p/zeroperl-sandboxed-perl-with-...

  • by ecmm on 2/11/25, 8:40 PM

    Not sure if it is useful for your use-case, but at Wasmer we’ve been spending some time adding support for the eh proposal: https://github.com/wasmerio/wasmer/pull/5383
  • by benatkin on 2/11/25, 7:23 PM

    That's really impressive. Like the author I am aware of the advantages/drawbacks of emscripten and wasi-sdk. The author did well to look extensively into both of them. Here's the repo. https://github.com/uswriting/zeroperl

    As increasingly is the case, a good starting point is the CI workflow: https://github.com/uswriting/zeroperl/blob/main/.github/work...

  • by Animats on 2/11/25, 6:08 PM

    setjmp/longjmp in 2025? That's kind of retro.
  • by mdaniel on 2/12/25, 3:37 AM

    The ongoing ... lively ... discussion about "wasm all the things" may interest this audience, too: https://news.ycombinator.com/item?id=43020684
  • by rurban on 2/12/25, 6:27 AM

    "percc" just does not work?

    He obviously he meant my perlcc, it is maintained for compatible perl versions and it works and is used in industry.

  • by rurban on 2/12/25, 6:30 AM

    This guy is just crazy. https://github.com/libexif/libexif exists and is much easier to use than compiling perl to wasm, just to run the overly slow exiftool.
  • by Gunax on 2/11/25, 5:43 PM

    I do not understand this at all, but it looks cool.
  • by hobs on 2/11/25, 6:12 PM

    Honestly it seems like porting ExifTool would actually be easier than this nightmare.