On 03/30/2012 06:25 AM, Steve Howell wrote:
On Mar 29, 11:53 am, Devin Jeanpierre<jeanpierr...@gmail.com>  wrote:

Well, what sort of language differences make for English vs Mandarin?
Relational algebraic-style programming is useful, but definitely a
large language barrier to people that don't know any SQL. I think this
is reasonable. (It would not matter even if you gave SQL python-like
syntax, the mode of thinking is different, and for a good reason.)


I don't see any fundamental disconnect between SQL thinking and Python
thinking.

List comprehensions are very close to SQL SELECTs semantically, and
not that far off syntactically.

   [row.x for row in foo if x == 3]

   select x from foo where x = 3

which is where most people get it wrong; the SQL SELECTs statement did not specify how the machine is going to get its answer, while the Python's list comprehension explicitly specify that the machine is going to loop over foo. In most implementation of SQL with the proper indexes set up, the SELECT statement above will most likely just use its index to avoid looping over the whole foo, and the most smartest ones might notice that the result query only ever contains 3 and so just use the count of the index (I don't know if any existing SQL engine is *that* smart though).

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to