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

"There's one huge difference between Cascalog and Linq: Linq is part of C#. You can't define Linq in terms of regular C#"

So, the code snippets in this article aren't written in Clojure, but instead in some other custom language? I dont know Clojure, but those examples look very much like that crazy foreign Lisp 'nested parenthesis talk' to me.



The code snippets are Clojure, but that's the point. Nothing was added to the Clojure language itself in order for this to be possible. Linq would not have been possible (in it's current form anyway) without adding new features to the C# language itself.


Flippant response: you're saying that nothing was added to Closure in order for some Closure code to get written? This is not unprecedented.

Seriously - I don't see what's unusual about the syntax of these examples that makes them a DSL that doesn't just look like clojure code.

If my Linq implementation is allowed to resemble the language for which it is implemented, then I can easily write a 'Linq' implementation in plain C# that will look just like plain C#. (Although I grant that LINQ refers to the syntax additions to C# and not just the library)

Not hugely worked up about this, just feeling a little 'Emperors New Clothes' about it.


The point wasn't to make it not look like Clojure, the point was to express querying constructs in a way that's natural to the language. This isn't impossible in any language and is actually fairly common within the domain (e.g. SQLAlchemy for Python works similarly though operator overloading).

The point he's trying to make is that the default way of doing things in a lisp is to adjust the language constructs to fit the domain of the problem. This (generally) results in a simpler mental model of the problem domain and less code. It's not a about being ABLE to do it. You can do something similar in most languages, but there it's just not as easy, not the default, and not as flexible.


You might be right, but if so it sounds like the talk of Linq, and syntax, and 'DSL's served to obscure his actual point, which is a shame.

Guys, honestly, downvote if it makes you feel better.


Here's the "LINQ" of Common Lisp, which may look "different" enough to convince you:

http://www.unixuser.org/~euske/doc/cl/loop.html

(It could be implemented identically in Clojure, if you cared to.)


Thanks. To my untrained eye that looks more like it could be called a DSL than the article, where mostly it's just creative whitespace formatting, as far as I can tell. What's going on with the underlining?


Re: the underlining -- no idea, just an instructional aid, I guess.

Here's another example that might look "DSLy": http://www.brool.com/index.php/pattern-matching-in-clojure

The pattern matching macro "match" is written entirely in Clojure, without any compiler tricks. I wish I could do the same in C#! (I'd need to have a bunch of cruft defining a predicate object with options for each match criterion.)

All of these techniques boil down to how easy it is to do two things in a language:

- To write DSL code in your structure of choice without having to cover it in a huge amount of syntax goop, e.g. the loop macro or the magic LINQ syntax.

- To analyze and transform that DSL code programmatically, in a way that's more structured than simple string manipulation, so that you can do the right thing with it.

C# 2.0 was very bad at both of these. C# 3.0 improved a lot, by adding lambda expressions for the first, and allowing you to analyze C# expressions as a syntax tree. But Clojure (& Lisp in general) is really good at both.


The snippets are Clojure code that use the Cascalog library. Cascalog has the look and feel of an embedded language.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: