Python from Wise Guy's Viewpoint

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex Martelli

    #31
    Re: Python from Wise Guy's Viewpoint

    Hannu Kankaanp?? wrote:
    [color=blue]
    > mike420@ziplip. com wrote in message
    > news:<LVOAILABA JAFKMCPJ0F1IFP5 N3JTNUL0EPMGKMD S@ziplip.com>.. .[color=green]
    >> THE BAD:
    >>
    >> 1. f(x,y,z) sucks. f x y z would be much easier to type (see Haskell)
    >> 90% of the code is function applictions. Why not make it convenient?[/color]
    >
    > Python has been designed to attract non-programmers as well. Don't
    > you think f(x,y,z) resembles the mathematical notation of passing
    > a function some parameters, instead of "f x y z"?[/color]

    Yes -- which is exactly why many non-programmers would prefer the
    parentheses-less notation -- with more obvious names of course;-).
    E.g.:
    emitwarning URGENT "meltdown imminent!!!"
    DOES look nicer to non-programmers than
    emitwarning(URG ENT, "meltdown imminent!!!")

    Indeed, such languages as Visual Basic and Ruby do allow calling
    without parentheses, no doubt because of this "nice look" thing.

    However, as I explained elsewhere, there are probably-insuperable
    language-design problems in merging "implicit call" and first-classness
    of all names unless you basically go all the way following Haskell
    with implicit currying and non-strictness (and assignments should
    probably go away too, else how to distinguish between assigning to
    x a nullary function f itself, and assigning to x the result of
    _calling_ f without arguments...?). Not to mention:

    emitwarning URGENT highlight "meltdown imminent!!!"

    where the need to disambiguate between highlight being the second
    of three parameters to emitwarning, or a function called with
    the string as its sole parameter and its RESULT being the second
    of two parameters to emitwarning, is important for human readers
    (indeed some languages that DO allow parentheses-less calls, such
    as Ruby, warn against actually USING this possibility in all cases
    where ambiguity-to-human-readers may result, such as the above --
    the need to be very careful and selective in actually using the
    capability makes me less and less willing to pay any large price
    for it).

    In other words, it's a language design tradeoff, like so many
    others -- one which I believe both Python and Haskell got just
    right for their different audiences and semantics (I know VB
    _didn't_, and I suspend judgment on Ruby -- maybe firstclassness
    of all names isn't as important as it FEELS to me, but...).

    [color=blue][color=green]
    >> 6. Requiring "return" is also dumb (see #5)[/color]
    >
    > You really don't get any of this "explicit is better than implicit"
    > thing, do you? Requiring people to write "return" instead of
    > leaving it as optional like in Ruby, is again one reason why
    > Pythonistas *like* Python instead of Ruby. You come to[/color]

    I think that making return optional is slightly error-prone,
    but it DOES make the language easier to learn for newbies --
    newbies often err, in Python, by writing such code as
    def double(x): x+x
    which indicates the lack of 'return' IS more natural than its
    mandatory presence. So, it's a tradeoff one could sensibly
    chose either way. Of course, such cases as:
    def buhandclose(boh ):
    try: boh.buh()
    finally: boh.close()
    would give you a bad headache in trying to explain them to
    newbies ("hmyes the result of buhandclose IS that of the
    last expression it evaluates, BUT the one in the finally
    clause, although evaluated AFTER boh.buh(), doesn't really
    count because..." [keeps handwaving copiously & strenously]).
    So, mandatory 'return' does make the language more uniform,
    consistent, and easy to master, though not quite as easy to
    "pick up casually in a semi-cooked manner". Still, I for
    one don't condemn Ruby for making the opposite choice -- it
    IS a nicely balanced issue, IMHO.

    [color=blue]
    > Anyway, as a conclusion, I believe you'd be much happier with
    > Ruby than with Python. It doesn't do this weird "statement vs
    > expression" business, it has optional return, it has optional
    > parens with function calls, and probably more of these things
    > "fixed" that you consider Python's downsides. You're trying to[/color]

    But doesn't make higher-order-functions as much of a no-brainer
    as they're in Python, sigh.
    [color=blue]
    > make Python into a language that already exists, it seems, but
    > for some reason Pythonistas are happy with Python and not rapidly
    > converting to Ruby or Haskell. Instead of trying to tell us[/color]

    My own reasons for the choice of Python over Ruby are quite
    nuanced and complicated, actually (those for either of them
    over Haskell have much to do with pragmatism over purity:-).

    It boils down to my desire to write application programs,
    often requiring cooperation of middling-sized groups of people,
    rather than experimental frameworks, or programs written by a
    lone coder or a small group of highly-attuned experts. I have
    the highest respect for Ruby -- it just doesn't match my needs
    QUITE as well as Python does. But, yes, if somebody doesn't
    really think about what kind of programs they want to write,
    but rather focuses on syntax sugar issues such as return being
    optional or mandatory "per se", then it's definitely worthwhile
    for that somebody to try Ruby and leave c.l.py in peace:-).


    Alex

    Comment

    • Gerrit Holl

      #32
      Re: Python from Wise Guy's Viewpoint

      Hannu Kankaanp?? wrote:[color=blue]
      > Anyway, as a conclusion, I believe you'd be much happier with
      > Ruby than with Python. It doesn't do this weird "statement vs
      > expression" business, it has optional return, it has optional
      > parens with function calls, and probably more of these things
      > "fixed" that you consider Python's downsides. You're trying to
      > make Python into a language that already exists, it seems, but
      > for some reason Pythonistas are happy with Python and not rapidly
      > converting to Ruby or Haskell.[/color]

      I wonder to what extent this statement is true. I know at least
      1 Ruby programmer who came from Python, but this spot check should
      not be trusted, since I know only 1 Ruby programmer and only 1
      former Python programmer <g>. But I have heard that there are a
      lot of former Python programmers in the Ruby community. I think
      it is safe to say that of all languages Python programmers migrate
      to, Ruby is the strongest magnet. OTOH, the migration of this part
      of the Python community to Ruby may have been completed already,
      of course.

      Gerrit.

      --
      53. If any one be too lazy to keep his dam in proper condition, and
      does not so keep it; if then the dam break and all the fields be flooded,
      then shall he in whose dam the break occurred be sold for money, and the
      money shall replace the corn which he has caused to be ruined.
      -- 1780 BC, Hammurabi, Code of Law
      --
      Asperger Syndroom - een persoonlijke benadering:

      Kom in verzet tegen dit kabinet:
      De website van de Socialistische Partij (SP) in Nederland: Informatie, nieuws, agenda en publicaties.


      Comment

      • Joachim Durchholz

        #33
        Re: Python from Wise Guy's Viewpoint

        Marcin 'Qrczak' Kowalczyk wrote:
        [color=blue]
        > On Sun, 19 Oct 2003 20:01:03 +0200, Joachim Durchholz wrote:
        >[color=green]
        >>The longer answer: Multimethods have modularity issues (if whatever domain
        >>they're dispatching on can be extended by independent developers:
        >>different developers may extend the dispatch domain of a function in
        >>different directions, and leave undefined combinations;[/color]
        >
        > This doesn't matter until you provide an equally powerful mechanism which
        > fixes that. Which is it?[/color]

        I don't think there is a satisfactory one. It's a fundamental problem:
        if two people who don't know of each other can extend the same thing
        (framework, base class, whatever) in different directions, who's
        responsible for writing the code needed to combine these extensions?

        Solutions that I have seen or thought about are:

        1. Let the system decide. Technically feasible for base classes (in the
        form of priorisation rules for multimethods), technically infeasible for
        frameworks. The problem here is that the system doesn't (usually) have
        enough information to reliably make the correct decision.

        2. Let the system declare an error if the glue code isn't there.
        Effectively prohibits all forms of dynamic code loading. Can create
        risks in project management (unexpected error messages during code
        integration near a project deadline - yuck). Creates a temptation to
        hack the glue code up, by people who don't know the details of the two
        modules involved.

        3. Disallow extending in multiple directions. In other words, no
        multimethods, and live with the asymmetry.
        Too restricted to be comfortable with.

        4. As (3), but allow multiple extensions if they are contained within
        the same module. I.e. allow multiple dispatch within an "arithmetic s"
        module that defines the classes Integer, Real, Complex, etc. etc., but
        don't allow additional multiple dispatch outside the module. (Single
        dispatch would, of course, be OK.)

        5. As (3), but require manual intervention. IOW let the two authors who
        did the orthogonal extensions know about each other, and have each
        module refer to the other, and each module carry the glue code required
        to combine with the other.
        Actually, this is the practice for various open source projects. For
        example, authors of MTAs, mail servers etc. cooperate to set standards.
        Of course, if the authors aren't interested in cooperating, this doesn't
        work well either.

        6. Don't use dynamic dispatch, use parametric polymorphism (or whatever
        your language offers for that purpose, be it "generics" or "templates" ).

        Regards,
        Jo

        Comment

        • Joachim Durchholz

          #34
          Re: Python from Wise Guy's Viewpoint

          Pascal Costanza wrote:
          [color=blue]
          > Joachim Durchholz wrote:
          >[color=green]
          >> Oh, you're trolling for an inter-language flame fest...
          >> well, anyway:
          >>[color=darkred]
          >>> 3. no multimethods (why? Guido did not know Lisp, so he did not know
          >>> about them) You now have to suffer from visitor patterns, etc. like
          >>> lowly Java monkeys.[/color]
          >>
          >> Multimethods suck.[/color]
          >
          > Do they suck more or less than the Visitor pattern?[/color]

          Well, the visitor pattern is worse.
          Generics would be better though.
          [color=blue]
          > So how do you implement an equality operator correctly with only single
          > dynamic dispatch?[/color]

          Good question.

          In practice, you don't use dispatch, you use some built-in mechanism.

          Even more in practice, all equality operators that I have seen tended to
          compare more or less than one wanted to have compared, at least for
          complicated types with large hidden internal structures, or different
          equivalent internal structures. I have seen many cases where people
          implemented several equality operators - of course, with different
          names, and for most cases, I'm under the impression they weren't even
          aware that it was equality that they were implementing :-)

          Examples are:
          Lisp with its multitude of equality predicates nicely exposes the
          problems, and provides a solution.
          Various string representations (7-bit Ascii, 8-bit Ascii, various
          Unicode flavors). Do you want to compare representations or contents? Do
          you need a code table to compare?
          Various number representation: do you want to make 1 different from 1.0,
          or do you want to have them equal?

          I think that dynamic dispatch is an interesting answer, but not to
          equality :-)

          Regards,
          Jo

          Comment

          • Joachim Durchholz

            #35
            Re: Python from Wise Guy's Viewpoint

            Kenny Tilton wrote:[color=blue]
            >
            > Dennis Lee Bieber wrote:
            >[color=green]
            >> Short version: The software performed correctly, to
            >> specification (including the failure mode) -- ON THE ARIANE 4 FOR
            >> WHICH IT WAS DESIGNED.[/color]
            >
            > Nonsense. From: http://www.sp.ph.ic.ac.uk/Cluster/report.html
            >
            > "The internal SRI software exception was caused during execution of a
            > data conversion from 64-bit floating point to 16-bit signed integer
            > value. The floating point number which was converted had a value greater
            > than what could be represented by a 16-bit signed integer. This resulted
            > in an Operand Error. The data conversion instructions (in Ada code) were
            > not protected from causing an Operand Error, although other conversions
            > of comparable variables in the same place in the code were protected.
            > The error occurred in a part of the software that only performs
            > alignment of the strap-down inertial platform. This software module
            > computes meaningful results only before lift-off. As soon as the
            > launcher lifts off, this function serves no purpose."[/color]

            That's the sequence of events that led to the crash.
            Why this sequence could happen though it shouldn't have happened is
            exactly how Dennis wrote it: the conversion caused an exception because
            the Ariane-5 had a tilt angle beyond what the SRI was designed for.
            [color=blue]
            > What happened (aside from an unnecessary chunk of code running
            > increasing risk to no good end) is that the extra power of the A5 caused
            > oscillations greater than those seen in the A4. Those greater
            > oscillations took the 64-bit float beyond what would fit in the 16-bit
            > int. kablam. Operand Error. This is not a system saying "whoa, out of
            > range, abort".
            >
            > As for Lisp not helping:
            >[color=green]
            > > most-positive-fixnum ;; constant provided by implementation[/color]
            > 536870911
            >[color=green]
            > > (1+ most-positive-fixnum) ;; overflow fixnum type and...[/color]
            > 536870912
            >[color=green]
            > > (type-of (1+ most-positive-fixnum)) ;; ...auto bignum type[/color]
            > BIGNUM
            >[color=green]
            > > (round most-positive-single-float) ;; or floor or ceiling[/color]
            > 340282346638528 859811704183484 516925440
            > 0.0
            >[color=green]
            > > (type-of *)[/color]
            > BIGNUM[/color]

            Lisp might not have helped even in that case.
            1. The SRI was designed for an angle that would have fit into a 16-bit
            operand. If the exception hadn't been thrown, some hardware might still
            have malfunctioned.
            2. I'm pretty sure there's a reason (other than saving space) for that
            conversion to 16 bits. I suspect it was to be fed into some hardware
            register... in which case all bignums of the world aren't going to help.

            Ariane 5 is mostly a lesson in management errors. Software methodology
            might have helped, but just replacing the programming language would
            have been insufficient (as usual - languages can make proper testing
            easier or harder, but the trade-off will always be present).

            Regards,
            Jo

            Comment

            • Marcin 'Qrczak' Kowalczyk

              #36
              Re: Python from Wise Guy's Viewpoint

              Followup-To: comp.lang.misc

              On Mon, 20 Oct 2003 13:06:08 +0200, Joachim Durchholz wrote:
              [color=blue][color=green][color=darkred]
              >>>The longer answer: Multimethods have modularity issues (if whatever
              >>>domain they're dispatching on can be extended by independent developers:
              >>>different developers may extend the dispatch domain of a function in
              >>>different directions, and leave undefined combinations;[/color]
              >>
              >> This doesn't matter until you provide an equally powerful mechanism
              >> which fixes that. Which is it?[/color]
              >
              > I don't think there is a satisfactory one. It's a fundamental problem:
              > if two people who don't know of each other can extend the same thing
              > (framework, base class, whatever) in different directions, who's
              > responsible for writing the code needed to combine these extensions?[/color]

              Indeed. I wouldn't thus blame the language mechanism.
              [color=blue]
              > 1. Let the system decide. Technically feasible for base classes (in the
              > form of priorisation rules for multimethods), technically infeasible for
              > frameworks. The problem here is that the system doesn't (usually) have
              > enough information to reliably make the correct decision.[/color]

              Sometimes the programmer can write enough default specializations that it
              can be freely extended. Example: drawing shapes on devices. If every shape
              is convertible to Bezier curves, and every device is capable of drawing
              Bezier curves, then the most generic specialization, for arbitrary shape
              and arbitrary device, will call 'draw' again with the shape converted to
              Bezier curves.

              The potential of multimethods is used: particular shapes have specialized
              implementations for particular devices (drawing text is usually better
              done more directly than through curves), separate modules can provide
              additional shapes and additional devices. Yet it is safe and modular, as
              long as people agree who provides a particular specialization.

              It's easy to agree with a certain restriction: the specialization is
              provided either by the module providing the shape or by module providing
              the device. In practice the restriction doesn't have to be always followed
              - it's enough that the module providing the specialization is known to all
              people who might want to write their own, so I wouldn't advocate enforcing
              the restriction on the language level.

              I would favor multimethods even if they provided only solutions extensible
              in one dimension, since they are nicer than having to enumerate all cases
              in one place. Better to have a partially extensible mechanism than nothing.
              Here it is extensible.
              [color=blue]
              > 2. Let the system declare an error if the glue code isn't there.
              > Effectively prohibits all forms of dynamic code loading. Can create risks
              > in project management (unexpected error messages during code integration
              > near a project deadline - yuck). Creates a temptation to hack the glue
              > code up, by people who don't know the details of the two modules involved.[/color]

              It would be interesting to let the system find the coverage of multimethods,
              but without making it an error if not all combinations are covered. It's
              useful to be able to test an incomplete program.

              There is no definite answer for what kind of errors should prevent running
              the program. It's similar to static/dynamic typing, or being able to
              compile calls to unimplemented functions or not.

              Even if the system shows that all combinations are covered, it doesn't
              imply that they do the right thing. It's analogous to failing to override
              a method in class-based OOP - the system doesn't know if the superclass
              implementation is appropriate for the subclass. So you can't completely
              rely on detection of such errors anyway.
              [color=blue]
              > 3. Disallow extending in multiple directions. In other words, no
              > multimethods, and live with the asymmetry. Too restricted to be
              > comfortable with.[/color]

              I agree.
              [color=blue]
              > 4. As (3), but allow multiple extensions if they are contained within the
              > same module. I.e. allow multiple dispatch within an "arithmetic s" module
              > that defines the classes Integer, Real, Complex, etc. etc., but don't
              > allow additional multiple dispatch outside the module. (Single dispatch
              > would, of course, be OK.)[/color]

              For me it's still too restricted. It's a useful guideline to follow but
              it should not be a hard requirement.
              [color=blue]
              > 5. As (3), but require manual intervention. IOW let the two authors who
              > did the orthogonal extensions know about each other, and have each module
              > refer to the other, and each module carry the glue code required to
              > combine with the other.[/color]

              The glue code might reside in yet another module, especially if each of
              the modules makes sense without the other (so it might better not depend
              on it). Again, for me it's just a guideline - if one of the modules can
              ensure that it's composable with the other, it's a good idea to change it -
              but I would like to be able to provide the glue code elsewhere to make
              them working in my program which uses both, and remove it once the modules
              include the glue code themselves.
              [color=blue]
              > Actually, this is the practice for various open source projects. For
              > example, authors of MTAs, mail servers etc. cooperate to set standards. Of
              > course, if the authors aren't interested in cooperating, this doesn't work
              > well either.[/color]

              The modules might also be a part of one program, where it's relatively
              easy to make them cooperate. Inability to cope with some uses is generally
              not a sufficient reason to reject a language mechamism which also has well
              working uses.
              [color=blue]
              > 6. Don't use dynamic dispatch, use parametric polymorphism (or whatever
              > your language offers for that purpose, be it "generics" or "templates" ).[/color]

              I think it can rarely solve the same problem. C++ templates (which can
              use overloaded operations, i.e. with implementation dependent on type
              parameters) help only in statically resolvable cases. Fully parametric
              polymorphism doesn't seem to help at all even in these cases (equality,
              arithmetic).

              --
              __("< Marcin Kowalczyk
              \__/ qrczak@knm.org. pl
              ^^ http://qrnik.knm.org.pl/~qrczak/

              Comment

              • Peter Hansen

                #37
                Re: Python from Wise Guy's Viewpoint

                Gerrit Holl wrote:[color=blue]
                >
                > But I have heard that there are a
                > lot of former Python programmers in the Ruby community. I think
                > it is safe to say that of all languages Python programmers migrate
                > to, Ruby is the strongest magnet. OTOH, the migration of this part
                > of the Python community to Ruby may have been completed already,
                > of course.[/color]

                And also on the other hand, perhaps not enough time has yet passed for
                us to see the migration of these fickle people *back* to Python. :-)

                -Peter

                Comment

                • Wojtek Walczak

                  #38
                  Re: Python from Wise Guy's Viewpoint

                  Dnia Sun, 19 Oct 2003 04:18:31 -0700 (PDT), mike420@ziplip. com napisa³(a):[color=blue]
                  > THE GOOD:[/color]
                  [...][color=blue]
                  > THE BAD:[/color]
                  [...]

                  Well, in the variety of languages and plenty of conceptions you can search
                  for your language of choice. Because all the things you mentioned in
                  "THE BAD" are available in other languages it doesn't mean it should also
                  exist in Python. Languages are different, just as people are. If you find
                  Python has more cons than pros it means that this is not a language from
                  which you can take 100% of fun. Anyway, changing it into next haskell,
                  smalltalk or ruby has no sense. Python fills certain niche and it does
                  its job as it should. Differences are necessity, so don't waste your time
                  on talks about making Python similar to something else.

                  --
                  [ Wojtek Walczak - gminick (at) underground.org .pl ]
                  [ <http://gminick.linuxse curity.pl/> ]
                  [ "...rozmait e zwroty, matowe od patyny dawnosci." ]

                  Comment

                  • Alex Martelli

                    #39
                    Re: Python from Wise Guy's Viewpoint

                    Pascal Costanza wrote:
                    ...[color=blue]
                    > So how do you implement an equality operator correctly with only single
                    > dynamic dispatch?[/color]

                    Equality is easy, as it's commutative -- pseudocode for it might be:

                    def operator==(a, b):
                    try: return a.__eq__(b)
                    except I_Have_No_Idea:
                    try: return b.__eq__(a)
                    except I_Have_No_Idea:
                    return False

                    Non-commutative operators require a tad more, e.g. Python lets each
                    type define both an __add__ and a __radd__ (rightwise-add):

                    def operator+(a, b):
                    try: return a.__add__(b)
                    except (I_Have_No_Idea , AttributeError) :
                    try: return b.__radd__(a)
                    except (I_Have_No_Idea , AttributeError) :
                    raise TypeError, "can't add %r and %r" % (type(a),type(b ))

                    Multimethods really shine in HARDER problems, e.g., when you have
                    MORE than just two operands (or, perhaps, some _very_ complicated
                    inheritance structure -- but in such cases, even multimethods are
                    admittedly no panacea). Python's pow(a, b, c) is an example --
                    and, indeed, Python does NOT let you overload THAT (3-operand)
                    version, only the two-operand one that you can spell pow(a, b)
                    or a**b.


                    ALex

                    Comment

                    • Markus Mottl

                      #40
                      Re: Python from Wise Guy's Viewpoint

                      In comp.lang.funct ional Kenny Tilton <ktilton@nyc.rr .com> wrote:[color=blue]
                      > Dennis Lee Bieber wrote:[color=green]
                      >> Short version: The software performed correctly, to specification
                      >> (including the failure mode) -- ON THE ARIANE 4 FOR WHICH IT WAS
                      >> DESIGNED.[/color][/color]
                      [color=blue]
                      > Nonsense. From: http://www.sp.ph.ic.ac.uk/Cluster/report.html[/color]

                      Dennis is right: it was indeed a specification problem. AFAIK, the coder
                      had actually even proved formally that the exception could not arise
                      with the spec of Ariana 4. Lisp code, too, can suddenly raise unexpected
                      exceptions. The default behaviour of the system was to abort the mission
                      for safety reasons by blasting the rocket. This wasn't justified in this
                      case, but one is always more clever after the event...
                      [color=blue]
                      > "supposed to" fail? chya.[/color]

                      Indeed. Values this extreme were considered impossible on Ariane 4 and
                      taken as indication of such a serious failure that it would justify
                      aborting the mission.
                      [color=blue]
                      > This was nothing more than an unhandled exception crashing the sytem
                      > and its identical backup.[/color]

                      Depends on what you mean by "crash": it certainly didn't segfault. It
                      just realized that something happened that wasn't supposed to happen
                      and reacted AS REQUIRED.
                      [color=blue]
                      > Other conversions were protected so they could handle things
                      > intelligently, this bad boy went unguarded.[/color]

                      Bad, indeed, but absolutely safe with regard to the spec of Ariane 4.
                      [color=blue]
                      > Note also that the code functionality was pre-ignition
                      > only, so there is no way they were thinking that a cool way to abort the
                      > flight would be to leave a program exception unhandled.[/color]

                      This is a serious design error, not a problem of the programming language.
                      [color=blue]
                      > What happened (aside from an unnecessary chunk of code running
                      > increasing risk to no good end)[/color]

                      Again, it's a design error.
                      [color=blue]
                      > is that the extra power of the A5 caused
                      > oscillations greater than those seen in the A4. Those greater
                      > oscillations took the 64-bit float beyond what would fit in the 16-bit
                      > int. kablam. Operand Error. This is not a system saying "whoa, out of
                      > range, abort".[/color]

                      Well, the system was indeed programmed to say "whoa, out of range, abort".
                      A design error.
                      [color=blue]
                      > As for Lisp not helping:[/color]

                      There is basically no difference between checking the type of a value
                      dynamically for validity and catching exceptions that get raised on
                      violations of certain constraints. One can forget to do both or react
                      to those events in a stupid way (or prove in both cases that the check /
                      exception handling is unnecessary given the spec).

                      Note that I am not defending ADA in any way or arguing against FPLs: in
                      fact, being an FPL-advocate myself I do think that FPLs (including Lisp)
                      have an edge what concerns writing safe code. But the Ariane-example just
                      doesn't support this claim. It was an absolutely horrible management
                      mistake to not check old code for compliance with the new spec. End
                      of story...

                      Regards,
                      Markus Mottl

                      --
                      Markus Mottl http://www.oefai.at/~markus markus@oefai.at

                      Comment

                      • Kenny Tilton

                        #41
                        Re: Python from Wise Guy's Viewpoint



                        Fergus Henderson wrote:
                        [color=blue]
                        > Kenny Tilton <ktilton@nyc.rr .com> writes:
                        >
                        >[color=green]
                        >>Dennis Lee Bieber wrote:
                        >>
                        >>[color=darkred]
                        >>> Just check the archives for comp.lang.ada and Ariane-5.
                        >>>
                        >>> Short version: The software performed correctly, to specification
                        >>>(including the failure mode) -- ON THE ARIANE 4 FOR WHICH IT WAS
                        >>>DESIGNED.[/color]
                        >>
                        >>Nonsense.[/color]
                        >
                        >
                        > No, that is exactly right. Like the man said, read the archives for
                        > comp.lang.ada.[/color]

                        Yep, I was wrong. They /did/ handle the overflow by leaving the
                        operation unguarded, trusting it to eventually bring down the system,
                        their design goal. Apologies to Dennis.
                        [color=blue]
                        >
                        >[color=green]
                        >>From: http://www.sp.ph.ic.ac.uk/Cluster/report.html
                        >>
                        >>"The internal SRI software exception was caused during execution of a
                        >>data conversion from 64-bit floating point to 16-bit signed integer
                        >>value. The floating point number which was converted had a value greater
                        >>than what could be represented by a 16-bit signed integer. This resulted
                        >>in an Operand Error. The data conversion instructions (in Ada code) were
                        >>not protected from causing an Operand Error, although other conversions
                        >>of comparable variables in the same place in the code were protected.
                        >>The error occurred in a part of the software that only performs
                        >>alignment of the strap-down inertial platform. This software module
                        >>computes meaningful results only before lift-off. As soon as the
                        >>launcher lifts off, this function serves no purpose."[/color]
                        >
                        >
                        > That's all true, but it is only part of the story, and selectively quoting
                        > just that part is misleading in this context.[/color]

                        I quoted the entire paragraph and it seemed conclusive, so I did not
                        read the rest of the report. ie, I was not being selective, I just
                        assumed no one would consider crashing to be a form of error-handling.
                        My mistake, they did.

                        Well, the original question was, "Would Lisp have helped?". Let's see.
                        They dutifully went looking for overflowable conversions and decided
                        what to do with each, deciding in this case to do something appropriate
                        for the A4 which was inappropriately allowed by management to go into
                        the A5 unexamined.

                        In Lisp, well, there are two cases. Did they have to dump a number into
                        a 16-bit hardware channel? There was some reason for the conversion. If
                        not, no Operand Error arises. It is an open question whether they decide
                        to check anyway for large values and abort if found, but this one arose
                        only during a sweep of all such conversions, so probably not.

                        But suppose they did have to dance to the 16-bit tune of some hardware
                        blackbox. they would go thru the same reasoning and decide to shut down
                        the system. No advantage to Lisp. But they'd have to do some work to
                        bring the system down, because there would be no overflow. So:

                        (define-condition e-hardware-broken (e-pre-ignition e-fatal)
                        ((component-id :initarg :component-id :reader component-id)
                        (bad-value :initarg :bad-value :intiform nil :reader bad-value)
                        ...etc etc...

                        And then they would have to kick it off, and the exception handler of
                        the controlling logic would get a look at the condition on the way out.
                        Of course, it also sees operand errors, so one can only hope that at
                        some point during testing they for some reason had /some/ condition of
                        type e-pre-ignition get trapped by the in-flight supervisor, at which
                        point someone would have said either throw it away or why is that module
                        still running?

                        Or, if they were as meticulous with their handlers as they were with
                        numeric conversions, they would have during the inventory of explicit
                        conditions to handle gotten to the pre-ignition module conditions and
                        decided, "what does that software (which should not even be running)
                        know about the hardware that the rest of the system does not know?".

                        The case is not so strong now, but the odds are still better with Lisp.

                        kenny


                        --

                        What?! You are a newbie and you haven't answered my:


                        Comment

                        • Hannu Kankaanp??

                          #42
                          Re: Python from Wise Guy's Viewpoint

                          Alex Martelli <aleax@aleax.it > wrote in message news:<OwOkb.194 85$e5.710958@ne ws1.tin.it>...[color=blue]
                          > Yes -- which is exactly why many non-programmers would prefer the
                          > parentheses-less notation -- with more obvious names of course;-).
                          > E.g.:
                          > emitwarning URGENT "meltdown imminent!!!"
                          > DOES look nicer to non-programmers than
                          > emitwarning(URG ENT, "meltdown imminent!!!")[/color]

                          It depends on the background of the non-programmer. I'd
                          say most non-programmers who turn into programmers have at
                          least some math experience, so they won't be scared to type
                          1 + 2 instead of "give me the answer to one plus two, thank you".
                          The latter group we can always guide to COBOL ;) (if my
                          understanding of that language is correct). And the former
                          group should be familiar with the function notation.

                          Perhaps, despite of Guido's urge for "programmin g for everyone",
                          Python has been designed with such a group in mind that has at
                          least some hope of becoming programmers ;)
                          [color=blue][color=green]
                          > > You really don't get any of this "explicit is better than implicit"
                          > > thing, do you? Requiring people to write "return" instead of
                          > > leaving it as optional like in Ruby, is again one reason why
                          > > Pythonistas *like* Python instead of Ruby. You come to[/color]
                          >
                          > I think that making return optional is slightly error-prone,
                          > but it DOES make the language easier to learn for newbies --
                          > newbies often err, in Python, by writing such code as
                          > def double(x): x+x
                          > which indicates the lack of 'return' IS more natural than its
                          > mandatory presence.[/color]

                          You're right. That definition of double is closer to what
                          programming newbies probably have learned in math, than one
                          with "return". But that's not the point I was arguing really.
                          It was that Pythonistas prefer the explicit "return" and don't
                          want it to be changed -- So it's silly to present it as one of
                          Python's flaws.

                          Well ok, that was a pretty bold claim with no extensive
                          studies to back it up, and even contradicts my previously
                          expressed need to be compatible with math. So sure, it's
                          a tradeoff, but unlike the 'no-parens'-syntax, explicit
                          return adds to code readability without affecting the basic
                          notation as comprehensively as the lack of parens in
                          function calls (such as making higher-order functions less
                          intuitive to use).

                          Actually my preference is to either always require return when
                          there's something to return, or never allow return. Making it
                          optional just leads to less uniformity. And disallowing it
                          entirely in an imperative language wouldn't be such a wise
                          move either.

                          Comment

                          • Pascal Bourguignon

                            #43
                            Re: Python from Wise Guy's Viewpoint


                            Fergus Henderson <fjh@cs.mu.oz.a u> writes:[color=blue]
                            > <http://www.google.com. au/groups?as_umsgi d=359BFC60.446B %40lanl.gov>.[/color]

                            The post at that url writes about the culture of the Ariane team, but
                            I would say that it's even a more fundamental problem of our culture
                            in general: we build brittle stuff with very little margin for error.
                            Granted, it would be costly to increase physical margin, but in this
                            case, adopting a point of view more like _robotics_ could help. Even
                            in case of hardware failure, there's no reason to shut down the mind;
                            just go on with what you have.


                            --
                            __Pascal_Bourgu ignon__

                            Do not adjust your mind, there is a fault in reality.
                            Lying for having sex or lying for making war? Trust US presidents :-(

                            Comment

                            • Kenny Tilton

                              #44
                              Re: Python from Wise Guy's Viewpoint



                              Markus Mottl wrote:
                              [color=blue]
                              > In comp.lang.funct ional Kenny Tilton <ktilton@nyc.rr .com> wrote:
                              >[color=green]
                              >>Dennis Lee Bieber wrote:
                              >>[color=darkred]
                              >>> Short version: The software performed correctly, to specification
                              >>>(including the failure mode) -- ON THE ARIANE 4 FOR WHICH IT WAS
                              >>>DESIGNED.[/color][/color]
                              >
                              >[color=green]
                              >>Nonsense. From: http://www.sp.ph.ic.ac.uk/Cluster/report.html[/color]
                              >
                              >
                              > Dennis is right: it was indeed a specification problem. AFAIK, the coder
                              > had actually even proved formally that the exception could not arise
                              > with the spec of Ariana 4. Lisp code, too, can suddenly raise unexpected
                              > exceptions. The default behaviour of the system was to abort the mission
                              > for safety reasons by blasting the rocket. This wasn't justified in this
                              > case, but one is always more clever after the event...
                              >
                              >[color=green]
                              >>"supposed to" fail? chya.[/color]
                              >
                              >
                              > Indeed. Values this extreme were considered impossible on Ariane 4 and
                              > taken as indication of such a serious failure that it would justify
                              > aborting the mission.[/color]

                              Yes, I have acknowledged in another post that I was completely wrong in
                              my guesswork: everything was intentional and signed-off on by many.

                              A small side-note: as I now understand things, the idea was not to abort
                              the mission, but to bring down the system. The thinking was that the
                              error would signify a hardware failure, and with any luck shutting down
                              would mean either loss of the backup system (if that was where the HW
                              fault occurred) or correctly falling back on the still-functioning
                              backup system if the supposed HW fault had been in the primary unit. ie,
                              an HW fault would likely be isolated to one unit.

                              kenny


                              --

                              What?! You are a newbie and you haven't answered my:


                              Comment

                              • Steve Schafer

                                #45
                                Re: Python from Wise Guy's Viewpoint

                                On 20 Oct 2003 19:03:10 +0200, Pascal Bourguignon
                                <spam@thalassa. informatimago.c om> wrote:
                                [color=blue]
                                >Even in case of hardware failure, there's no reason to shut down the
                                >mind; just go on with what you have.[/color]

                                When the thing that failed is a very large rocket having a very large
                                momentum, and containing a very large amount of very volatile fuel, it
                                makes sense to give up and shut down in the safest possible way.

                                Also keep in mind that this was a "can't possibly happen" failure
                                scenario. If you've deemed that it is something that can't possibly
                                happen, you are necessarily admitting that you have no idea how to
                                respond in a meaningful way if it somehow does happen.

                                -Steve

                                Comment

                                Working...