Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

chromatic (983)

  (email not shown publicly)

Blog Information [] Profile for chr0matic []

Journal of chromatic (983)

Friday July 27, 2007
11:31 AM

A Domain Specific Language For Writing Dirty Limericks

[ #33898 ]

I wrote a domain-specific language for writing dirty limericks. It looks a lot like English, but you have to prefix rhyming words with colons. Otherwise, it's a completely new language, so please read my weblog and buy my book and come to my conference talk about how awesome I am for doing what everyone does every day with English: use it as intended.

:There :once :was :a :programmer :of :Ruby...

Here's more joy on my least favorite subject Ruby programmers can talk about these days:

I meant to suggest in my previous post that the flaw was in me for no longer thinking in Perl when using Perl, though at the same time if Perl were to better support DSLs (domain specific languages) then I would have gotten a Get-Out-of-Jail-Free Card despite my mis-think. I hope that others reading this benefit from the clarification as well.

  Cosine Jeremiah, Knowing Ruby and Perl

Cosine, if you post yet another followup, please explain precisely what in the world you possibly mean by "better support DSLs" and perhaps even "DSL" in general.

Why do I ask this?

Cosine uses the example of Ruby's OO primitives and pervasive use of blocks to change the behavior of a Hash instance... and claims somehow that this makes a building block of a domain-specific language.

This baffles me.

When you find yourself starting to think "HAI I JUST WRITEDS A DSLS!!!", stop. You are not a Big Man who has performed the Manly Deed Akin to Dragon-Slaying and Princess Rescuing by defining your own language which just magically happens to have exactly the same syntax as Ruby and the same semantics of Ruby. YOU JUST CHOSE IDENTIFIER NAMES THAT MADE SENSE FOR YOUR PROBLEM DOMAIN.

Now that is a reasonable and honorable and well-maintainable thing to do, and I congratulate all of the Ruby developers (and Perl developer and Java developers and PHP developers and C developers and Haskell developers and you get the picture that just about every language that allows you to choose meaningful identifiers supports choosing meaningful identifiers while keeping the syntax and semantics of the language unchanged) for that.

Now can we all stop this wankery over "My language lets me do made-up thing that doesn't actually have any defining characteristics that I can't figure out how to do in your language" and actually have a conversation about how to write maintainable programs and devise good APIs?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Considering this, if Lisp claims to be great at doing DSLs, I suppose it is because it has macros to allow custom flow control. The rest is all just identifiers.

    I've heard that the Ruby folks like to inject methods into base classes to let them talk about collections using their domain's terminology as methods directly on the data. This seems to just be another riff on derived types but perhaps without bothering to actually declare the new type. I guess the idea is instead of making your new type be a speci
    • Considering this, if Lisp claims to be great at doing DSLs, I suppose it is because it has macros to allow custom flow control. The rest is all just identifiers.

      Lisp is the Henry Ford of language design: you can have any syntax and semantics you want, as long as they're s-expressions.

      (You could generalize that to internal DSLs too. I'm just waiting for the right time to show all of the "HAI I WRITED U A DSL!!!!!" kiddies the attributes of P5NCI or source filters in Perl.)

  • There once was a programmer of Ruby
    The above is perfectly legal Ruby code.
  • ...but seriously, when is Perl getting better metaprogramming and DSL support? It doesn't even have symbols or procs, so you can't create custom yield types or assignment methods, which are all vital to any good domain solution.

    I really want a Perl way to strip the cuss words from bbmarkup comments in my blog, but without a DSL for the task, I'm going to have to use Ruby. Or maybe Erlang, I hear that's hot now, too.
    • I appreciate the reply, but you still didn't answer the question. What is a DSL?

      "A little language that you can run through your host language's eval" is not an acceptable answer, because the only thing you can successfully run through your host language's unmodified eval is precisely that language itself.

      If that's the case, then your statement that "Ruby is better at writing DSLs" is particularly meaningless, because it simplifies to "Ruby is better at writing Ruby code that the Ruby interpreter can