The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Rails: Not a DSL

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jeremy Voorhis

Posts: 212
Nickname: jvoorhis
Registered: Oct, 2005

Jeremy Voorhis is a Rubyist in northeast Ohio.
Rails: Not a DSL Posted: Jul 14, 2006 12:59 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jeremy Voorhis.
Original Post: Rails: Not a DSL
Feed Title: JVoorhis
Feed URL: http://feeds.feedburner.com/jvoorhis
Feed Description: JVoorhis is a Rubyist in northeast Ohio. He rambles about Ruby on Rails, development practices, other frameworks such as Django, and on other days he is just full of snark.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jeremy Voorhis
Latest Posts From JVoorhis

Advertisement

This morning, I refreshed NetNewsWire1 to see the headline Rails: Not a DSL. After clicking on the feedreader’s link, which linked to Artima, which linked to DZone, which linked to Digg, which linked to the blog with said article.

The message of the article boiled down to something like this: you can’t call everything a DSL. Sure. If you repeat any word to yourself enough times, it loses its meaning2. Well, it’s true. Rails’s expresiveness is a matter of Ruby being used the way it was meant to be used. It’s how your application and your platform interface – if you are taking advantage of a dynamic language, the two may then intertwingle and appear as an arch.

For an exampe of this style of application design, I can make Ruby’s SHA1 implementation – a method that I use frequently for password encryption and for generating unique tokens – available directly from a String object as follows.

class String
  # Returns the SHA1 digest of a +String+.
  def to_sha1
    Digest::SHA1.hexdigest self
  end
end
and call that code as follows:

password_hash = password.to_sha1 unless password_hash
This may be called throughout the application and it is easy to read. I have not, however, created an internal DSL for string encryption. If you need a label for this style of application design, call it a fluent interface, or the arch. Or just call it good design.

Finally, what separates a DSL from just good design? While I cannot provide exact criteria, I think the answer lies in the motivation for which the language-oriented tool in question was created. More specifically, was it created to solve a specific problem with a narrow scope? Was it also designed to share meaning with an expert?

An excellent example of a DSL is the Spirit parser library, which allows C++ developers to transcribe a grammar, likely created by a language or protocol expert, into executable code. While its feats are much simpler, I believe the asset compiler library I have written also qualifies as a domain-specific language because it was created to be a language-based tool that eased communication between my client – a domain expert in image processing – and my application, transcribing their requirements almost directly into Ruby. It is worth noting that my work rarely involves creating or even using DSLs; they are just another tool at my disposal, especially when solving a specific problem that requires communication with experts.

1 Yes, it is still my mainstay feedreader.

2 In my experience, the word “each” is very susceptible.

Read: Rails: Not a DSL

Topic: Selenium Previous Topic   Next Topic Topic: Linux, realpath, suckage

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use