merits of Lisp vs Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Rubin

    Re: merits of Lisp vs Python

    Jon Harrop <jon@ffconsulta ncy.comwrites:
    I discovered this recently with F#. Although F# (as a dialect of OCaml) is
    impure like Lisp, it does make purely functional programming easy and
    provides many purely functional data structures. I translated 15kLOC of
    mostly-functional OCaml code into F# and only had to add four locks to make
    the whole library concurrent.
    The idea of the composable-STM stuff is to not add locks at all, just
    mark sections as atomic and the right stuff happens automagically
    (i.e. you never have to worry about deadlock), including when you nest
    such sections. Its performance also exceeds traditional locking. But
    it relies on Haskell's purity.

    Comment

    • Jon Harrop

      Re: merits of Lisp vs Python

      Paul Rubin wrote:
      Jon Harrop <jon@ffconsulta ncy.comwrites:
      ># cond 2
      > [( = ) 1, "one";
      > ( = ) 2, "two";
      > ( = ) 3, "three"]
      > "neither one, two nor three";;
      >- : string = "two"
      >
      I'm missing something. Doesn't Ocaml have strict evaluation?
      Yes.
      That means if you use function calls instead of string constants in those
      values, they all get called.
      True.
      You haven't really done what cond does.
      Good point. How about this:

      # let rec cond x rules default = match rules with
      | [] -default
      | f :: t -match f x with
      | Some e -e
      | None -cond x t default;;
      val cond : 'a -('a -'b option) list -'b -'b = <fun>

      # cond 2
      [(fun n -if n=1 then Some "one" else None);
      (fun n -if n=2 then Some "two" else None);
      (fun n -if n=3 then Some "three" else None)]
      "neither one, two nor three";;
      - : string = "two"

      The 'Some "one"' is only called if its predicate matched. Anyway, you don't
      need macros to write COND and you don't need COND if you have pattern
      matching.

      --
      Dr Jon D Harrop, Flying Frog Consultancy
      Objective CAML for Scientists
      Business Das perfekte Beratungsgespräch: Tipps und Tricks Sabine Henschel4. Juli 2024 Business Mindset Coach: Ihr Schlüssel zu einem neuen Denken Sabine Henschel4. Juli 2024 Familie Kollegiale Beratung in der Pflege: Zusammen stark Sabine Henschel3. Juli 2024 Familie Was kostet eine Beratung beim Notar wegen Erbrecht: Ein Ratgeber Sabine Henschel2. Juli 2024 Business Was kostet eine

      Comment

      • Jon Harrop

        Re: merits of Lisp vs Python

        Paul Rubin wrote:
        Jon Harrop <jon@ffconsulta ncy.comwrites:
        >I discovered this recently with F#. Although F# (as a dialect of OCaml)
        >is impure like Lisp, it does make purely functional programming easy and
        >provides many purely functional data structures. I translated 15kLOC of
        >mostly-functional OCaml code into F# and only had to add four locks to
        >make the whole library concurrent.
        >
        The idea of the composable-STM stuff is to not add locks at all, just
        mark sections as atomic and the right stuff happens automagically
        (i.e. you never have to worry about deadlock), including when you nest
        such sections. Its performance also exceeds traditional locking. But
        it relies on Haskell's purity.
        Yes. My point is that I only had to add four locks in 15kLOC of F# code
        because my code was almost entirely pure. So F# is a long way towards that
        Haskell ideal whilst having many other advantages over Haskell, like
        predictable memory usage.

        --
        Dr Jon D Harrop, Flying Frog Consultancy
        Objective CAML for Scientists
        Business Das perfekte Beratungsgespräch: Tipps und Tricks Sabine Henschel4. Juli 2024 Business Mindset Coach: Ihr Schlüssel zu einem neuen Denken Sabine Henschel4. Juli 2024 Familie Kollegiale Beratung in der Pflege: Zusammen stark Sabine Henschel3. Juli 2024 Familie Was kostet eine Beratung beim Notar wegen Erbrecht: Ein Ratgeber Sabine Henschel2. Juli 2024 Business Was kostet eine

        Comment

        • Alex Mizrahi

          Re: merits of Lisp vs Python

          (message (Hello 'Paul)
          (you :wrote :on '(10 Dec 2006 00:01:34 -0800))
          (

          PRI'm not persuaded, I haven't examined his example carefully yet but it
          PRlooks like basically a reader hack. Lexical scope in Lisp means among
          PRother things lexical closures and (maybe I'm mistaken) it seemed to me
          PRAlex's example didn't supply that.

          lexical scope is pretty low-level concept that affects lot of stuff, so it
          requires lot of changes -- we are not extending a language, but build a new
          one actually.
          we'll have to create object 'lexical environment' and to query it for
          variable values instead of just using variable values: var -(query env
          'var).
          then, we'll need to make closures -- that is a pair of environment and code
          itself.
          so, it's very close to writting new interpreter -- but it's order of
          magnitude easier to write this interpreter via macros than from scratch,
          most other language constructs can be reused.
          that's the point -- macros allow to implement a language with aprox. same
          syntax but different semantics relatively easily.

          PR I'm also unconvinced (so far) of his description of call/cc as a Lisp
          PRmacro but that's going to take me some head scratching.

          there is a chapter about continuations in Paul Graham's "On Lisp".

          "Common Lisp doesn't provide call/cc, but with a little extra effort we can
          do the same things as we can in Scheme. This section shows how to use macros
          to build continuations in Common Lisp programs."

          )
          (With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
          "People who lust for the Feel of keys on their fingertips (c) Inity")


          Comment

          • Paul Rubin

            Re: merits of Lisp vs Python

            Jon Harrop <jon@ffconsulta ncy.comwrites:
            Yes. My point is that I only had to add four locks in 15kLOC of F# code
            because my code was almost entirely pure.
            But that's like saying you only had to call malloc in 4 different
            places, which means dealing with freeing, buffer overruns, etc. As
            soon as you use any locks at all, you're susceptable to all the
            headaches of dealing with locks. Anyway this is turning into
            ML vs. Haskell, maybe an improvement on Lisp vs. Python but still OT.
            So F# is a long way towards that Haskell ideal whilst having many
            other advantages over Haskell, like predictable memory usage.
            F# is pretty similar to ML, right? Hmm. Haskell's memory usage
            issues stem more from laziness than purity. One could imagine a
            strict Haskell dialect that was still pure (I think ML is heading
            in that direction) but that would throw out a lot of Haskell coolness.

            Does OCaml support parallel threads at all? I mean using multiple
            cpu's simultaneously. I thought it didn't and this was one of the
            factors that got me to make the leap into Haskell.

            Comment

            • Paul Rubin

              Re: merits of Lisp vs Python

              "Alex Mizrahi" <udodenko@users .sourceforge.ne twrites:
              so, it's very close to writting new interpreter -- but it's order of
              magnitude easier to write this interpreter via macros than from scratch,
              most other language constructs can be reused.
              But now you've got an interpreter and you no longer have that Lisp
              compiler.
              there is a chapter about continuations in Paul Graham's "On Lisp".
              >
              "Common Lisp doesn't provide call/cc, but with a little extra effort we can
              do the same things as we can in Scheme. This section shows how to use macros
              to build continuations in Common Lisp programs."
              I think he's mistaken about being able to implement call/cc in full
              generality with CL macros in any reasonable way. But it might be
              possible to implement enough to do something like Python generators
              using lexical closures that one re-enters through some kind of cond
              statement selecting the yield point to be continued from.

              Comment

              • Steven D'Aprano

                Re: merits of Lisp vs Python

                On Sun, 10 Dec 2006 06:40:46 +0000, Kirk Sluder wrote:
                To start with, English does not restrict the expressiveness and
                power of the syntax and grammar.
                >>
                >Really? There are no restrictions whatsoever in English syntax and
                >grammar? None at all?
                >
                Of course I didn't say that: What I said was, "To start with,
                English does not restrict the expressiveness and
                power of the syntax and grammar. People who use the English language
                in specific communities and in specific forms of discourse do.
                Hang on... are you saying that *people* create languages?

                *slaps head*

                And here I was thinking that languages fell from the sky like donuts!
                Gosh, thank you for explaining that too me. What a fool I must seem!

                By the way, that was sarcasm. Of course the English language doesn't exist
                in a vacuum. Of course people -- not rocks, not trees, not the Greek
                Furies, and especially not the Academie Francaise -- create languages.
                And, as an Australian in a world dominated by Americans, I know damn well
                that different communities of English speakers use different rules.

                *Slightly* different rules. That's why Standard American English and
                British English are both English, not different languages like Italian and
                German or Korean and Russian.

                [snip]
                As an example of the context-specific nature of pragmatics at work,
                if I was your reviewer or editor, I'd reject this manuscript.
                Perhaps you should find out what "manuscript " means before talking about
                rejecting one, because what I wrote was most certainly not a manuscript in
                any English language I'm aware of.
                As a
                participant on usenet, I'll just point out that you selectively
                quoted the antithesis, and deleted my thesis to argue a straw-man.
                Look, I was arguing a really simple point: for communication to occur
                between two individuals, both people must agree on a set of rules for the
                language that they use to communicate. If they don't have a common
                language with agreed upon rules, communication will be feeble and weak, if
                not non-existent, or there will be misunderstandin gs and errors.

                Is that so hard to grasp? If you ask for "fire water", by which you
                mean whiskey, but I understand to be petrol (gasoline), you're going
                to be a very sick person indeed if you drink what I give you.

                Of course there are restrictions, *enforced by users of language in
                specific communities.* But the English language is quite malleable,
                and includes not only the discourse we are currently engaged in, but
                the clipped jargon of internet chat and amateur radio, the
                chronically passive discourse of academia, the passionate chants of
                protesters, and a wide variety of poetic expression.
                Did I say it wasn't malleable? You are attacking me for things I never
                said.

                This is where wannabe critics of "English grammar" fail to
                understand the language they claim to defend, much to the amusement
                of those of us who actually do study language as it is, rather than
                the mythical eternal logos we want it to be.
                Ho ho ho, have you ever jumped to a foolish conclusion. You think I'm one
                of those tiresome bores who think that just because the ancient Romans
                couldn't end a sentence with a preposition, English shouldn't either?
                Puh-lease!

                Languages are (with some trivial exceptions) human creations. The
                laws, rules and restrictions of languages are dynamic and dependent
                on community, mode, medium and context. Of course, wannabe
                grammarians frequently rise up at this point and say that if such is
                the case, then there is nothing to prevent <language of choicefrom
                devolving into a babble of incomprehensibl e dialects. To which the
                easy response is that the benefits of conformity to linguistic
                communities almost always outweigh the costs of nonconformist
                expression.
                Yes yes, you're really passionate about language, you have little respect
                for grammarians, blah blah blah. None of that has the slightest relevance
                to what I was talking about. I'm not denying that languages evolve and
                mutate. I'm talking about the simple fact -- and it is a fact -- that two
                people must share at least some common linguistic concepts in order
                to communicate, and the fewer common constructs they share, the worse
                the communication. Languages accomplish that through rules. Yes, the
                rules are mere conventions, and can change. They're still rules.

                Some languages have very strict rules, some have very flexible rules, but
                they all have rules and they all restrict how you use the language.
                English has a rule that you turn "programmer " into a plural by adding
                "s" to the end. If you decide to drop the -er and add -ing instead, as in
                "I hired a team of six programming this week", at best people will do a
                double-take and be forced to work out what you mean from context. If you
                decide to make the plural of programmer by deleting the first and last
                three characters, nobody will have any idea what drugs you are smoking.


                [snip]
                >So, when I say "sits cat rat" it is not only legal English, but you can
                >tell which animal is sitting on which?
                >
                What is "legal" in English depends on the communities in which you
                are currently participating. Likely there is some community in which
                such clipped discourse is understood and therefore legal.
                Oh yes, the mythical "some community". Nope, sorry, I don't buy it. That's
                not legal in any English dialect I've come across, and I've dealt with --
                and still do -- English speakers from all over the world. No English
                language or dialect typically puts the verb in front of both the object
                and subject for present tense expressions. It isn't just *clipped*, the
                word order is completely different from English. Didn't you notice that?

                But in fact even if there is some obscure dialect of English that would
                allow that, that doesn't change my point that there are some constructs
                which aren't legal in English (as it exists today). If not "sit cat rat",
                something else.

                No doubt you can come up with some particular idiomatic phrase in English
                that puts the verb first, or a different grammatical construct like the
                imperative tense, e.g. "Sit on the rat, cat!". Poetry, in particular,
                sometimes uses the verb-subject-object order. But these exceptions merely
                emphasis that English, unlike Gaelic, doesn't normally write
                verb-subject-object.

                A language that was so radically different from all the other English
                dialects as to allow "sits cat rat" as a typical construct wouldn't be
                English. It might be a pidgin or a creole language. But it won't be
                English, not now. In the indefinite future, who knows? I'm not saying that
                languages are carved in stone, never to change -- that would be stupid.
                But at any one time, languages have rules, even if those rules change over
                time, and if two people disagree on those rules, communication is hurt, up
                to the point of stopping communication completely.

                If you are
                talking to me, I'd express my lack of comprehension by saying
                "Pardon?" and ask you to rephrase.
                And how unfortunate for you that in my local community, "pardon" is the
                worst insult imaginable and I punch you in the face.

                (See, you aren't the only one that can just invent local communities
                with implausible variations of English.)

                >But I'm belaboring the point. Of course English has restrictions in
                >grammar and syntax -- otherwise one could write something in Latin or
                >Thai or Mongolian and call it English. There are RULES of grammar and
                >syntax in English, which means that there are possible expressions which
                >break those rules -- hence there are expressions which one can't write in
                >legal English.
                >
                When you make an "illegal" statement in English, exactly who or what
                corrects you?
                >
                Is it Zeus, the divine Logos, the flying spaghetti monster, some
                platonic ideal?
                No. Your peers or your parents or your editor or your teachers correct
                you. Or you get a reputation for being "stupid" and people start treating
                you as if you were stupid -- maybe they start talk-ing ver-y slow-ly at
                you, using baby words. Or people just find it difficult to communicate
                with you, or misunderstand what you are trying to say.

                There is no law of physics that says that people can't say "Head on my hat
                I put". But English speakers just don't do it, and when somebody does,
                they are treated as if they aren't speaking English.

                But notice that semantics is important -- if I were to say "Head on my
                pillow I lay", chances are good that I'd be treated as speaking
                poetically, rather than as a non-English speaker. We commonly lay our head
                on our pillow, but put our hat on our head.
                As you can probably tell, this kind of silliness is a bit of a sore
                spot for me. So please by all means, do some basic reading of
                linguistics before you continue to engage in such silliness. Or at
                least learn to properly quote an argument.
                Before patronizing me, do make the effort to understand what I am saying.
                Just because you've got valid concerns about ignorant grammarians doesn't
                excuse your carelessness. Instead of reading what I actually wrote, you
                read into it what you wanted to see: another stupid wanna-be grammarian
                who thinks that languages are frozen, static, dead things. You couldn't be
                more wrong, and your repeated assumption -- and that's all it was, just an
                assumption -- that I know nothing about linguistics is shameful.

                Are you man enough to acknowledge your error, or are you going to continue
                this ridiculous charade of attacking me for holding views I don't have?


                --
                Steven.

                Comment

                • Ramon Diaz-Uriarte

                  Re: merits of Lisp vs Python

                  On 09 Dec 2006 03:16:45 -0800, Paul Rubin
                  <"http://phr.cx"@nospam. invalidwrote:
                  "Ramon Diaz-Uriarte" <rdiaz02@gmail. comwrites:
                  a) "old-fashioned"? Is that supposed to be an argument? I guess
                  addition and multiplication are old-fashioned, and so is calculus;so?
                  I think "old-fashioned" should only carry a negative connotation in
                  the fashion world, not in programming.
                  >
                  If someone handed you a calculus book written in Latin, you'd probably
                  find it undesirably old-fashioned too.
                  >
                  I think the "reasoning by analogy" is clearly showing its weakness
                  here (truth is, it was me who used the analogy to begin with). However
                  since (and this is no cynicism) I do really respect and find thought
                  provoking most of what you write,

                  how is Lisp similar to a calculus book written in Latin (or to the
                  Latin in the calculus book, or whatever)? What exactly is
                  "old-fashioned" supposed to mean here, and how does it carry a truly
                  negative connotation?

                  R.

                  P.D. I am only now starting with Lisp, after having written a lot of
                  Python for the last two years.
                  --
                  Ramon Diaz-Uriarte
                  Statistical Computing Team
                  Structural Biology and Biocomputing Programme
                  Spanish National Cancer Centre (CNIO)

                  Comment

                  • Steven D'Aprano

                    Re: merits of Lisp vs Python

                    On Sun, 10 Dec 2006 02:00:02 -0500, Ken Tilton wrote:

                    Steven D'Aprano wrote:
                    >On Sat, 09 Dec 2006 22:41:12 -0500, Ken Tilton wrote:
                    >>
                    >>
                    >>>>I know that. It was more of a rhetorical question -- Lispers are either
                    >>>>trying to emphasis the radical nature of what you can do with macros, or
                    >>>>understat e it and make them seem just like functions.
                    >>>
                    >>>Yep, both. The first is rare. CLOS is one, my Cells (ported this summer
                    >>>to PyCells as part of SoC 2006) is another. The latter is the norm.
                    >>
                    >>
                    >If macros' advanced usage is rare,
                    >
                    Hunh? I have tons of them. Of coure at your level of discourse you will
                    want to know if those are metric tons or...
                    Stop playing games Ken. You said they were rare. Not me. You. The fact
                    that you personally make lots of use of the more radical macros doesn't
                    come into it. As you said, the norm across the wider Lisp community is the
                    less radical macro, the ones that are basically just functions.

                    That's what you said -- or are you changing your mind?



                    --
                    Steven.

                    Comment

                    • Stefan Nobis

                      Re: merits of Lisp vs Python

                      Steven D'Aprano <steve@REMOVE.T HIS.cybersource .com.auwrites:
                      Is that an argument against factory functions? Damn straight it is:
                      they are a powerful tool, and in the hands of morons, they can be
                      dangerous. Does that mean that languages shouldn't permit
                      higher-order functions? Not necessarily: all programming tools can
                      be misused, but some can be misused more easily than others. Power
                      and risk is often a trade-off, and language designers can't
                      eliminate all risk of stupid behaviour, but they can design the
                      language to allow whatever level of risk they believe is
                      acceptable. (E.g. there is no doubt that C's raw pointers are
                      powerful, but many languages deliberately don't use them.)
                      I understand your point, I understand the Java folks. But I think this
                      point of view is really wrong. The right solution would be to better
                      train people, to give more good examples or even to not employ those,
                      who don't grasp it.

                      You point of view is that of (big) companies: Every developer should
                      be equal, exchangable. I'm very sure this is only an illusion. And I
                      think this point of view leads to many failures of (big)
                      projects. Each project has it's working horse(s) and these are quite
                      more equal than the others. :)

                      To deny the good developers, the working horses the power they need
                      isn't a good idea. Give them all the tools they need and let others
                      learn from them -- so (nearly) everybody becomes a good to great
                      developer.

                      Am I naive? Maybe...
                      The risk of stupid factory functions is small compared to the
                      benefit, but maybe there is some domain somewhere where the ideal
                      solution is a language that DOESN'T treat functions as first class
                      objects, deliberately weakening the language so that a particular
                      class of errors (or stupid behaviour) just cannot happen.
                      And with Lisp macros the good developers may easily create these DSLs
                      to be used by the not so good developers. :)
                      That's the perspective of many people, and maybe it is wrong. Maybe
                      you really need to be immersed in Lisp for a while to see the
                      advantages of macros.
                      Yes, I think this perspective is wrong. Some time ago I wondered about
                      the hype of LinQ -- with Lisp macros it's already there. These things,
                      embedded languages (like embedded SQL, embedded Prolog, ...) are
                      really great. I also hate the amount of boilerplate code nesseccary in
                      Java -- yes, in Python it's muss less, but in Lisp it really vanished.

                      If you use a really good designed language which don't assume every
                      programmer to be dumb and equal, yes, maybe macros would be not that
                      big a bonus. But hey, they are not worse than operator overloading and
                      the like, so why not include them? (Answer: In most cases it's hard to
                      add macros because of non-homogenous syntax.) :)

                      --
                      Stefan.

                      Comment

                      • Stefan Nobis

                        Re: merits of Lisp vs Python

                        Steven D'Aprano <steve@REMOVE.T HIS.cybersource .com.auwrites:
                        Look at us: we're all communicating in a common language, English,
                        and we all agree on syntax and grammar. Now, I could be a lot more
                        expressive, and language could be a lot more powerful, if I could
                        define my own language where "You are a poopy-head" was in fact a
                        detailed and devastatingly accurate and complete explanation for why
                        Python was a better language than Lisp.
                        So it is good that English restricts the expressiveness and power of
                        the syntax and grammar. While we're talking English, we can both
                        understand each other, and in fact people who redefine words and
                        ignore the common meaning of them are often covering weaknesses in
                        their arguments.
                        Uh, you don't talk often to non-programmers, do you? Talk a bit to
                        non-programmers about your programming habits, why you prefer which
                        programming language and so on. Everything in english. How much do
                        they understand?

                        Ever talked to skateboarders? Other people of different scenes? They
                        are creating new, specialized languages every day. Here in Germany a
                        study was published a little time ago, how few people understand
                        commercials and their slogans.

                        Do you know how many jokes work? Yes, by misunderstandin gs. Why is
                        this? Because (natural) languages have macros, operator overloading
                        and all this fuss.

                        I'm no expert, I not really studied linguistics, but I would say, you
                        are completley wrong.

                        --
                        Stefan.

                        Comment

                        • Steven D'Aprano

                          Re: merits of Lisp vs Python

                          On Sun, 10 Dec 2006 02:12:29 -0500, Bill Atkins wrote:
                          Steven D'Aprano <steve@REMOVE.T HIS.cybersource .com.auwrites:
                          >
                          >Rightly or wrongly, people fear that Lisp's macros push Lisp closer to
                          >that hypothetical anything-goes language than is healthy. Maybe that's a
                          >
                          Wrongly.
                          That's your opinion, and as an experienced Lisp coder, it is an opinion
                          worth treating seriously. Nevertheless, a mere denial doesn't constitute
                          evidence, let alone proof.
                          And do they? To paraphrase Brian Griffin: "Are you sure it
                          was people? Are you sure it wasn't...nothin g?"
                          You know, I'm really starting to think that you Lispers -- and I hate to
                          generalise, but in this case I feel I'm forced to -- have a real problem
                          here. On the one hand, I keep reading how unfair it is that the rest of
                          the programming world won't give Lisp a fair go, that all these other
                          programmers are spreading FUD over Lisp, especially over the macros and
                          parentheses. And then you come along and imply that nobody is concerned
                          about Lisp macros.

                          So which is it? If Lisp is so self-evidently better than every other
                          language, and if nobody has any fears or concerns with Lisp, why is Lisp a
                          fringe language? Not as fringe as it was ten years ago, and maybe growing
                          in popularity, and it is beyond all doubt that Lisp has a lot of influence
                          amongst language designers, but outside of a few niche areas, its still a
                          fringe language.


                          >My point isn't whether or not their claims are correct (a "couple" of
                          >macros? really?) but that things like this feed the perception that Lisp
                          >is close to that hypothetical language where anything could be anything.
                          >If anything could be anything, do you really know what (+ 1 2) means
                          >without reading every line of code?
                          >
                          Jesus H Christ. Didn't you just get through talking about how easily
                          someone can redefine built-ins in Python?
                          Yes. But you can't redefine 1+2 in Python, at least not without hacking
                          the interpreter. Can you redefine (+ 1 2) in Lisp?

                          >Even something simple like file I/O can be abused. Example: I've seen
                          >
                          Agreed. This is why I've always argued that I/O should never have
                          been included in programming languages. Too dangerous. And, let's
                          face it, pretty old-fashioned these days.
                          Ha ha, I love good sarcasm!

                          Unfortunately, that isn't good sarcasm.

                          >(This is an interesting demonstration that any language that allows file
                          >I/O and importing of external program files can always treat functions
                          >as data, even if the language doesn't directly support it. An alternative
                          >would be to keep the strings in memory instead of writing to a module,
                          >then use exec on them instead of importing the module.)
                          >
                          No, it treats code as text. See the difference?
                          Text is data.

                          What is the point of your comment? You don't have to argue about every
                          thing I say, even the ones we agree on. Look again at what I wrote. Is
                          there anything that gave you the impression that I think that having the
                          ability to write text to a file and import it is better than actually
                          supporting functional programming directly?

                          [snip]
                          >Is that an argument against factory functions? Damn straight it is:
                          >they are a powerful tool, and in the hands of morons, they can be
                          >dangerous. Does that mean that languages shouldn't permit higher-order
                          >functions? Not necessarily: all programming tools can be misused, but some
                          >can be misused more easily than others. Power and risk is often a
                          >trade-off, and language designers can't eliminate all risk of stupid
                          >behaviour, but they can design the language to allow whatever level of
                          >risk they believe is acceptable. (E.g. there is no doubt that C's raw
                          >pointers are powerful, but many languages deliberately don't use them.)
                          >
                          Could you please calm down?
                          Huh?
                          >The risk of stupid factory functions is small compared to the benefit, but
                          >maybe there is some domain somewhere where the ideal solution is a
                          >language that DOESN'T treat functions as first class objects, deliberately
                          >weakening the language so that a particular class of errors (or stupid
                          >behaviour) just cannot happen. But that language isn't Python.
                          >
                          Could you calm down?
                          Okay, once was funny. Twice is worrying. What exactly is giving you the
                          idea I need to calm down? Was it the use of reasoning and logic?
                          Perhaps it was the attempt to be reasonable and moderate and find some
                          middle ground that we could agree on, or if not agree, at least say "Well,
                          I disagree with you, but at least I understand where you are coming from"?

                          >When it comes to Lisp's macros, the perception is that the power is
                          >
                          NB: here, "the" means "Steven D'Aprano's" (the number of meanings
                          "the" can assume in different contexts is quite surprising).


                          >
                          >correspondingl y greater, and the risk of abuse even more so. The safe
                          >
                          Don't you get tired of making the same arguments? Because I'm getting
                          tired of making the same counterpoints.

                          Comment

                          • hg

                            Re: merits of Lisp vs Python

                            Bill Atkins wrote:
                            Steven D'Aprano <steve@REMOVE.T HIS.cybersource .com.auwrites:
                            >
                            >On Fri, 08 Dec 2006 23:38:02 -0800, Wolfram Fenske wrote:
                            >>
                            >>if Common Lisp didn't have CLOS, its object system, I could write my own
                            >>as a library and it would be just as powerful and just as easy to use as
                            >>the system Common Lisp already provides. Stuff like this is impossible
                            >>in other languages.
                            >>
                            >Dude. Turing Complete. Don't you Lisp developers know anything about
                            >computer science?
                            >
                            Of course, but you have to realize that Turing-completeness is a
                            useless concept when comparing languages. C and Python are both
                            Turing-complete. So: write me some code in each that reads in a line
                            of text, splits it on spaces and stores the result in an array. Which
                            would you rather write? Which will be shorter and more easily changed
                            and straightforward ly grasped in the future?
                            >
                            QED. Turing-completeness is irrelevant when comparing languages.
                            Take it as a given.
                            Lisp ? ;-)


                            Comment

                            • Ken Tilton

                              Re: merits of Lisp vs Python



                              Steven D'Aprano wrote:
                              On Sun, 10 Dec 2006 02:00:02 -0500, Ken Tilton wrote:
                              >
                              >
                              >
                              >>Steven D'Aprano wrote:
                              >>
                              >>>On Sat, 09 Dec 2006 22:41:12 -0500, Ken Tilton wrote:
                              >>>
                              >>>
                              >>>
                              >>>>>I know that. It was more of a rhetorical question -- Lispers are either
                              >>>>>trying to emphasis the radical nature of what you can do with macros, or
                              >>>>>understa te it and make them seem just like functions.
                              >>>>
                              >>>>Yep, both. The first is rare. CLOS is one, my Cells (ported this summer
                              >>>>to PyCells as part of SoC 2006) is another. The latter is the norm.
                              >>>
                              >>>
                              >>>If macros' advanced usage is rare,
                              >>
                              >>Hunh? I have tons of them. Of coure at your level of discourse you will
                              >>want to know if those are metric tons or...
                              >
                              >
                              Stop playing games Ken. You said they were rare. Not me. You. The fact
                              that you personally make lots of use of the more radical macros doesn't
                              come into it. As you said, the norm across the wider Lisp community is the
                              less radical macro, the ones that are basically just functions.
                              >
                              That's what you said -- or are you changing your mind?
                              No, I simply misapprehended what you wrote, though it was perfectly
                              clear. You wrote:
                              If macros' advanced usage is rare, and most usage of macros could be done
                              by functions, then maybe that explains why so many coders don't miss them.
                              Maybe my brain misfired because there is so much wrong with that. The
                              meta-wrong is that clearly you do not understand macros or how they play
                              out in real applications, but you have climbed up on this soapbox as if
                              you were an expert on both issues. Like your interview, you are
                              speculating without basis on what might happen. You do have a good
                              excuse since GvR does the same.

                              Here you have a chance to talk with people who program with macros day
                              in and day out and learn about them, instead you are trying to tell us
                              how they are used. Does that make a lot of sense? Or do you think we are
                              lying? :)

                              Language-transforming macros such as defclass/defmethod (the heart of
                              CLOS) and my defmodel come along rarely. This does not mean my
                              applications do not /use/ CLOS extensively. They do. It means I do not
                              have ten such different language extensions. I have three: defclass,
                              defmodel, and LOOP. Can you understand that difference? "Used everywhere
                              because they are so cool" and "just a few such cool tools exist" are not
                              contradictory.

                              Does rare mean "who needs it"? Nice try, but obviously not. Well, maybe
                              not obviously, because not everyone likes OO, but I would not want to
                              program without defclass or defmodel or even LOOP. The latter is such a
                              powerful iteration tool it justifies learning the new syntax, which is
                              also not a problem because I use it all day making it is easy to
                              remember. (Aside: I /did/ resist learning it for years because of the
                              different syntax--my loss.)

                              Recall that this subwar started over someone saying Lisp was able to
                              "grow" CLOS without changing and have it look like part of the language,
                              which led you and others to echo GvR and pronounce macros to be
                              obfuscatory (?). Sorry, no, not in fact. Only in your nightmares.

                              As for simple macros not being necessary, what they do is clean up the
                              code, letting the beef stand out more. Obviously people with that
                              interest do not turn around and create obfuscated code, no matter how
                              many times you want to FUD that (which seems to be quite a lot <g>).

                              ken

                              --
                              Algebra: http://www.tilton-technology.com/LispNycAlgebra1.htm

                              "Well, I've wrestled with reality for thirty-five
                              years, Doctor, and I'm happy to state I finally
                              won out over it." -- Elwood P. Dowd

                              "I'll say I'm losing my grip, and it feels terrific."
                              -- Smiling husband to scowling wife, New Yorker cartoon

                              Comment

                              • Kirk  Sluder

                                Re: merits of Lisp vs Python

                                In article
                                <pan.2006.12.10 .14.24.05.64806 8@REMOVE.THIS.c ybersource.com. au>,
                                Steven D'Aprano <steve@REMOVE.T HIS.cybersource .com.auwrote:
                                Yes. But you can't redefine 1+2 in Python, at least not without hacking
                                the interpreter. Can you redefine (+ 1 2) in Lisp?
                                Not without barreling through error messages about name conflicts.

                                Comment

                                Working...