File diff: [root]/code @ 1c4688c5151 | log | faq | css

diff --git a/code/dsls-suck b/code/dsls-suck
new file mode 100644
index 0000000..38e0865
-- /dev/null
++ b/code/dsls-suck
@@ -0,0 +1,52 @@
h1. 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.

h2. 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.

bc. 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":delimiters_must_die! 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.

h2. Examples

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

bc.. 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

p. 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.

h2. Alternatives

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

bc. 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.

h2. 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.
\ No newline at end of file

By Voker57 on 2011-03-02 01:29:28 +0300 Powered by bitcheese wiki engine