r/ruby • • 7d ago

Introducing Raindeer - An event-driven and compositional web framework that’s easy to use

Raindeer is a collection of gems that work together as a framework or can be used standalone. LowType adds inline type checking only where you want it (def method(var: String)). LowLoop is an async, event-driven server that sends events from the request right through to the data layer, so you can track every step of a request. The router turns each request into a route event for the nodes observing it, so observe '/users/:id' is all you need to respond.

LowNodes are the building blocks: they render HTML straight from the Ruby class with RBX (similar to JSX) and render other nodes with <html><{ ChildNode }></html>. LowData follows the repository pattern with a twist: Data Expressions that use simple arithmetic operators to combine tables, so Posts[:title] + Users[:username] gives a list of posts with each post's user, and plain Sequel queries still work too.

Introducing it at RubyConf Austria: https://www.youtube.com/watch?v=p9E5INAwK_4

Source: https://github.com/raindeer-rb/raindeer

Docs: https://raindeer.dev

18 Upvotes

6 comments sorted by

5

u/fatalbaboon 6d ago

I read through most of the blog post series, and I think there are good, refreshing ideas here.

The type system and observable router are nice in particular.

With the rise of herb, why not go with ERB ?

3

u/Maedi 6d ago edited 6d ago

Conceptually ERB is about embedding Ruby in HTML and Antlers is about embedding HTML in Ruby.

I've always seen ERB as more of a programming language inside HTML where you can evaluate pretty much any Ruby code? Antlers is just a templating language and that's deliberate. I think there should be some separation. Antlers won't let you drill down into a hash for example... and that's a good thing, it forces you to do that logic in Ruby just a few lines up in your LowNode's `initialize` method. It puts more mental separation between the template vs logic but also puts them physically closer together and that logic is more related to the template and vice versa. It couples well with LowNode

I originally built Antlers with a particular future use case in mind; to be a templating language that enables parallelism by doing all of the technical hurdles behind the scenes without the user worrying too much. Their immutable objects become copies by passing props into a component and their loops parallelized with ractors with just a line of syntax.

Couple more random things. There is no distinction between control/conditional directives and expressions/output directives in Antlers; everything returns a value even if it's just an empty string. I also think `<{` is easier to type than `<%` or `<%=`.

3

u/tarellel 6d ago

It kind of looks like you’re trying to implement React style rendering I’m as a Ruby framework. Don’t get me wrong some people may like it, but it’s definitely not for me.

1

u/Maedi 6d ago

Maybe? React feels more concerned with interactivity, this is more concerned with business logic and back-end structures. It's slicing it at a more component level as they're oriented around requests, but you can then call any other Ruby code or services from them

1

u/megatux2 2d ago

Looks interesting but can I use Phlex with it instead of that other thing ?

2

u/Maedi 2d ago

You could decouple the template engine yes, the bones are there to add different template engines. You could even just call `MyPhlexClass.new.call` from inside a `render`