2010-10-14

list comprehension

2010-09-25

On Sep 24, 12:44 pm, namekuseijin wrote:
> On 22 set, 18:57, Xah Lee wrote:
>
> > gossip, Guy Steel, Lojban, Racket
>
> We know the man is made of steel, but it's actually "Steele"... :)
>
> > ----------
> > A classic piece of mockery of Guido by Schemers
>
> > • 〈The Fate of Lambda in Python 3000 and Scheme v300〉http://xahlee.org/comp/the_fate_of_lambda.html
>
> This is really old news, but in the case of Krishnamurthi's april
> fool's reply in the form of mockery of the alleged mockery by Guido:
>
> "We think dropping FILTER and MAP is pretty uncontroversial; (filter P
> S) is almost always written clearer as a DO loop (plus the LAMBDA is
> slower than the loop). Even more so for (map F S). In all cases,
> writing the equivalent imperative program is clearly beneficial."
>
> it just doesn't follow even as mockery, because of 3 things:
> 1) it assumes list comprehensions in python are imperative programming
> 2) it assumes do loops in scheme are imperative programming
> 3) it assumes do in scheme is the equivalent of list comprehensions in
> python

remember, a mockery does not mean it has to mirror every sentence with some consistent logic.

of course your are trolling, but your list above is questionable to me.

> 1) it assumes list comprehensions in python are imperative programming

i'd go as far to say that “list comprehension” in every lang is imperative programing.

for some explanation of “list comprehension” and several examples in different langs, see:
http://en.wikipedia.org/wiki/List_comprehension

the python example is given as:

S = [2*x for x in range(101) if x**2 > 3]

(see also:
• 〈Perl-Python Tutorial: List Comprehension〉
http://xahlee.org/perl-python/list_comprehension.html
)

you see, one characteristic of functional programing lang is that the lang has lots of single-purpose functions, and the user is supposed to sequence or combine them for max power and flexibility.

lisp comprehension is a fucking anomaly in this regards.
i dunno which fucking idiot invented it. (those expert with its history, please post)

from looking at the Wikipedia examples, you can see that typically it invents a new syntax. A better way and more in sync with functional lang spirit, is simply have this instead:

operation(
filterFunction(
listGenFunction(1, 20),
trueFalseDecisionFunction()
)
)

or in Mathematica:

Select[Range@20, # > 3 &]^2

in Mathematica FullForm notation, the above is:

Times[
Select[
Range[20],
Function[
Greater[ Slot[1],3] ]
],
2]

(formatted in a way so lispers can understand)

in my style of coding, the above is typically written like this:

(#*2 &) @ (Select[#,# > 3 &]&) @ Range@20


See also: • 〈A Example of Mathematica Notation and List Processing〉
http://xahlee.org/UnixResource_dir/writ/notations_mma.html

> 2) it assumes do loops in scheme are imperative programming

Of course it is. Look at the big picture. “Do loop” in any lang is arguably imperative.

> Schemers are a pretty desunited group.  Many in the Racket group don't
> go along with other implementors, like the guy who proposed for a
> previous RNRS the DO macro as a shortcut for a named let.  DO is no
> more of a imperative artifact than a named LET because it is a named
> let, which in turn is just a function call with more conveniently
> placed bindings.  But thanks to lame politics, it's got bad rap.
>
> Plus, Guido wasn't mocking, he was being pragmatic and many of his
> points were valid points, like the fact that tail-recursion makes for
> lame debugging.

From a few articles i read of Guido, it's pretty clear to everyone he does not have sufficient experience in functional programing to criticize it.

basically, his article on wanting to chop lambda pretty much just says “i don't grok functional notations, i prefer syntax that contain hints telling me what it does”.

> Lisp guys should hear most complaints and fix whatever perceived bad
> lisp lisp got.  Reducing parenthesis usage

yes but not by special case syntaxes. Either stick with the existing 99% regular paren syntax, or create a sysematic M-expression transformation, such as Mathematica.

> and reducing long abstract
> names of functions like "call-with-current-continuation" or "sqlite-
> query/effect-set" would be a beginning (and renaming such aberrations
> in an import was a welcome addition of R6RS), as would be providing
> automatic function dispatch on type of arguments so we could get far
> shorter function names thanks to function overloading -- make-
> datatypefoo, length-datatypefoo, read-datatypefoo is not really
> acceptable anymore in this day and age... why not simply (length foo),
> (read foo) etc?
>
> Also, something C headers just beats all languages out there:
> function prototypes.  You read them, you know what types get in and
> what types get out.  You open a Scheme R6RS lib and you see a name in
> the export list, then you need to dig for it in the source to figure
> out the parameters and try to guess what it does by peeking at the
> code... java is another stinker which decided to get rid of function
> prototypes, but at least it provides plenty of automatic IDE tools to
> do the digging for you and report the prototypes right in your nose...

Scheme lisp disappointed me very much. I don't think i'll have anything to do with Scheme again in my life, and i don't think it'll go anywhere by a iota. Maybe the Racket with the name change will go somewhere, but i think in a blink of eye i'd hop onto Clojure, newLISP, OCaml, F#, Ruby, Q/Pure, Erlang, Haskell, then i'd touch Scheme again. Currently, the ones i really want to have some serious working knowledge is OCaml/F#, for my math, theorem proving, geometry visualization, related tasks...

