Forum: Ruby Can Anyone Recommend A Good DSL Book?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ae577905a543a759b11ce883ffd00ef6?d=identicon&s=25 Sean Mountcastle (Guest)
on 2006-03-01 16:06
(Received via mailing list)
I apologize if this has been asked on this list before (I did a quick
search using Namazu and didn't find any specific books; perhaps that's
because they don't exist):

Are there any good books on domain specific languages (preferably in
Ruby)?  I've read Fowler's article on DSLs, I attended Glenn
Vanderburg's "Metaprogramming Ruby" talk at OSCON, I also listened to
Rich Kilmer speak at a NoVARUG meeting about a DSL he wrote for the
USAF/BBN and I've listened to the recording of Domain Specific
Languages by Jim Weirich from RubyConf 2005 -- but I still don't "get"
it. It seems like black magic to me, so I'm hoping there's a book out
there devoted to implementing DSLs using Ruby that can help me better
understand this useful technique.

Does anyone know of such a book?

Many thanks in advance,
Sean
Bc6d88907ce09158581fbb9b469a35a3?d=identicon&s=25 James Britt (Guest)
on 2006-03-01 17:01
(Received via mailing list)
Sean Mountcastle wrote:
> I apologize if this has been asked on this list before (I did a quick
> search using Namazu and didn't find any specific books; perhaps that's
> because they don't exist):

It's a good question.

>
> Does anyone know of such a book?

There are some DSL articles in the pipeline for Ruby Code & Style[0], so
hopefuly they'll help you, but a more detailed book on DSLs would be
interesting.


[0] http://www.artima.com/rubycs


--
James Britt

"In physics the truth is rarely perfectly clear, and that is certainly
  universally the case in human affairs. Hence, what is not surrounded
by
  uncertainty cannot be the truth."
  - R. Feynman
Ab870531383eea6e4d9110317f5401e7?d=identicon&s=25 Caleb Clausen (Guest)
on 2006-03-01 17:33
(Received via mailing list)
Sean Mountcastle wrote:
> Are there any good books on domain specific languages (preferably in
> Ruby)?
> Does anyone know of such a book?

I would *love* to see a book about ruby DSLs. After seeing a little
about how other people design them at RubyConf, it's become clear to
me that there are quite a number of different good ways to implement
DSLs in ruby. Why this should be, I don't know. It doesn't seem to
have been a deliberate feature of the language. I know of no such
book, but I hope someone out there will consider writing one, if they
aren't already.

If it helps, you can think of a DSL as just a particularly clear and
naturalistic API.
E7559e558ececa67c40f452483b9ac8c?d=identicon&s=25 unknown (Guest)
on 2006-03-01 17:46
(Received via mailing list)
On Mar 1, 2006, at 11:01 AM, James Britt wrote:
> Sean Mountcastle wrote:
>> I apologize if this has been asked on this list before (I did a quick
>> search using Namazu and didn't find any specific books; perhaps
>> that's
>> because they don't exist):
>
> It's a good question.

You might want to read chapter 6 of The AWK Programming Language (Aho,
Kernighan, Weinberger).  The title of that chapter is 'little
languages'.
The chapter includes the following examples (in AWK of course):

	assembler and interpreter
	drawing graphs
	a sort generator
	a reverse-polish calculator
	an infix calculator
	recursive-descent parsing


Gary Wright
560c83ff6b6600e39315a1cf75b7c229?d=identicon&s=25 Tom Copeland (Guest)
on 2006-03-01 17:54
(Received via mailing list)
> 	a reverse-polish calculator
> 	an infix calculator
> 	recursive-descent parsing

Along the same lines, the O'Reilly Lex and Yacc book (by John Levine and
several others) has some little DSL examples - a menu generation system
and whatnot.

Yours,

Tom
Ae577905a543a759b11ce883ffd00ef6?d=identicon&s=25 Sean Mountcastle (Guest)
on 2006-03-01 21:31
(Received via mailing list)
Gary and Tom,

Thanks for the pointers, I've read the AW AWK Programming Language and
O'Reilly lex & yacc books.  From the presentations I've seen on Ruby
DSLs, it doesn't seem like folks are writing parsers -- it seems more
like Lisp macros where the program is being written as its being
interpreted.

In the same way that Ruby's attr_accessor creates getter/setter
methods for the specified symbols (instance variables), DSL 'gurus'
have created similar constructs which implement the 'mini language'
without the drugery of writing a parser/compiler.

It looks like there are no "How to write DSLs in Ruby" books currently
available or planned.

Regards,
Sean
Eb9493c94d8db9887e5f15284d2c767f?d=identicon&s=25 unknown (Guest)
on 2006-03-01 21:48
(Received via mailing list)
In article
<c4d54c6f0603010706w19b509dbvac479ea9552f77be@mail.gmail.com>,
Sean Mountcastle <smountcastle@gmail.com> wrote:
>it. It seems like black magic to me, so I'm hoping there's a book out
>there devoted to implementing DSLs using Ruby that can help me better
>understand this useful technique.
>
>Does anyone know of such a book?
>
>Many thanks in advance,
>Sean
>

Not a book, but I'm starting a new blog with a series of articles on how
I'm
re-visioning RHDL - A Ruby-based DSL for describing digital circuits.
HDLs
(Hardware Description Languages) are likely not familiar to folks here
so let
me give you a bit of background: HDLs such as VHDL and Verilog are used
heavily
now for designing chips.  The semantics of an HDL are mostly quite
different
from the semantics of a regular programming language; think of HDLs as
dataflow
languages  which also describe circuit structure and/or behavior.   Even
if
you're not interested in HDLs, this dataflow aspect might be interesting
for some as a method for dealing with concurrency.

I'll try to put post up at least every other day or so.  Feel free to
post
comments and questions.  I want this to eventually lead to a series of
articles and I figure this is a way of writing them and getting
immediate
feedback.  Here's the link:

http://blog.thoughtfiz.net/

Phil
E3c79c779c0b390049289cdfe7cb9705?d=identicon&s=25 Bob Hutchison (Guest)
on 2006-03-04 22:29
(Received via mailing list)
On Mar 1, 2006, at 10:06 AM, Sean Mountcastle wrote:

> it. It seems like black magic to me, so I'm hoping there's a book out
> there devoted to implementing DSLs using Ruby that can help me better
> understand this useful technique.
>
> Does anyone know of such a book?
>
> Many thanks in advance,
> Sean
>

I don't know of anything specific. Some of the lisp books, for
example Peter Seibel's book 'Practical Common Lisp' (<http://
www.gigamonkeys.com/book/> the pdf is freely available) touches on
the subject but in CL the idea is kind of fundamental so it is
sometimes not specifically named as DSL and it is all through the
book (in CL you basically program by building DSLs). Same with Paul
Graham's book 'On Lisp' <http://www.paulgraham.com/onlisp.html> also
with a freely available pdf version. Both books are excellent,
Graham's is in my short-list of Important Software Books.

In the Ruby world, the best I've read is David Black's 'Ruby for
Rails'. It isn't available yet (it is being released chapter by
chapter at Manning). It also isn't explicitly about DSLs but it is
one of the best that I've seen on the subject and discusses Rails as
a DSL.

Cheers,
Bob

----
Bob Hutchison                  -- blogs at <http://www.recursive.ca/
hutch/>
Recursive Design Inc.          -- <http://www.recursive.ca/>
Raconteur                      -- <http://www.raconteur.info/>
xampl for Ruby                 -- <http://rubyforge.org/projects/xampl/>
D8fb06dfc08a477ecb0a76ffdbff3475?d=identicon&s=25 Chiaro Scuro (chiaroscuro)
on 2006-03-04 22:35
(Received via mailing list)
On 3/1/06, Sean Mountcastle <smountcastle@gmail.com> wrote:
> Are there any good books on domain specific languages (preferably in
> Ruby)?  I've read Fowler's article on DSLs, I attended Glenn
> Vanderburg's "Metaprogramming Ruby" talk at OSCON, I also listened to
> Rich Kilmer speak at a NoVARUG meeting about a DSL he wrote for the

While it's not a DSL book, Domain Driven Design by Evans is going to
be a *very useful* read if you are going to create a DSL.

-- Chiaroscuro --
Liquid Development Blog: http://liquiddevelopment.blogspot.com
Efe70cff891d5722448a6512cfd1e1f1?d=identicon&s=25 David Bailey (dbailey7)
on 2006-04-07 21:39
Chiaro Scuro wrote:
> On 3/1/06, Sean Mountcastle <smountcastle@gmail.com> wrote:
>> Are there any good books on domain specific languages (preferably in
>> Ruby)?  I've read Fowler's article on DSLs, I attended Glenn
>> Vanderburg's "Metaprogramming Ruby" talk at OSCON, I also listened to
>> Rich Kilmer speak at a NoVARUG meeting about a DSL he wrote for the
>
> While it's not a DSL book, Domain Driven Design by Evans is going to
> be a *very useful* read if you are going to create a DSL.
>
> -- Chiaroscuro --
> Liquid Development Blog: http://liquiddevelopment.blogspot.com

On 3/20/06, James Britt <james_b@neurogami.com> wrote:
> I'm pleased to announce the publication of a new article at Ruby Code &
> Style.  Jim Freeze has written an outstanding piece on creating DSLs
> (domain-specific languages) with Ruby.
>
> Check it out!
>
> http://www.artima.com/rubycs/articles/ruby_as_dsl.html

Good stuff.  Covers all of the basics, and has clear examples of the
meta-programming needed for a DSL.  Thanks much to all involved.
A0eee794e60f2555d410b8accb674ffb?d=identicon&s=25 Les Nightingill (lazylester)
on 2006-04-07 21:50
James Britt wrote:

> "In physics the truth is rarely perfectly clear, and that is certainly
>   universally the case in human affairs. Hence, what is not surrounded
> by uncertainty cannot be the truth."
>   - R. Feynman

one too many negatives in that last sentence! (I hope!!!)
Ce8b03e5750097942c58e12b46724312?d=identicon&s=25 Giles Bowkett (Guest)
on 2006-04-07 22:19
(Received via mailing list)
Surely you're joking, Mr. Feynman!
Ff63c03fd68754adbadd2c6314646bef?d=identicon&s=25 Bill Guindon (agorilla)
on 2006-04-07 23:29
(Received via mailing list)
On 4/7/06, David Bailey <david.bailey@technologist.com> wrote:
> meta-programming needed for a DSL.  Thanks much to all involved.
>
> --
> Posted via http://www.ruby-forum.com/.

That seems strangely familiar.  Perhaps this is why?
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...

Then again, maybe not.  Wonder what the odds are.  If nothing else, we
certainly seem to agree on the article.
D23f436b8e718e80f447712cdac67083?d=identicon&s=25 Amr Malik (Guest)
on 2006-04-09 19:58
Sean Mountcastle wrote:
> I apologize if this has been asked on this list before (I did a quick
> search using Namazu and didn't find any specific books; perhaps that's
> because they don't exist):
>
> Are there any good books on domain specific languages (preferably in
> Ruby)?  I've read Fowler's article on DSLs, I attended Glenn
> Vanderburg's "Metaprogramming Ruby" talk at OSCON, I also listened to
> Rich Kilmer speak at a NoVARUG meeting about a DSL he wrote for the
> USAF/BBN and I've listened to the recording of Domain Specific
> Languages by Jim Weirich from RubyConf 2005 -- but I still don't "get"
> it. It seems like black magic to me, so I'm hoping there's a book out
> there devoted to implementing DSLs using Ruby that can help me better
> understand this useful technique.
>
> Does anyone know of such a book?
>
> Many thanks in advance,
> Sean

Its not Ruby related, but you might want to look at "Starting Forth" and
"Thinking Forth". These are classic texts, and the terminology
(buzzwords) are not the same as today, but still a pleasure to read.

Starting Forth: http://home.iae.nl/users/mhx/sf.html
Thinking Forth: http://thinking-forth.sourceforge.net/

or if you want to look at a quick DSL example, take a look at this:

http://home.iae.nl/users/mhx/sf1/sf1.html

Maybe someone can translate this example to Ruby sometime. It seems so
natural in Forth though. Its weird how sometimes largely forgotten
things still have the power to teach us :)


HTH,

Amr
This topic is locked and can not be replied to.