Page: [root]/code/dsls-suck | src | faq | css

DSLs suck

DSL is for Domain Specific Language. But does every domain needs its own language?

Rarely. DSLs are mostly invented because people are too lazy to use available tools and/or plagued with NIH syndrome.

What's so bad about DSLs?

Their poor quality as programming languages. DSLs are mostly created in haphazard fashion. First, some moron decides that instead of using YAML, .ini or even XML (because this will bloat his program so much that his suckless friends will turn away from him), he will just throw together some kind of key-value config parser.

mycoolvalue 2
mycoolstring wtf

Nice and cuddly, as all the small things are. Then he needs value names with spaces and strings with newlines. Welcome to escaping hell! Then he thinks that he needs to reuse values in other values, so he throws together interpolation, using some silly character like ^. Seriously, who's ever going to use it in string. And if he does, we can escape it...

Then he needs cycles, then variables, then functions, and we have a crappy reimplementation of PHP. That's what called DSL.


Here's a config for FDM. I copied it over, changed some vars and not touching it anymore.

set maximum-size 127M

action "inbox" mbox "%h/mail/inbox"

account "pop3s" pop3s server "" port 995
	user "" pass "pass"

match all action "inbox"
match "From:.*bob@idiot\\.net" action drop

This piece of shit contains examples of most DSL failures. Bizarre interpolation, strings with custom escaping, crappy variables. Pathetic excuse of a language.

The other well-known DSL is SQL. If you think it does not suck, try inserting a binary value in a table. Then write some logic for stored procedures.


EDSLs. This is like DSL, only with real programming language. Here's an example in Ruby, that's from Merb request router:

 match('/wiki/diff/:sha/:pagename', :pagename => /.*/, :sha => /[a-f0-9]+/).to(:controller => :page_diffs, :action => :showpagediff).name(:showpagediff)
match('/wiki/diff/:sha', :sha => /[a-f0-9]+/).to(:controller => :page_diffs, :action => :showdiff).name(:showdiff)
match('/wiki/src/:pagename', :pagename => /.*/).to(:controller => :wiki_pages, :action => :src).name('articles_src')

Clean, human-readable, absolutely standard. Other good (and more embeddable) languages exist, like Lua.

In most cases, you don't even need a full-fledged programming language. You can use a declarative one, like YAML, which even has substitution and few other useful tricks. You can use JSON, INI, or even XML, just for fuck's sake, don't write your own DSL. Please.

Things that do it right way

XMonad: it uses Haskell as its config language.
ion3), awesome use Lua for configs.
MongoDB uses BSON for its API and JavaScript for DB-side logic.

Powered by bitcheese wiki engine