5 ms·
Could something like this - running in essentially a totally sandboxed environment, like webassembly - be Zig's sweet spot? I think of Zig as a very developer f
by losvedir 4y ago
Could something like this - running in essentially a totally sandboxed environment, like webassembly - be Zig's sweet spot? I think of Zig as a very developer friendly, powerful, fast, fun, low level language, without the strict safety guardrails of rust.
For some applications, rust's borrowchecker is not something you're going to want to be without, but is "memory safety" actually a concern when compiling to web assembly? In that case, is Zig all pros and no cons? You get its easy to use interfaces for allocation and working with raw bytes, but without the chance of memory vulnerabilities, like when running in a sandboxed browser environment or Cloudflare's V8 isolates?
- kibwen 4y agoSandboxed environments prevent many of the worst effects of memory unsafety, though at best you'll still crash your program, and at worst you'll still leak or corrupt the contents of your process's memory. They also impose performance overhead relative to unsandboxed code. So it's less "all pros and no cons" and more "fewer cons, but fewer pros". Which can still be an improvement in general, depending on context.
- mustache_kimono 4y ago> I think of Zig as a very developer friendly, powerful, fast, fun, low level language, without the strict safety guardrails of rust. Whenever I read something like this, I think: "Why is it some people will dream up niches for other languages to fill that are about people not liking Rust?" It's interesting if only because it seems lots of people really like writing Rust. Have these people tried Rust? Shouldn't Zig stand on its own -- "Zig is better because it solves X and Y" or even some matter ease or style "Zig makes it easier to X and Y which is important for WASI apps"?
- xtian 4y agoZig does stand on its own https://ziglang.org/learn/why_zig_rust_d_cpp/ https://ziglang.org/learn/why_zig_rust_d_cpp/
- mustache_kimono 4y agoExactly. "Zig: Because [these good reasons] for WASI/WASM" or even "I just prefer Zig to Rust" is a much better argument. My point was only -- "Zig: Because people don't like writing Rust" is kind of a weird case to make, when lots and lots of people seem to like writing Rust.
- googlryas 4y agoThere's masochists in the world. A lot of people enjoy writing C++.
- mustache_kimono 4y ago"Why didn't you just write this in C++?" == "But can't we be miserable forever?"
- pjmlp 4y agoI do, despite its warts, because as polyglot developer I am able to use mixed code bases, so I get all the safety I need from managed languages, and only use C++ for what would be anyway unsafe code blocks. .NET + C++/CLI, Java/Kotlin + JNI/NDK, JavaScript + C++ addons, and so on. Many developers get lost trying to use an hammer for every nail.
- pcwalton 4y agoMemory safety is also a helpful productivity tool, because it eliminates bugs, even if those bugs don't turn into security vulnerabilities. Whether that is worth the mental overhead of the lifetime/borrow system is something you have to decide. Personally, I find it's an easy choice.
- oconnor663 4y agoDoes the Wasm sandbox actually catch use-after-free? I thought it was just out-of-bounds accesses or something like that, but I mostly have no idea.