Lisp refactoring puzzle
xahlee at gmail.com
Tue Jul 12 05:37:30 CEST 2011
On Jul 11, 6:51 am, jvt <vincent.to... at gmail.com> wrote:
> I might as well toss my two cents in here. Xah, I don't believe that
> the functional programming idiom demands that we construct our entire
> program out of compositions and other combinators without ever naming
> anything. That is much more the province of so-called "function-
> level" programming languages like APL/J and to a more limited extent
> concatenative languages where data (but not code) is mostly left
> without names.
> Functional programming, in my mind, is about identifying reproducibly
> useful abstractions, _naming them_, and constructing other
> abstractions from them. Your piece of code above probably needs to be
> factored out into named pieces so that the composition is more
> sensible. If a piece of code isn't comprehensible, it might be
> because it isn't using the right abstractions in the right way, not
> because the notion of functional programming is itself problematic.
> One might instead provide a nightmare nest of procedural code and
> claim that procedural programming has problems. Of course, this
> particular kind of problem might be less common in procedural code,
> since it depends heavily on naming and side effecting values, but it
> isn't hard to find procedural code with a long list of operations and
> namings wherein the chose names are random or otherwise unrelated to
> the problem domain. My adviser in grad school used to name variables
> after pieces of furniture in dutch, but that didn't cause me to
> impeach the _notion_ of procedural code.
of course, you are right. But i wasn't criticising functional
programing in anyway.
was just putting out my tale as a caution, to those of us — e.g.
academic scheme lispers and haskell types — who are perpetually
mangling their code for the ultimate elegant constructs.
but speaking on this now... as you guys may know, i was a naive master
of Mathematica while being absolute illiterate in computer science or
any other lang. (see 〈Xah Lee's Computing Experience (Impression Of
Lisp from Mathematica)〉 @ http://xahlee.org/PageTwo_dir/Personal_dir/xah_comp_exp.html
) When i didn't know anything about lisp, i thought lisp would be
similar, or even better, as a highlevel lang in comparison to
Mathematica. In retrospect now, i was totally wrong.
lisp, or scheme lisp, is a magnitude more highlevel in comparison to C
or C derivatives such as C++, Java. However, in comparison to
Mathematica, it's one magnitude low level. (it pains me to see lisp
experts here talking about cons and macros all day, even bigshot names
such as one Paul Graham and in lisp books praising lisp macros. Quite
over the years, i had curiosity whether perhaps ML/OCaml, Haskell,
would be equivalent high-level as Mathematica as i thought.
Unfortunately, my study of them didn't went far. (best result is my
incomplete 〈OCaml Tutorial〉 @ http://xahlee.org/ocaml/ocaml.html ) Am
not qualified to comment on this, but i think that even Haskell,
OCaml, are still quite low in comparison to Mathematica.
it's funny, in all these supposedly modern high-level langs, they
don't provide even simple list manipulation functions such as union,
intersection, and the like. Not in perl, not in python, not in lisps.
(sure, lib exists, but it's a ride in the wild) It's really
exceedingly curious to me. And it seems that lang authors or its
users, have all sorts of execuse or debate about whether those should
be builtin if you force them to answer. (i.e. they don't get it)
While, we see here regularly questions about implementing union etc
with follow up of wild answers and re-invention the thousandth time.
Of course, Mathematica has Union, Intersection, and a host of others
some 20 years ago, and today it has a complete set of combinatorics
functions as *builtin* functions (as opposed to add-on libs of second-
rate quality). (this is not a question. No need to suggest some
possible reasons why lang might not want to have a whole set of list
manipulation builtin. You (the lisper/python/perl regulars and other
lang fans) are a complete idiot, that's what i'm saying. COMPLETE
IDIOT. (actually, this is not surprising, since genius and true
thinkers are rare and few. (such as myself. As they say, beyond the
i also wondered, if Mathematica is truely a magnitude higher level
than lisp, why we don't see any computer scientists talk about it? (of
course there are, but almost non-existant in comparison to, say,
academic publications on Scheme, Haskell, even Java) I think the
reason is social, again. Proprietary langs isn't a revue of
academicians, together with the fact that Stephen Wolfram goes about
as if the entire science of computer science comprises of himself.
Want Mathematica? Pay $2k+.
recently i spent several days studying and watching a talk by Douglas
Crockford. it is incredible. He went thru history, and explained, how
it is the very people in computing community who laughed and stifled
all the great innovations in computing (e.g. innovations in computer
languages). Many of these innovations we enjoy today (e.g web) took
few decades to finally be accepted (usually in a inferior form (and he
showed, how the web came to be thru Tim, and Mosaic etc folks, and
geeker's loud cries of pain about how things “should” be. e.g. Tim
ignored SGML folk's cries. Mosaic added the image tag, ignoring Tim's
cries. …)). These people, i call tech geekers. (e.g. as we witness
here recently, where lisper idiots siging the tunes of cons — a
concept based on hardware that's obsolete for like 30 years.) Douglas
Crockford gave many examples thru-out his lectures.
i had similar impressions about how new tech is always sneered upon
first by the very people of that field (e.g. cookies, js, web email,
blogs, instant messaging, and in recent years youtube, twitter,
facebook), and old habit really are impossible to die. Progress on
comp lang is exceedingly slow, usually in the form of tiny
improvements (think of the C C++ Java C# C-go spanning 40 years of
minor tweaks, or think of acceptance of functional programing langs).
(Douglas says it take a generation to swap people out) For example,
lisp cons business, computer language formatting, 80 char line
truncation business, unix line truncation business, netquette issues,
RFC idiocies and RFC idolization, unix philosphy shit, emacs meta key
and UI gospels …. (you can read bout my take here: 〈Computing ＆ its
People〉 http://xahlee.org/Periodic_dosage_dir/skami_prosa.html )
watch the first episode of Douglas Crockford's talk here:
it's a hour and 42 minutes, worth every minute. There are 5 more.
More information about the Python-list