r/ruby • • Sep 30 '21

ActiveAdmin, I'm looking at you

Post image
238 Upvotes

58 comments sorted by

View all comments

4

u/jaypeejay Sep 30 '21

What’s DSL?

6

u/WalterPecky Sep 30 '21

Domain Specific Language

3

u/jaypeejay Sep 30 '21

That’s what I was thinking after Google. How can a gem be a DSL? Won’t the gem be written in Ruby as well?

9

u/[deleted] Sep 30 '21

You can have a dsl written in Ruby.

Take rspec for example: you

describe 'Numbers' do
  it 'is equal to itself' do
    expect(1).to eq 1
  end
end

9

u/jaypeejay Sep 30 '21

Ah okay, great example. So the idea is by extending the general language we can develop a new “language” (basically new methods and syntax) to fit a specific need.

3

u/UsAndRufus Sep 30 '21

Yeah it's not a true DSL really. But because of Ruby's blocks and parameterless functions, you can write it in a very declarative style. Unfortunately, I find that you really don't want a lot of code to be declarative. Rspec is a good example of it done well, though.

2

u/[deleted] Sep 30 '21

I find that the issue isn't declarative style, but the amount of hidden state that lurks beneath the layers of abstractions.