Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java
by icode on Tuesday August 03, 2010 @02:40PM
(#1572185)
Why dont they just take a string as the argument to search() and parse it? They could use a very SQL like Syntax:
[ Parent
| on HN ]
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java
by rndmcnlly0 on Tuesday August 03, 2010 @03:37PM
(#1572444)
One of the big reasons to build the DSL in the first place is to let the host language's syntax help you spot problems in your query. Syntax errors can be spotted from editor-provided syntax highlighting directly or slightly later when the code is read by the interpreter -- much sooner than when your runtime library finally decides to look at it (at search time).
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java
by st0p on Tuesday August 03, 2010 @04:09PM
(#1572579)
Yeah, i've never done any research into DSL's, but I always thought they would have some sort of custom syntax. Since DSL's seem quite the hype ATM, I'm a bit dissapointed by these examples. Sure, nice coding and all that (even though I would have used LINQ myself, but then again I'm not restricted to C# 2.0), but I fail to to see where the L of DSL comes into play.
If this is the latest hype I didn't have time for to research, I'm not missing out.
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java
by Lewisham on Tuesday August 03, 2010 @11:57PM
(#1573605)
There are two types of DSLs, internal and external. External ones are the custom syntax you talk of, internal are DSLs that use features or quirks of a host language to appear different.
XML or SQL are external DSLs, much of the cool Ruby stuff like Rake and Rails are internal DSLs. The examples presented are all internal (presumably for a good reason). There are advantages to both approaches. Read Martin Fowler's discussion at http://martinfowler.com/dslwip/
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java
by JadeNB on Wednesday August 04, 2010 @01:10AM
(#1573706)
Dan Bernstein argues that the most bug-prone part of a user-facing program is usually its parsing: see (5) of http://cr.yp.to/qmail/guarantee.html. chromatic summarises this as “Don't parse that string!” (http://www.modernperlbooks.com/mt/2010/07/dont-parse-that-st...).