5 ms·
Javascript runs everywhere where there is a browser. Rust runs everywhere where there is a c compiler, which is funnily enough the sample places that C/C++ run
by zeth___ 8y ago
Javascript runs everywhere where there is a browser.
Rust runs everywhere where there is a c compiler, which is funnily enough the sample places that C/C++ run.
- bluejekyll 8y agoAnd with wasm, Rust/C/C++ all can run in the browser too...
- zeth___ 8y agoNot quite yet. But getting there.
- bluejekyll 8y agopretty much there: https://www.hellorust.com/setup/wasm-target/ https://www.hellorust.com/setup/wasm-target/
- fineline 8y agoJS in the browser has direct integration to the DOM, networking, various local data persistence APIs, and other IO and sensors (webcam, accelerometer...) etc. Rust can be compiled to run in a sandbox, which can then be integrated via a remote call interface with the JS layer, and thus be indirectly (via JS) connected to the above APIs, but there are currently concerns around the performance of this approach. Rust cannot independently manage a web page which hosts it, without JS. There is some way to go before browsers support practical, accessible and performant front-end web apps in Rust.
- erikpukinskis 8y agoWhen people say “The Browser” they mean “that thing which is on literally every computer where you instantly load that one kind of software”. People think the web is a technology, or that JavaScript is a language. They’re not. It’s not. The web is an idea: it’s the idea that every computer in the world already has the runtime on it that can run your next app. Whatever that is—whatever that runtime is—that’s “The Browser”. WASM is not that. Maybe in 10 years.
- somenewacc 8y agoemscripten can compile to both wasm and asm.js and load them depending on browser support. this seems good enough.
- erikpukinskis 8y agoPerformance won’t be as good as hand tuned JavaScript with native DOM calls.
- abiox 8y agowebassembly has vastly improved performance in a variety of situations.
- nulagrithom 8y agoWhat are you babbling about? The web is technology. JavaScript is a language. And WASM is shipping in all major browsers already. You don't have to wait 10 years. You can start using WASM today.
- erikpukinskis 8y agoIt hurts my feelings that you think I’m babbling. I’m trying to be as articulate as I can. I don’t want to write software just for people with 2 year old iPhones. I write software for everyone, especially people who can’t afford anything but the hardware they’re stuck with. That’s why I’m not going to target WASM. That’s my point: to me, “The Web” isn’t just modern browsers on newish devices. It’s the whole world as an audience. I think that’s why so many people target the web. I also think WASM is premature optimization in almost all situations. That said, I totally support anyone who wants to target it. It’s dope technology. If you love Rust and you want to write browser apps with it, and limit your audience a little, knock yourself out. I don’t think you’re embracing what the web is for, but there’s no law that says you have to.
- abiox 8y agoafaik webassembly has shipped in all major browsers - edge, firefox, opera, chrome and safari... including mobile versions.
- noobermin 8y agoYou're aware that most operating systems have a C API, right? Give me a place C doesn't run where js does.
- jakelazaroff 8y agoIn a browser. Yes, there's wasm, but it has a lot of limitations that don't apply to JavaScript. fineline had a good comment about it upthread: https://news.ycombinator.com/item?id=17088315 https://news.ycombinator.com/item?id=17088315
- sigstoat 8y agohttps://github.com/kripken/emscripten https://github.com/kripken/emscripten
- pjmlp 8y agoTry to use the C API on Android, ChromeOS, Windows Phone, Mbed.
- hsaliak 8y agoYou mean wherever there is llvm? It's a large subset, but it is still a subset.
- zeth___ 8y agoHuh til that rust isn't compillable by gcc.
- palotasb 8y agoThat's different. The rust toolchain is compiled by rust, and it relies on LLVM which can be compiled by GCC. But LLVM does not have a backend for every architecture (or even if it does, it might require extra effort from the Rust compiler using it and they have not enabled support for _everything_). Thus not all architectures can be targets for Rust programs.
- zaarn 8y agoI'm not sure on the last point, a lot of architectures, especially niche ones, aren't supported by Rust at all while there are plenty of C compilers for them going around. (have fun trying to get Rust working on 8bit controllers or Itanium/ia64)
- ryanbrunner 8y agoI think the point is less that Rust runs everywhere that C runs, and more that there doesn't exist an environment that can run Rust and not run C (which is not true for Javascript)
- vlovich123 8y agoCan you clarify this point? To me it would seem with Rust being able to target WASM/ASM.js that you could indeed target all the same environments JS does.
- regularfry 8y agoEmscripten means that's not a distinguishing feature from C or C++.
- vlovich123 8y agoMy response was to the last part that there's an environment where Javascript can run but Rust can't. I agree that C/C++ targets are a strict superset but I'll posit that for all the architectures that matter it's the same surface area at which point the calculation for which to use is about ease-of-use, correctness, etc.