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?
Re:Lispy view
chromatic on 2007-07-27T17:57:38
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.)
The above is perfectly legal Ruby code.There once was a programmer of Ruby
Re:No Symbols Needed
chromatic on 2007-07-28T00:10:41
It's also valid Perl code, so obviously it can't be a DSL. (Psst, your roots are showing.)
Re:No Symbols Needed
Aristotle on 2007-07-28T01:14:21
“I know it’s weird, but it does make it easier to write poetry in perl.
:-)” —Larry Wall Re:No Symbols Needed
djberg96 on 2007-07-28T16:48:51
Says who? That's never been a condition of a DSL.Re:No Symbols Needed
chromatic on 2007-07-28T17:48:39
However, Perl is not really capable of DSLs...Cosine Jeremiah, Back to Perl.
You and I discussed that very phrase in my previous journal entry.
Re:External Reply
chromatic on 2007-08-05T23:54:56
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 unmodifiedeval
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 interpret than Perl is", which is a tautology.
I don't think that's your point... is it?