
Helix: Rust and Ruby, Without the Glue - chancancode
http://blog.skylight.io/introducing-helix/
======
twelvechairs
Very 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
There's a _lot_ of stuff in this space: mrusty, ruru, Helix. It's exciting
stuff.

~~~
eropple
mrusty 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
Just 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
Nothing 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.

------
rattray
> 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!

------
fouc
Great 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
If Ruby is anything like Python, nonlocal name lookups in loops can indeed be
performance bottlenecks.

------
pg_bot
I 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
Ruby’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_
Interesting 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.

------
MichaelGG
But 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
The Rust version works on strings not on bytes. Strings don't have encodings.

~~~
hetman
What do you mean? All Rust strings are UTF-8 encoded, and all Ruby strings
have an associated encoding.

~~~
steveklabnik
All rust String and &strs are UTF-8 encoded, there are also other string
types.

------
ksec
So 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
I 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.

------
carlosft
What are the dependencies for installing the gem? I assume the machine will
need rustc/cargo to compile the gem.

~~~
steveklabnik
I am not super specifically knowledgeable about these details, but Rubygems
lets you upload binaries to make this not needed generaly.

------
solipsism
Helix 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
The 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.

------
bigfcjjyfcg
This is fucking cool. You have convinced me to pick up Rust.

------
hobs
Isnt a set containment problem a really simple problem to solve with a
database, eg an inner join and a count?

~~~
bjz_
For something that is in memory and throw-away, why go through a DB?

~~~
hobs
I 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
Why hit the network/a central resource when you could just do it locally?

~~~
fouc
It'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.

~~~
hobs
Exactly, I dont mean to beat a dead horse, but most bog standard web apps have
the quoted items in a db anyway, and these are very common problems.

For example if we have a few tables we can determine which menu items a user
could eat:

    
    
      users
      user_ingredient_exclusions
      ingredients
      menu_ingredients
      menu
    
      -- items a user can eat based on not having any items in the excluded   list
      select distinct m.*
      from menu m
      inner join menu_ingredients mi on m.id = mi.menu_id
      left join user_ingredient_exclusions e on e.ingredient_id = mi.ingredient_id
      inner join user u on u.id = e.user_id
      where e.id is null
      and u.id = @id

------
jilljennV
May I say? PRAISE HELIX.

------
accbcc
Rust has no its ecosystem, just pyramid selling. Swift will beat it!

~~~
desireco42
:) I wish I understood this jab. Can you explain me.

------
accbcc
I like Swift. Rust syntax make me headache.

~~~
Rotten194
I like apples. Oranges look weird.

------
pzh
Hmm. 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
Ruby 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
This is the exact reason I'm headlong into Elixir and Phoenix right now. It's
like the best of both worlds.

