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!

22bb3e56828870ee9a0dd93aeadbe04a?s=128

Godfrey Chan

April 26, 2017
Tweet

Transcript

  1. Previously…

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

    workload are I/O bound – But occasionally it does…
  3. “Best of both worlds” – Native extensions – JSON gem

    – Very fast – Transparent to the user – Date, Pathname, etc…
  4. Turbo Rails…? – String#blank? – Sam Saffron’s fast_blank – 50

    LOC in C – 20x speedup
  5. But C… – Unsafe – Risky – segfaults! – Maintenance

    burden – Contribution barrier
  6. Skylight Agent – Started with Ruby – Too much overhead

    – Native extension! – But C…
  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
  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
  9. fast_blank in Rust* * boilerplate not included

  10. fast_blank in Helix

  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
  12. Last year – Good proof-of-concept – Too hard to use

    – Missing basic features
  13. This year – Deploy to production – Polish, documentation –

    Features – Focus on Rails
  14. Demo! – End-to-end example – Deploy to Heroku – It

    works!™
  15. ▶ http://chancancode.tv/helix

  16. Good use cases – CPU-bound – Simple inputs – Avoid

    chatty APIs
  17. Good use cases

  18. Good use cases – Use Rust libraries – Leverage Rust

    web browser tech – Mailer, Background job, Action Cable
  19. None
  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
  21. usehelix.com