Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What's special about node.js here? Does golang, C#, python, ruby, java, etc... have a virtual file system?

I get it, I've implemented things for tests, I'm just wondering if this shouldn't be solved at an OS level.

--- update

Let's put this another way, my code does effectively, child_process.spawn('something-that-reads-and-write-a-file')

now I'm back to the same issue. To test I need a virtual file system. Node providing one won't help.



Go actually does https://pkg.go.dev/embed

I do think it's more painful to distribute files when you're a distributed as a single binary vs scripts, since the latter has to figure out bundling of files anyway.

But still - it does exist


Embed is read-only at runtime. This proposed vfs module for Node.js is a full virtual file system.


true


It's cool that it fits into golang's readable file system interface so it can be used polymorphically. I don't know if golang has very complete interfaces for a read and write file system that could be used for a full vfs. If it does, that's nice, and a starting point for a similar vfs! I'm also not sure whether it should go into the standard library or not.


Zip files are created in such a way that they can be a part of an executable file. (This is how self-extracting archives used to work.) Support for reading zip files is lightweight, and is present almost everywhere.

A ZIP fork embedded into the executable should be an obvious read-only VFS implementation. Bring your assets with you, even maybe build them with the standard zip utility.

It should take relatively few LOCs, provided that libzip is already linked into the executable anyway.


Java, Haskell, Rust, and several other languages do have solutions for this. Here’s one for Rust: https://docs.rs/vfs/latest/vfs/


In the past, I've implemented this in Ruby and elixir on Linux systems using a ramdisk.


Python doesn't have a virtual filesystem in general but it is possible to shim the import mechanism.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: