News for hackers. Stuff that matters.
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by extension on Tuesday August 03, 2010 @01:12PM (#1571875)
In Java, I would do this:

  new Search().equal(Search.NAME,"Joe")
              .between(Search.AGE,18,25)
              .go();
Just as concise with less voodoo. And it's a single statement.

With the existing method, you can still ditch the empty parens by using public final fields. You just have to pre-populate them all with respective grammar objects.

Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by pgr0ss on Tuesday August 03, 2010 @01:31PM (#1571944)
Your syntax is definitely simpler. One reason we did it the way we did was to get compiler checking for operators. We've tried to follow idioms in different client libraries, and for the statically compiled languages, we've tried to make it so if it compiles, it will work.

Since the field comes first (orderId().startsWith()), if you try to call an operator on a field that does not support it, it will not compile.

Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by supersillyus on Tuesday August 03, 2010 @01:51PM (#1572012)
You should make it clearer in the commentary that you're holding the static languages to a higher standard.