8 ms·
Helix: Rust and Ruby, Without the Glue
- ksec 10y agoSo it is Rusted Rails? XD Anyway I think the same could be applied to Ruby Core as well. As I have been calling a Rusted Ruby for a long time. Though I am not sure if this is a good thing for other Ruby implementation like JRuby.
- shrugger 10y agoI think this is a GREAT thing for other implementations like JRuby. Rusty Ruby would be able to learn from some of the implementation tricks that impls like Jruby and rbx have learned along the way, and maybe those guys will learn something from the Rusty Ruby crew along the way also. Rust as far I know (not at all, honestly) doesn't interface with Java that well, so for JVM projects, it's nice to have a familiar language like Ruby that can tie in and make prototyping way easier. I think people misunderstand how awesome Jruby is, because Ruby has never performed that well and Jruby has performed very well. Performance is not the only reason to both implementing a language. There's also the issue of mindshare, where a large group of people might already know Ruby, and it'd be easier in those scenarios to just give them Jruby and let them go to town than try and drag them through learning Java. Rusty Ruby will do the same thing for Rust, I think. Rust is a very intricate, well-thought-out language, and I think it would benefit a lot from playing off the shared knowledge of thousands of Ruby users.
- pg_bot 10y agoI would be interested to see how Ruby's Set class performs in the Zesty example. If that is actually a bottleneck in the application, I would rather reach for something that is in the Standard Library instead of going fully native.
- halostatue 10y agoRuby’s set class is implemented in Ruby wrapping a Hash (`{ key => true }`), not in C (or Java or…). It’s fairly good when you’re testing for containment, but the implementation is probably going to be as bad or worse for the #fully_contains behaviour…except the requirement that Zesty’s arrays be sorted. Conceptually, a Set will do much better even with this sort of optimization.
- bjz_ 10y agoInteresting side-note: Rust's `HashSet<T>` is actually implemented by wrapping a `HashMap<T, ()>`. But because `()` is zero-sized (unlike a boolean), Rust can optimise a ton of stuff out.
- accbcc 10y agoI like Swift. Rust syntax make me headache.
- Rotten194 10y agoI like apples. Oranges look weird.
- MichaelGG 10y agoBut the Rust version of the blank check doesn't handle any encoding but UTF-8. Helix could wrap up a char iterator for it I suppose, one that calls rb_enc_codepoint_len? And isn't there some common C lib that exposes Unicode functions like is_whitespace? Granted, using a cargo crate is easier than finding and adding a .h, and far easier than getting and linking another lib.
- aidenn0 10y agoThe Rust version works on strings not on bytes. Strings don't have encodings.
- x5n1 10y agohuh? strings have encodings. rust strings are bytes encoded in utf-8. https://doc.rust-lang.org/book/strings.html https://doc.rust-lang.org/book/strings.html
- aidenn0 10y agoIn Rust a string is a sequence of unicode scalar values. I personally find it unfortunate that they dictate the storage of it at the API level, but that is a necessary evil for presenting a consistent ABI with foreign code. I did not know that strings in Ruby have encodings. Is there a reason for that? I personally don't like mixing characters and opaque byte sequences as they are very different.
- MichaelGG 10y agoRuby's Japanese heritage is probably why it handles encodings like that - I think there were multiple encs it had to deal with at once or something. Also Unicode doesn't completely handle all kanji in that there's some that have an old style not available in Unicode. But maybe that's not relevant.
- aidenn0 10y ago
- twelvechairs 10y agoVery excited to see the development of the Ruby/Rust space. The two languages together would seem a joy of a workflow from concept through to maintenance, and the wealth of important Ruby personalities currently involved in Rust (as well as others) encourages that that this will be a well trodden and well documented workflow sooner rather than later. I think this could help Ruby regain some of its early excitement, and remove the negativity of its 'just a scripting language', 'only for rails, which is too slow for modern development anyway' image.
- steveklabnik 10y agoThere's a _lot_ of stuff in this space: mrusty, ruru, Helix. It's exciting stuff.
- eropple 10y agomrusty is super cool. My only beefs with it are around the difficulties of mruby (package availability, 1.9.3 limitations, generally being "off the beaten path"), not of mrusty itself, but it's such a fantastic way to quickly build a scripting layer that I fell in love with it almost immediately. I would pay a decent chunk of money for a cleanly integrated MRI implementation inside of Rust, but I also will not be holding my breath for it.
- xuejie 10y agoJust out of curiosity: what limitations of Ruby 1.9.3 is critical in your case? Not to start a flame war, but according to my experience, Ruby 1.9 is already quite good, later versions of Ruby only introduce minor syntax & semantic changes, which is trivial to work around. This is nothing like the big differences between 1.8 and 1.9 I agree with package availability problem of mruby, tho.
- eropple 10y agoNothing is critical, I'm just so used to writing Ruby 2.3 at this point that 1.9 isn't as enjoyable. I wish it were better, I'm not saying it's bad.
- mlvljr 10y agoRust and Ruby, Without a Clue -- misread and thought, this was smth in style of "Programming by Poking" initially (https://news.ycombinator.com/item?id=11628080 https://news.ycombinator.com/item?id=11628080)
- hobs 10y agoIsnt a set containment problem a really simple problem to solve with a database, eg an inner join and a count?
- bjz_ 10y agoFor something that is in memory and throw-away, why go through a DB?
- hobs 10y agoI was taking the point of "Why is the problem taking so long when it seems like a simple thing to calculate?" which was a little orthonogal from theme of the total post, so I can see why there would be some confusion. The article talked about 30 minutes to run through a "is this set of items in this other set of a bunch of items". While it would probably make sense to do this efficiently in memory the reality is the company mentioned are probably doing it inefficiently in memory; asking some tool which can do this type of work effectively and is fairly well known was my basic suggestion.
- placeybordeaux 10y agoWhy hit the network/a central resource when you could just do it locally?
- drewbug 10y agoSometimes, it'll be faster.
- placeybordeaux 10y agoUnless you specify some asymmetry it will always be faster to do it locally.
- fouc 10y agoIt's a webapp, they're likely already querying all the meal information from a mysql or postgresql db. Chances are they could have made a change to their db models and written some sql to handle food requirements checking instead of handling it after the query. But that could've been premature optimization ultimately, and to speed it up now, it's probably easier to optimize the slow ruby code with some rust instead.
- deleted 10y ago[deleted]
- pzh 10y agoHmm. Kind of makes you wonder why you're using Ruby at all, which is slow as hell. It appears that once they port all Rails libraries to Rust, it may not take that much effort to create Rust on Rails and get rid of Ruby.
- rattray 10y agoRuby is phenomenally easy to write. This post essentially describes a way to make Ruby less slow, which would reduce the incentive to leave the language. Once they port all Rails libraries to Rust, you can still use the extremely-ergonomic Ruby programming language, but it won't be "slow as hell" anymore. And ruby performance is "tolerable in most circumstances" as-is. I certainly agree that it could be awesome to have Rust on Rails for those who would find even Rails on Rust performance intolerable, and Iron's abstractions inadequate.
- brightball 10y agoThis is the exact reason I'm headlong into Elixir and Phoenix right now. It's like the best of both worlds.
- danso 10y agoHow many platforms and frameworks have been completely ported over to a better language? There are many languages that have arguably succeeded PHP, and yet WordPress and Facebook remain on PHP, which would belie your assumption that "it may not take that much effort to [re]create [some framework] and get rid of [that framework's original language]"
- donpdonp 10y agoI find a great answer in this area is Crystal. I consider it 'go in ruby clothing'. Like go, Crystal is a typed language and outputs binary executables. They kept the beautiful ruby syntax and made better internals. http://crystal-lang.org/ http://crystal-lang.org/
- tmikaeld 10y ago
- rattray 10y ago> With Rails reaching version 5.0, there are plenty of APIs that are heavily used and extremely feature-stable. My goal with Helix is to eventually make it possible to reimplement a lot of these APIs as an native extension gem. Sounds extremely exciting!
- solipsism 10y agoHelix is the name Perforce is using to rebrand their set of tools. Just an FYI, I'm not saying that means this should not be called Helix.
- poizan42 10y agoThe amount of name reuse in software in recent years really frustrates. It makes it so much harder to find the information you are looking for. Besides that I really don't get why perforce are renaming their version control system yo Helix. Perforce is a well-known name, it seems weird to just drop a strong brand.
- jilljennV 10y agoMay I say? PRAISE HELIX.
- fouc 10y agoGreat blog post.. First time I've been sold on Rust, sounds like it's got some great features. Maybe I just had to hear about it from a Ruby dev. :) Typos in the article: "slimed down", "you code could" Is "needle_length = needle.length" actually necessary? I thought repeated calls would be zero cost, but I'm guessing I'm wrong.
- kibwen 10y agoIf Ruby is anything like Python, nonlocal name lookups in loops can indeed be performance bottlenecks.
- accbcc 10y agoRust has no its ecosystem, just pyramid selling. Swift will beat it!
- desireco42 10y ago:) I wish I understood this jab. Can you explain me.
- bigfcjjyfcg 10y agoThis is fucking cool. You have convinced me to pick up Rust.
- carlosft 10y agoWhat are the dependencies for installing the gem? I assume the machine will need rustc/cargo to compile the gem.
- steveklabnik 10y agoI am not super specifically knowledgeable about these details, but Rubygems lets you upload binaries to make this not needed generaly.