r/ruby • • 15h ago

Call Things What They Are

Thumbnail
saturnci.com
54 Upvotes

r/ruby • • 12h ago

Phlex 3 Beta is out with a specialised Ruby-to-Ruby JIT for components

16 Upvotes

We just released the first beta of Phlex 3, which includes a special Ruby-to-Ruby just-in-time compiler, allowing us to optimise performance far beyond what’s possible at runtime.

The compiler starts from what’s actually loaded. It asks each component’s live methods where they were defined, parses those files with Prism and turns them into a syntax tree.

Then it walks the tree and decides what each call really means by asking the running program: is div still Phlex’s div, or has someone overridden it, refined it or mixed something over it? Is that constant still the string it was? Each call we can prove is ours is replaced with a node that just appends text. Everything else is left as it was.

Next comes fusing: neighbouring appends merge, so a run of static elements becomes a single string, escaped and serialised once.

Finally, the tree is formatted back into Ruby, with a source map so that errors point to your original file and line, and this is evaluated in place of the original methods.

I posted more details including some micro benchmark results. You can also see the full release notes on GitHub.

I don’t know if this is going to work or if we’re going to discover some new edge case we hadn’t thought of, but it looks promising so far and it’s been running in production with 465 components for over 24 hours without any issues.


r/ruby • • 5h ago

Blog post Start with one server, even if you plan to take over the world

Thumbnail
widefix.com
2 Upvotes

A lesson from maintaining legacy Ruby on Rails apps.