Mature Poets Steal

chromatic on 2008-01-11T00:07:24

Some people were asking for a way to change table schemas easily, so I came up with a DSL for doing that, so you can do stuff like:

alter_table :items
  add_column :name, :text, :unique => true
  drop_column :category
end

And Sequel will generate the correct SQL for you.

Sequel Interview with Sharon Rosner (emphasis mine)

For a second that looked a lot like another language I knew, and then I looked more closely. Silly me. Those leading colons make all the difference.


hmm

TeeJay on 2008-01-17T18:16:43

looking at that, I think I'd rather use XML as in Torque (http://www.jajakarta.org/turbine/en/turbine/torque/user-guide.html)
.

Well?

djberg96 on 2008-01-19T05:14:24

I can see from Piers Cawley that Perl is capable of writing good pidgin notation.

Here's an idea. Instead of complaining about Ruby DSL's 24/7, show us how to write one in Perl.

Re:Well?

chromatic on 2008-01-19T06:04:53

Instead of complaining about Ruby DSL's 24/7...

Exaggerate much?

... show us how to write one in Perl.

I'll do you one better. Take off the leading colons, turn end into a semicolon, and HEY LOOK IT'S SQL WITH SIGILS.

Sharon merely uglified an existing, perfectly working DSL. Some invention.

Re:Well?

pdcawley on 2008-01-20T04:28:28

Yeah, but at least it's not just passing a string to sql.execute or whatever, so ruby gets a chance to complain before the database does.

Nah... not exactly compelling as arguments go is it?

Re:Well?

chromatic on 2008-01-20T07:59:45

It's an advantage though, and if there's cross-database goodness hidden behind the API, that's an advantage too.

Of course, I worked on a project with something similar in 1999, and SQL was around before that, so anyone who didn't invent relational theory (or write a SQL database used by multiple people and projects) who claims to have come up with the syntax comes across as somewhat pretentious.

Re:Well?

Aristotle on 2008-01-19T06:50:45

show us how to write one in Perl.

I think chromatic’s entire point is that “DSLs” are just “APIs,” except sprinkled with a magic pixie dust that no one has the will or capacity to define, past the fact that hash keys in great quantities are involved. “I know it when I see it” seems to exhaust the substance of the difference.

So how does one reproduce something undefinable?