5 ms·
> I can use Rust, but I have never been on good terms with Rust. I have a story of rewriting part of our production code as Rust extension, which turned out to
by masklinn 4y ago
> I can use Rust, but I have never been on good terms with Rust. I have a story of rewriting part of our production code as Rust extension, which turned out to be 3-4 times faster, but we ditched it anyway, because maintenance cost would be too high
That would be an interesting tale, especially in light of helix / ruru / magnus (why so many?) (and I don't know how they compare to pyo3 in terms of ease of use).
I can see it if they used "raw" rb_sys though, that seems... not much of an improvement over C unless the API is really small and you can quickly bail out to safe Rust: https://briankung.dev/2022/02/02/writing-a-rust-gem-from-scratch/ https://briankung.dev/2022/02/02/writing-a-rust-gem-from-scr...
- ilyt 4y agoI'd imagine the story is just "we don't really write that much in Rust so going back after a break is a PITA"
- masklinn 4y agoI would assume they don't "really write that much in Zig" either (and Rust would be much easier to maintain for Rubyists) so anything but a statically typed pseudo-ruby (something like cython) would fail the test.
- nine_k 4y agoYou mean, Crystal?
- npn 4y agoYou can't use Crystal to write ruby extensions, because it has a huge runtime and a big GC. You can call Ruby script in Crystal though. [0] And I think Zig would be easier to maintain compare to Rust because it is a simpler language. Sure there is a lot of breaking changes, but it's not much of trouble for a language that can be read in one afternoon (referring to the single page document). [0]: https://github.com/Anyolite/anyolite https://github.com/Anyolite/anyolite
- masklinn 4y ago> And I think Zig would be easier to maintain compare to Rust because it is a simpler language. Which is not necessarily helpful when you're mostly not using it, and mostly as a way to build extensions for an other language: in that case what you want is a language which protects you from mistakes, and a glue layer which integrates safely (and hopefully idiomatically) between the two, aka pretty extensive safety abstractions, aka pretty much the opposite of zig.
- greenpeas 4y ago> Which is not necessarily helpful when you're mostly not using it When I return to a project written in a language that I don't use regularly, I basically have to re-learn the language (maybe there's something wrong with me, but I even forget the basics of a language that used to be my primary driver after I've not written in it for more than a year or two). So if I need to re-learn a language to make some changes, I think I'd much rather re-learn a simpler language.
- still_grokking 4y ago> I even forget the basics of a language that used to be my primary driver after I've not written in it for more than a year or two Same for me. But "re-learning" takes half a day at most. I just need to get used to it again, remember the idioms, remember the quirks. Of course this is more of an issue if you come back and half of the language changed in the meantime. (Something that's not so uncommon for pre-v1 stuff…)
- npn 4y agoSafety is overrated. If safety is the most important aspect of software then we should have been using Ada for everything by now. The same with idiomatic, in order to write code in a language idiomatically, you have to spend a lot of time using it, and much more time for a huge language like Rust. Usually people can't afford that, they want to rewrite the extension in a more performant language because they want the speed, not because they like the language they use to implement the extension (may be they do, but that's not the point). So simpler language like Zig is definitely better, the developers can just look at the one page document, implement the feature (with testing and all), then forget about it and come back to the language they are using daily.
- masklinn 4y ago> You mean, Crystal? No, Crystal is a ruby-like statically typed language, but it's not designed for embedding / shared libraries, even less so with an other GC'd language: it has its own runtime and GC. Ruby:Crystal is Python:Nim, not Python:Cython.
- Lio 4y agoSomething like the Sorbet Compiler? https://sorbet.org/blog/2021/07/30/open-sourcing-sorbet-compiler https://sorbet.org/blog/2021/07/30/open-sourcing-sorbet-comp...
- the_mitsuhiko 4y agoI would be shocked if they write more Zig than Rust. Likewise if they find more references and docs in Zig. A lot of zig code in the wild doesn’t even compile any more.
- pron 4y agoI wouldn't use either Zig or Rust in production just yet, but if you're someone willing to take that risk, then picking a language that is so easy to learn (learning Zig from scratch only takes a couple of days) is certainly an advantage especially if you're not using it much. There are definitely other factors against it, but I can easily see why this would be a very important one in its favour.
- the_mitsuhiko 4y agoThere is a massive difference in language stability, compiler stability and ecosystem maturity between Rust and zig. You can use Rust in production for multiple years and many companies do. The same can’t be said about zig.
- pron 4y agoCertainly, but on those metrics the two languages -- that are neither the only nor the frontrunner choices -- are closer to each other than either one is to the actually established, popular options that have a massive (positive) difference compared to both. So, if among the alternatives you are willing to consider either Rust or Zig to begin with, then popularity, maturity, clear prospects, and low long-term risk are clearly not your biggest factors and your choice will be based on other things that matter to you more. These factors do matter a lot to me, which is why I, like the vast majority of low-level shops, wouldn't pick either one of these languages for production use at the moment (if top speed were a crucial factor for me in picking a car, I wouldn't care by how much the second-to-last car beat the last car in a race, as I'd pick one from the leading pack), but the poster clearly has other considerations that should be judged based on the poster's values, not mine.
- drogus 4y agoI’d be interested in it as well. I imagine the author talks about Rust being hard, cause extending Ruby with Rust doesn’t seem problematic. Here is an example of simd json extension written in Rust using Rutie: https://github.com/drogus/simd-json-ruby/blob/main/src/lib.rs#L13 https://github.com/drogus/simd-json-ruby/blob/main/src/lib.r... It has a bunch of macros that are rather straightforward to use