Udell: I’ve been checking out the
preview, and it’s definitely an eye-opener. The following
snippet does a three-way join across an XML data source and two CLR
objects. The XML data source is the content of this blog. The
objects are a dictionary of date mappings, and an array of strings.
The output is constructed as XML.
As an educational exercise, I’ve converted this to
From a functionality point of view, the two implementations are
largely equivalent (though some differences are mentioned
below). This means that the differences are primarily
syntax. In fact, the impression I got from
video is that C#'s LINQ support is largely syntactic sugar over
roughly equivalent runtime functionality. That being said,
syntax matters. Very much so. And having an SQL like
syntax is a big enabler for many folks.
Note I said “SQL like”. What in reality you
have is SQL#. In Jon’s example, I see
&& and sortby. In other
examples, I have seen ==. Not to
mention the Yoda-like “from, where, select” .
More importantly, in both Jon and my examples you are very much
aware of the data sources, with things like
Descendants and Element sprinkled
throughout the code.
Despite progress being made with var declarations,
the C# implementation still requires the developer to be more
involved with the data typing administrivia than the Ruby one
does. In particular, note the (string) in the
middle of the query.
Conversely, the Ruby implementation, the developer is more
involved in the administrative details associated with naming In
particular, note the three occurrences of |item| and
in building the XML, I had to say that one needs to get
“tags” and call the resulting XML element
“tags”. The latter could be improved with better
integration between Ruby’s XML builder and REXML.
The biggest functional difference is that I had to write the
code to find the month twice. LINQ’s implementation
could do the same, or it could add an additional map step.
While not a big deal in this particular example, it could very well
be a significant issue in larger examples.
All in all, a little competition in language design is a good
thing. Ruby would do well to study
And, of course, Perl 6 (if it ever ships) would allow third parties
to design such syntaxes for themselves.
Man your code is beautiful. Looking back at the LINQ code it’s quite obvious. In order to comprehend it, the “SQL” has to be separated into separate lines with indentation. Whereas the ruby code just flows like water...
The buzzwords of the moment: Linq for the .Net world, Ruby for the open source world. Jon Udel wrote the following example for the .Net world to show of the nice things about Linq: The following snippet does a three-way join across an XML data...
Mobile Phone As Home Computer (tags: ideas future phones usability) PyMP3Cut (tags: python mp3) SharkJumping: Podcasting Ad Insertion - Stop the Madness (tags: advertising podcasting vc startups) Sam Ruby: Ruby 1.8 vs LINQ (tags: ruby xml .net sql...
Microsoft’s LINQ is pretty cool, it allows you to address diverse data sources with the same (programmatic) query syntax. But looking over Sam Ruby’s rendition of an example in Ruby (also cool) and his comments, both versions are very...
I saw a request for some actual SOAP code, so I will try and oblige. I don’t want to publish the entire code because there’s lots of messy stuff that’s specific to eBay’s SOAP API. I’ll talk about that some other time, but for now, those details...
Programmer Intent or What you're not getting about Ruby and why it's the tits
A user named yesthatmcgurk left a comment on DotNetKicks where he/she said: I must be a complete loser, because I can’t see where Ruby is such hot shit. I’d love to read a story, “What you’re not getting about Ruby and why its the tits.” Such a...
The yoda like syntax you mention is actually how SQL server or any database parses a normal textual query. While it might be “backwards” in way of traditional select statements, to me it’s actually more intuitive. It’s like an upside down pyramid. For example, I want to get customers (from) that have the first name with “t” (where) let me get their first name’s and address (select). I feel that traditional SQL is more “yoda-like.”
I’m using US census data to look up the estimated populations of the cities and towns running elmcity hubs. The dataset is just plain old CSV (comma-separated variable), a format that’s more popular than ever thanks in part to a new...