Choosing Perl/Python for my particular niche

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fred Ma

    #31
    Re: Appreciation for the importance of readability (was: ChoosingPerl/Python for my particular niche)

    Michele Simionato wrote:[color=blue]
    >
    > 1. we want to spend at most 5% of our time doing coding and 95% doing
    > science;
    > 2. our group is composed by two persons and our code will never be
    > released;
    > 3. if a Ph. D. student reach the group and has to study the code, we
    > will explain it to him in person;
    > 4. the largest program we will ever write is a thousand lines long;
    > for the rest we will use standard routines and write as little code
    > as possible;
    > 5. we don't care at all about fancy graphics: the output will be a list
    > of numbers write on a file and displayed by gnuplot;
    > 6. all we care is numerical performance in floating point computations;
    > the logic of the program will be trivial.
    >
    > They actually used old fashioned Fortran 77 and I think they made the perfect
    > choice given their requirements; they essentially had to do numerical
    > integrations and solving differential equations, tasks were Fortran is
    > incredibly strong. Other persons I know doing particle Physics and doing a
    > good deal of programming (good deal means something like 50% of their time
    > spent on programming; spending more than 50% means that you are actually
    > a programmer, and scientists don't want to do that) were using a mixture
    > of Fortran and C. Here I am referring to people doing numerically
    > intensive tasks; I have seen a trend to switch to C++ for large projects,
    > since there is a perception than C++ scales better than Fortran. In
    > any case, the core routines are still in Fortran and always will be.
    > For scripting tasks, scripting languages are used; I know a few
    > astronomers who were using Perl to control the telescope movement.
    > Many physicists/astronomers use Python too. Specialized languages
    > and tools (Mathematica, Maple, Matlab, Octave, Yorick, etc. etc.)
    > have their place.[/color]


    I want to start by emphasizing that I don't disagree with you.
    I've spent a great deal of a previous degree in solution
    methods for couple PDEs, as well as problem formulations that
    come up with PDEs. I know of the tools that you mentioned.

    I would like to point out that many science problem are not
    as much numerically based. Many of them can be regarded still
    as "physically " based science. For example, physical design
    phase of digital circuit design relies on optimization
    algorithms, albeit applied to a specialized class of problems.
    There are genetic algorithms that evolve neural nets for
    various applications (many of them physically based). These
    less numerical applications use more abstraction in computational
    models, so C++ has a place for these.

    Of course, it is arguable that the computation models and
    methods are a separate thing from the physical problems
    that motivate them. So it all depends on how each person
    interprets "science".

    Fred

    Comment

    • Charlton Wilbur

      #32
      Re: Choosing Perl/Python for my particular niche

      >>>>> "CL" == Cameron Laird <claird@lairds. com> writes:

      CL> Try 'em both briefly, choose one that makes a
      CL> good impression, and get back to your engineering work.
      CL> You'll be glad you upgraded to a 'P' language.

      You, sir, have written a clear, fair-minded, and reasonable post. The
      Backbone Cabal will be revoking your Usenet license shortly.

      (I concur, by the way: Python has a couple of traits that would drive
      me, with close to 10 years of Perl experience, bonkers; but they don't
      drive everyone bonkers, and they obviously suit some people, or they
      wouldn't be in the language. The OP ought to spend a couple weeks
      playing with each language and pick the one that seems to suit his
      style better.)

      Charlton

      --
      cwilbur at chromatico dot net
      cwilbur at mac dot com

      Comment

      • Fred Ma

        #33
        Re: Choosing Perl/Python for my particular niche

        Charlton Wilbur wrote:[color=blue]
        >[color=green][color=darkred]
        > >>>>> "CL" == Cameron Laird <claird@lairds. com> writes:[/color][/color]
        >
        > CL> Try 'em both briefly, choose one that makes a
        > CL> good impression, and get back to your engineering work.
        > CL> You'll be glad you upgraded to a 'P' language.
        >
        > You, sir, have written a clear, fair-minded, and reasonable post. The
        > Backbone Cabal will be revoking your Usenet license shortly.
        >
        > (I concur, by the way: Python has a couple of traits that would drive
        > me, with close to 10 years of Perl experience, bonkers; but they don't
        > drive everyone bonkers, and they obviously suit some people, or they
        > wouldn't be in the language. The OP ought to spend a couple weeks
        > playing with each language and pick the one that seems to suit his
        > style better.)[/color]

        Well, it looks like trying them both out in the long term is in fact
        what I'll be doing. Thanks.

        Fred
        --
        Fred Ma
        Dept. of Electronics, Carleton University
        1125 Colonel By Drive, Ottawa, Ontario
        Canada, K1S 5B6

        Comment

        • Peter Hickman

          #34
          Re: Choosing Perl/Python for my particular niche

          Fred Ma wrote:[color=blue]
          > I appreciate the sed terseness because
          > I can make a command line pipe stage out of it, but
          > the same brevity in a scripting language can make for
          > rough going.[/color]

          Both perl and python will allow you to do this. in perl

          #!/usr/bin/perl
          while(<>) { print uc $_; }

          this script will read from stdin and write an uppercased version of the
          input to stdout and can be used in a pipeline.

          You can to the same in python and of course the guts of the loop can be
          as big or small as you like. There is also a s2p tool that converts sed
          scripts into perl, but rewiting would be a better bet as s2p can produce
          some crufty code.

          To be honest you could just flip a coin and go with that if you have no
          specific requirements.

          Perl may be easier to sell to your boss than python but if you just went
          ahead with it you could use anything.

          Comment

          • Robin Munn

            #35
            Re: Choosing Perl/Python for my particular niche

            Fred Ma <fma@doe.carlet on.ca> wrote:[color=blue]
            > Hello,
            >
            > This is not a troll posting, and I've refrained from
            > asking because I've seen similar threads get all
            > nitter-nattery.[/color]
            [snip: poster is basically asking "Should I learn Perl or Python?"]

            While availability of libraries for your specific tasks is a major
            factor to take into consideration, I'd say that even more important is
            to figure out which language fits your brain.

            I first learned Perl, then Python. I now use Python almost exclusively,
            because I found that Python fits my mental "map" much better than Perl
            does. To me, it seemed like in Perl, everything was a string. Sure, you
            could have objects and classes, but they felt strange and awkward -- how
            do I translate the "bless" keyword into my mental model? Whereas
            Python's object model translated perfectly into my mental map, to the
            point where programming in Python gave a clarity that I never had when
            using Perl. It's hard to explain why, exactly -- it just seemed like
            when using Perl, I was always going back down to the level of details,
            the trees in the forest. Python allows me to look at the entire forest.
            I can still go down and look at trees if I need to, but I don't have to
            operate in that mode all the time.

            Your mileage *will* vary. There's no substitute for experience. Set
            yourself a simple task (say, writing a sieve of Eratosthenes program)
            that you could do in about an hour with a language you're familiar with.
            Then write the same program in Perl and in Python, and see which one
            fits *your* brain better.

            --
            Robin Munn
            rmunn@pobox.com

            Comment

            • Fred Ma

              #36
              Re: Choosing Perl/Python for my particular niche

              Peter Hickman wrote:[color=blue]
              >
              > Fred Ma wrote:[color=green]
              > > I appreciate the sed terseness because
              > > I can make a command line pipe stage out of it, but
              > > the same brevity in a scripting language can make for
              > > rough going.[/color]
              >
              > Both perl and python will allow you to do this. in perl
              >
              > #!/usr/bin/perl
              > while(<>) { print uc $_; }
              >
              > this script will read from stdin and write an uppercased version of the
              > input to stdout and can be used in a pipeline.
              >
              > You can to the same in python and of course the guts of the loop can be
              > as big or small as you like. There is also a s2p tool that converts sed
              > scripts into perl, but rewiting would be a better bet as s2p can produce
              > some crufty code.
              >
              > To be honest you could just flip a coin and go with that if you have no
              > specific requirements.
              >
              > Perl may be easier to sell to your boss than python but if you just went
              > ahead with it you could use anything.[/color]


              Hi, Peter,

              My boss is my thesis supervisor. I'm going with Perl and keeping a
              tab on Python. I expect to do most of my hacking in Perl, since I
              see it around everywhere, composing in Python, and one-liners in
              Perl/sed. About invoking Perl as part of a simple command in a
              pipeline, I mean that one doesn't even have to write a script for it,
              similar to sed

              Command1 | sed -e Expression1 -e Expression2 ... | Command_N

              This might also be possible in Python, in which case so much the better.
              I'll find out (or someone might answer in a follow-up post). Thanks
              for your view on the two.

              Fred
              --
              Fred Ma
              Dept. of Electronics, Carleton University
              1125 Colonel By Drive, Ottawa, Ontario
              Canada, K1S 5B6

              Comment

              • Fred Ma

                #37
                Re: Choosing Perl/Python for my particular niche

                Robin Munn wrote:[color=blue]
                >
                > Fred Ma <fma@doe.carlet on.ca> wrote:[color=green]
                > > Hello,
                > >
                > > This is not a troll posting, and I've refrained from
                > > asking because I've seen similar threads get all
                > > nitter-nattery.[/color]
                > [snip: poster is basically asking "Should I learn Perl or Python?"]
                >
                > While availability of libraries for your specific tasks is a major
                > factor to take into consideration, I'd say that even more important is
                > to figure out which language fits your brain.
                >
                > I first learned Perl, then Python. I now use Python almost exclusively,
                > because I found that Python fits my mental "map" much better than Perl
                > does. To me, it seemed like in Perl, everything was a string. Sure, you
                > could have objects and classes, but they felt strange and awkward -- how
                > do I translate the "bless" keyword into my mental model? Whereas
                > Python's object model translated perfectly into my mental map, to the
                > point where programming in Python gave a clarity that I never had when
                > using Perl. It's hard to explain why, exactly -- it just seemed like
                > when using Perl, I was always going back down to the level of details,
                > the trees in the forest. Python allows me to look at the entire forest.
                > I can still go down and look at trees if I need to, but I don't have to
                > operate in that mode all the time.
                >
                > Your mileage *will* vary. There's no substitute for experience. Set
                > yourself a simple task (say, writing a sieve of Eratosthenes program)
                > that you could do in about an hour with a language you're familiar with.
                > Then write the same program in Perl and in Python, and see which one
                > fits *your* brain better.[/color]


                Well, my bout with Perl took much, much more than an hour.
                It worked, though. It's probably not enough experience to
                get a good look at the strength of Perl. For example, I
                am a vim user (an editor), which is cryptic at first, but
                let's you fly when you get to know it. I'm not saying that
                all things cryptic are efficient in the end, just that a
                brief bout won't always uncover the strengths. As a
                "working model", I've decided to use Perl as the workhorse,
                and keep tabs on Python as time permits. If my mental map
                works better with Python, it's ease of ramping up will
                allow the better fit to shine through despite the lesser
                time I spend with it. Then it will naturally take a more
                prominent role. Thanks for the advice on checking out both.
                It seems to be the most realistic, and in line with what
                many have suggested.

                Fred
                --
                Fred Ma
                Dept. of Electronics, Carleton University
                1125 Colonel By Drive, Ottawa, Ontario
                Canada, K1S 5B6

                Comment

                • U-CDK_CHARLES\\Charles

                  #38
                  Re: Choosing Perl/Python for my particular niche

                  On 30 Mar 2004 22:23:50 GMT, Fred Ma <fma@doe.carlet on.ca> wrote:[color=blue]
                  > Robin Munn wrote:[color=green]
                  >>[/color]
                  >
                  > Well, my bout with Perl took much, much more than an hour.
                  > It worked, though. It's probably not enough experience to
                  > get a good look at the strength of Perl.[/color]

                  Well, here's two cents American, leaving the exchange calculation as an
                  excercise for the reader.

                  My first task at my last job was to automate a test that could run from
                  the Solaris prompt. Knowing C, I tried to script it in csh, which
                  proved difficult--redirecting stderr was needlessly convoluted.

                  Then I read "csh scripting considered evil" and decided to give the
                  Bourne shell a whirl. Though the syntax had a learning curve, once I
                  cracked that nut, the project "Just Worked."

                  Being a C programmer (embedded systems mostly) it was "Easy" to learn to
                  use Python as "C without the compile"

                  It took some playing before I realized the strength of Python as a
                  prototyping language and stopped trying to write C code in Python.

                  Of course, NOW I'm trying to learn how NOT to write C++ code in
                  VisualBasic, so go fig.


                  Comment

                  • Cameron Laird

                    #39
                    Re: Choosing Perl/Python for my particular niche

                    In article <4069F371.B4D08 F58@doe.carleto n.ca>,
                    Fred Ma <fma@doe.carlet on.ca> wrote:

                    Comment

                    • Cameron Laird

                      #40
                      Python from the command line (was: Choosing Perl/Python for my particular niche)

                      In article <4069F1FD.601C9 079@doe.carleto n.ca>,
                      Fred Ma <fma@doe.carlet on.ca> wrote:

                      Comment

                      • Fred Ma

                        #41
                        Re: Python from the command line (was: Choosing Perl/Python for myparticular niche)

                        Cameron Laird wrote:[color=blue]
                        >
                        > In article <4069F1FD.601C9 079@doe.carleto n.ca>,
                        > Fred Ma <fma@doe.carlet on.ca> wrote:
                        > .
                        > .
                        > .[color=green]
                        > >Perl/sed. About invoking Perl as part of a simple command in a
                        > >pipeline, I mean that one doesn't even have to write a script for it,
                        > >similar to sed
                        > >
                        > > Command1 | sed -e Expression1 -e Expression2 ... | Command_N
                        > >
                        > >This might also be possible in Python, in which case so much the better.
                        > >I'll find out (or someone might answer in a follow-up post). Thanks[/color]
                        > .
                        > .
                        > .
                        > # python -c "print 3 + 5"
                        > 8[/color]

                        I was 99.99% sure that it was possible (heck, if tcsh and bash can do
                        it, python surely can). It's a little easier to squish it into a simple
                        command in a pipeline for a terse/compact "language" e.g. sed. On a
                        side-note, I've abused sed before by embedded sed scripts into bash
                        scripts without actually writing the sed script:

                        Bash_Command | \
                        sed \
                        -e 'Expression1' \
                        -e 'Expression2' \
                        -e 'Conditional1 {' \
                        -e 'Body_of_Condit ional1' \
                        -e 'More_of_Body' \
                        -e '}' \
                        | More_Bash_Comma nds

                        Not that I want to do everything in sed, of course. And for
                        perl/python, there is probably not much reason to mix commands
                        with bash, since (unlike sed) they have the shell functionality.

                        I've put in a request to my sysadmin to install python. The
                        way to get hooked on it is to start small, with mundane tasks
                        (same as with any new shell, I suppose). If it doesn't get
                        installed due to lack of priority, I can always get it
                        bundled with my next cygwin update. Cygwin is an absolute
                        blessing. Everything comes prebuilt (lots of stuff) and
                        you have superuser priveleges, as well as simultaneous
                        access to Windows. Just as long as your HDD isn't FAT
                        (that prevents chmod from working).

                        But I digress.....

                        Fred

                        --
                        Fred Ma
                        Dept. of Electronics, Carleton University
                        1125 Colonel By Drive, Ottawa, Ontario
                        Canada, K1S 5B6

                        Comment

                        • Cameron Laird

                          #42
                          Re: Python from the command line (was: Choosing Perl/Python for myparticular niche)

                          In article <406BB6C4.7F3AD D4@doe.carleton .ca>,
                          Fred Ma <fma@doe.carlet on.ca> wrote:

                          Comment

                          • Fred Ma

                            #43
                            Re: Python from the command line (was: Choosing Perl/Python for myparticular niche)

                            Cameron Laird wrote:[color=blue]
                            >[color=green]
                            > >I've put in a request to my sysadmin to install python. The
                            > >way to get hooked on it is to start small, with mundane tasks
                            > >(same as with any new shell, I suppose). If it doesn't get
                            > >installed due to lack of priority, I can always get it
                            > >bundled with my next cygwin update. Cygwin is an absolute
                            > >blessing. Everything comes prebuilt (lots of stuff) and
                            > >you have superuser priveleges, as well as simultaneous
                            > >access to Windows. Just as long as your HDD isn't FAT
                            > >(that prevents chmod from working).[/color]
                            >
                            > Oh! Apparently Win* is the platform of interest; that
                            > hadn't occurred to me.
                            >
                            > There's a LOT to say specifically on the topic of Python-
                            > for-Windows-system-administration. You might want to
                            > start with Mark Hammond's book.
                            >
                            > I'm no great fan of CYGWIN for my own use, although I
                            > certainly recognize it's been historically important.
                            > It occurs to me that perhaps we haven't made adequately
                            > clear how easy it is to install native Python on Windows.
                            > It should take less time doing it than talking about do-
                            > ing it. I'm not arguing with your approach; I just want
                            > to ensure we've been clear about the alternatives.[/color]


                            Actually, didn't mean to cause a great deal of confusion here,
                            but solaris is the main platform. But I access solaris boxes
                            from a PC. And since I have a mapped network drive, I can use
                            PC tools to work on my unix files.

                            I agree, installing stuff on windows is easy. My comment about
                            cygwin is that it's even easier than easy. I just have to check
                            off the Python box. That gives me opportunity to try it for
                            small things.

                            By no means am I comparing cygwin to other unix environments for
                            the PC. I enjoy it out of convenience. Most of my stuff is on
                            the solaris, and cygwin gives me a nice posix shell without
                            leaving the windows environment.

                            Fred
                            --
                            Fred Ma
                            Dept. of Electronics, Carleton University
                            1125 Colonel By Drive, Ottawa, Ontario
                            Canada, K1S 5B6

                            Comment

                            Working...