In my opinion, the Python equivalent of your pseudo-code is fairly close to
how you would write the instructions logically. But then maybe not everyone
thinks in the same way that I do :-)

for x in range(1, 10):
  if age_of_person(x) > 50:
    print name_of_person(x), "is an old man (or woman)"

Of course you would have to define the functions age_of_person() and
name_of_person() in order for this to work, or you could write it in a more
object-oriented method so you have a "Person" object which has attributes
name, age, gender, etc. and the code would be even more readable.

for person in list_of_people:
  if person.age > 50:
    print person.name, "is an old ", person.gender

Disclaimer: I mainly write in Python, so obviously am naturally biased
towards Python, however I have yet to see another widely used language that
is as readable or intuitive to learn (to me).

Cheers,

Richard

--

Richard Gildea

Software Developer
Physical Biosciences Division
Lawrence Berkeley National Laboratory
1 Cyclotron Rd
Mail Stop 64R0121
Berkeley
CA 94720-8118



On 13 September 2012 10:02, Patrick Shaw Stewart <patr...@douglas.co.uk>wrote:

>
> Like most computer users and many scientists I don't write scripts to
> organize or analyse my data unless I get desperate.  I've used both Python
> and Perl a few years ago, but it would take quite a lot of time and effort
> and staring at on-line tutorials to get back into either of them right now.
>  So I end up using massive Excel files that kind of work, but are a pain.
>  I've noticed that quite a few structural biologists have the same problem.
>
> I've never understood why there can't be a simple programming language
> that is completely self-explanatory bercause it uses English sentences.
>  Our robot scripting language uses syntax like
>
> Dispense 0.5 * DropVol ul to TargetWells using ProteinSyringe
>
> That is pretty obvious.
>
>
> So why can't I have a language where I can write
>
>
> Carry_out_a_sequence_where
>
>  x is 1 to 10
>
> with_step_size 1 :
>
> if
> age of person(x) is_greater_than 50
>  then
> print name of person(x) "is an old man (or woman)" .
>
> Repeat_for_next x .
>
>
> ?
>
>
> I don't care if it's efficient (anything is efficient compared to Excel)
> or if it's easy to write big programs in.  All I care about is that it's
> easy to get going.
>
> Later on I can learn to write simply "Sequence" instead of
> "Carry_out_a_sequence_where".  I could click a button that would make the
> replacement to make my code more compact and readable to a trained eye.
>  And of course  is_greater_than  could be written as  > .
>
> Any intelligent school-child could understand it too, which would be
> fantastic here in the UK where kids aren't taught to program any more.
>
> Does such a language exist?
>
>
>
>
>
> On 13 September 2012 17:08, James Stroud <xtald...@gmail.com> wrote:
>
>>
>> On Sep 13, 2012, at 3:24 AM, Tim Gruene wrote:
>>
>> I have the impression that
>> python programmers spend a lot of effort in trying to convince others
>> that python is a "good" choice. Why bother rather than let people make
>> their own decision?
>>
>>
>> Someone asked.
>>
>> Plus, python programmers put no more effort than any other programmer.
>> It's just that python has more advocates (for good reason) so the apparent
>> effort is amplified.
>>
>> Don't hate us because our preferred programming language is beautiful.
>>
>> James
>>
>>   --
>> James Stroud
>>
>> http://www.jamesstroud.com
>>
>>
>
>
> --
>  patr...@douglas.co.uk    Douglas Instruments Ltd.
>  Douglas House, East Garston, Hungerford, Berkshire, RG17 7HD, UK
>  Directors: Peter Baldock, Patrick Shaw Stewart
>
>  http://www.douglas.co.uk
>  Tel: 44 (0) 148-864-9090    US toll-free 1-877-225-2034
>  Regd. England 2177994, VAT Reg. GB 480 7371 36
>
>

Reply via email to