• 〈Language, Purity, Cult, and Deception〉
http://xahlee.org/UnixResource_dir/writ/lang_purity_cult_deception.html

plain text version follows.
--------------------------------------------------
Language, Purity, Cult, and Deception

Xah Lee, 2009-01-24

[this essay is roughly a 10 years personal retrospect of some languages, in particular Scheme and Haskell.]

I learned far more Ocaml in the past 2 days than the fucking 2 months i tried to learn Haskell, with 10 years of “I WANT TO BELIEVE” in haskell.

The Haskell's problem is similar to Scheme lisp, being academic and of little industrial involvement. About 10 years ago, during the dot com era around 1999, where scripting war was going on (Perl, tcl, Applescript, Userland Frontier, with in the corner Python, Ruby, Icon, Scheme, in the air of Java, HTML 3, CSS, CGI, javascript), i was sold a lie by Scheme lisp. Scheme, has a aura of elegance and minimalism that's one hundred miles in radius. I have always been a advocate of functional programing, with a heart for formal methods. Scheme, being a academic functional lang, has such a association. At the time, Open Source and Linux have just arrived on the scene in uproars, along with Apache & Perl. The Larry Wall scumbag and Eric Raymond fuckface and Linus T moron and Richard Stallman often appear in interviews in mainstream media. Richard Stallman's FSF with its GNU, is quick to make sure he's not forgotten, by a campaign on naming of Linux to GNU/Linux. FSF announced that Scheme is its chosen scripting lang for GNU system. Plans and visions of Guile — the new Scheme implementation, is that due to Scheme Lisp's power will have lang conversion abilities on the fly so programers can code in any lang anywhere in the GNU OS — like today's Microsoft “.NET”. Around that time, i also wholeheartedly subscribed to some A Brave Gnu World bulletin of FSF with high expectations.

Now, it's 2009. Ten years have passed. Guile disappeared into oblivion. Scheme is tail recursing in some unknown desert. PHP, one of the ugly kludge pidgin, practically and quietly surpassed the huckstered Perl in early 2000s to become the top 5 languages. (remember? Larry Wall scumbag said P is for “Practical”. PHP's got two “P”s.) Python has surfaced to became a mainstream. Ruby is the new hipster on the block. Where is Scheme? O, you can still hear these idiots continuationing tail recursions among themselves in newsgroups. Tail recursion! Tail recursion! And their standard the R6RS in 2007, by their own consensus, is one fucked up shit.

In 2000, i was a fair expert of unix technologies. Sys admin to several data center's solaris boxes each costing 40 grands. Master of Mathematica and Perl but don't know much about any other lang or langs in general. Today, i am a expert of about 5 languages and working experience with tens or so diverse ones. There is nothing in Scheme i'd consider elegant, not remotely, even if we only consider R4RS.

Scheme, like other langs with a cult, sold me a lie that lasted 10 years. Similarly, Haskell fucked me with a lure of “no assignment”. You can try to learn the lang for years and all you'll learn is that there's something called currying and monad.

In 2005, i spent a year to learn Python. Perl is known for its intentional egregious lies, lead by the demagogue Larry Wall. It fell apart unable to sustain its “post-modernistic” sophistry. To me, Python have always seemed a antidote to Perl, until you walked in. You learned that the community is also culty, and is into certain grand visions on beauty & elegance with its increasingly complex syntax soup with backward incompatible python 3.0. The python fuckheads sport the air of “computer science R us”, but their intelligence is about the same level of Perl monger idiots. (Schemers and Haskell book authors at least know what they are talking about. They are just ignorant outside of academia.)

I think my story can teach tech geekers something. In my experience, the langs that are truely a joy to learn and use, are those sans a cult. Mathematica, javascript, PHP, are all extremely a joy to use. Anything you want to do or learn how to do, in so far that the lang is suitable, can be done quickly. Their docs are to the point. And today i have to include Ocaml. It's not about whether the lang is functional, or whether the lang is elegant, or what theoretical advantage it has. Also, lang of strong academic background such as Scheme and Haskell are likely to stay forever there, regardless what is the technical nature of the lang. The background of the community, makes half what the language is.

The above is not a terrible insight, but i suppose it should be useful for some application. Today, there's huge number of languages, each screaming ME! To name a few that are bubbled up by tech geekers: Arc, Clojure, Scalar, F#, Erlang, Ruby, Groovy, Python 3, Perl6. (for a big list, see: Proliferation of Computing Languages) So, if i want to learn another lang down the road, and wish it to be a joy to use, usable docs, large number of usable libraries, well supported, a community that is not looping eternally around estheticalities, then which one should i buy? I think Erlang, OCaml/F#, would be safe choices, while langs like Qi, Oz, Arc, Perl6, would be most questionable.

Disclaimer: All mentions of real persons are opinion only.Related:

Xah ∑ xahlee.org ☄

No comments:

Post a Comment