Hacker Newsnew | comments | show | ask | jobs | submitlogin

I'm coming around to the view that a DSL is a thing where you have actually created a new syntax. If there is no parser, there is no DSL in sight.

Few Haskell libraries actually provide DSLs, though I can name some that do, usually very small ones, often ones where if you still desire to write the raw Haskell you can. It's just that APIs take effort to learn and use, and Haskell can use some patterns that many other languages can't, just as Ruby can use some patterns many other languages can't.

I actually think seeing DSLs where there aren't actually any is somewhat dangerous, because people's brains stop being able to abstract correctly. I have a perl "DSL" at my workplace that I wrote that I have been desperately trying to convince people is not actually a DSL, because it makes people think about it wrong. It is a way of decorating functions in such a way that I can reach the metadata and do other helpful while they can get on with their lives, and it looks like this:

    special_sub subname =>
        permission_check { $_[0]->had('some_permission') },
        xml_rpc(name => "Category.subname"),
        does {
            blah blah blah
    };
and there are various other sundry things it can do easily that would make less sense out of context. This does things like expose this function to the local XMLRPC handler, and the xml_rpc function takes in the XML-RPC-specific metadata for this case. "xml_rpc", "permission_check" (which actually has a shorter name in real life), and even "does" are actually functions that return values which do the real magic, but I have the problem where people don't understand;

    my $common_permission = permission_check { $_->[0]->has('perm') };

    special_sub sub1 => $common_permission, does {...};
    special_sub sub2 => $common_permission, does {...};
    special_sub sub3 => $common_permission, does {...};
People see the DSL magic and suddenly its like everything they knew about the base language just goes flying out the window.



Applications are open for YC Summer 2015

Guidelines | FAQ | Support | Lists | Bookmarklet | DMCA | Y Combinator | Apply | Contact

Search: