Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Helix: Ruby Native Extensions Without Fear

Helix: Ruby Native Extensions Without Fear

Helix makes writing Ruby classes in Rust safe and fun. Find out how!

Godfrey Chan

April 26, 2017
Tweet

More Decks by Godfrey Chan

Other Decks in Programming

Transcript

  1. Previously…

    View Slide

  2. Ruby is slow…
    – Usually it doesn’t matter

    – Most workload are I/O bound

    – But occasionally it does…

    View Slide

  3. “Best of both worlds”
    – Native extensions

    – JSON gem

    – Very fast

    – Transparent to the user

    – Date, Pathname, etc…

    View Slide

  4. Turbo Rails…?
    – String#blank?

    – Sam Saffron’s fast_blank

    – 50 LOC in C

    – 20x speedup

    View Slide

  5. But C…
    – Unsafe

    – Risky – segfaults!

    – Maintenance burden

    – Contribution barrier

    View Slide

  6. Skylight Agent
    – Started with Ruby

    – Too much overhead

    – Native extension!

    – But C…

    View Slide

  7. Meet Rust
    – Like C: compiled, statically typed, very fast

    – Unlike C: enjoyable to use, guarantees safety

    – “If it compiles, it doesn’t crash”

    – Same guarantee as Ruby, but without GC

    View Slide

  8. Zero-cost abstractions™
    – In Ruby: tension between abstractions and performance

    – Symbol#to_proc, Enumerable#map, etc

    – In Rust: no such tradeoff

    – Compiler is magic

    View Slide

  9. fast_blank in Rust*
    * boilerplate not included

    View Slide

  10. fast_blank in Helix

    View Slide

  11. The vision
    – Keep writing the Ruby you love…

    – …without the fear of eventually hitting a wall

    – Start with Ruby

    – Move to Helix when appropriate

    View Slide

  12. Last year
    – Good proof-of-concept

    – Too hard to use

    – Missing basic features

    View Slide

  13. This year
    – Deploy to production

    – Polish, documentation

    – Features

    – Focus on Rails

    View Slide

  14. Demo!
    – End-to-end example

    – Deploy to Heroku

    – It works!™

    View Slide


  15. http://chancancode.tv/helix

    View Slide

  16. Good use cases
    – CPU-bound

    – Simple inputs

    – Avoid chatty APIs

    View Slide

  17. Good use cases

    View Slide

  18. Good use cases
    – Use Rust libraries

    – Leverage Rust web browser tech

    – Mailer, Background job, Action Cable

    View Slide

  19. View Slide

  20. Roadmap
    – Greenfield project

    – Drop-in replacement

    – Reopen class

    – Ship to production

    – Binary distribution

    – Non-traditional use-cases

    – Performance parity with C

    – Miscellaneous features and QoL improvements

    View Slide

  21. usehelix.com

    View Slide