Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: Programing Made Simple

  1. #21
    Join Date
    Jan 2004
    Posts
    2,011
    Rep Power
    0

    Default

    yeh please explian. my only true problem with php is that it doens't have true data encapsulation with its default classes butif you use smarty all that criss and you dont have to worry bout a thing. suh what you talking bout.

  2. #22
    Join Date
    Aug 2002
    Posts
    1,236
    Rep Power
    0

    Default

    I recently did some PHP work and had the frustrating experience of trying to work within the limitations of the available datatypes.

    Please correct me if I'm wrong. PHP is all about arrays and associative arrays.

    In order to find out if an associative array contained a key the code was like:

    Code:
    <?php
    
    $peterpiper = array();
    $stuffofpeter = array();
    $peterpiper['had'] = $stuffofpeter;
    array_push($peterpiper['had'],'peck','of pickled peppers');
    
    if (array_key_exists('had',$peterpiper)){
       echo "peter piper picked a " . $peterpiper['had'][0] .
                      " of " .  $peterpiper['had'][1];
    }
    foreach ($peterpiper['had'] as $peter_piper) {
       if ($peter_piper == 'of pickled peppers'){
    
          echo "<hr>if peter piper picked a peck $peter_piper,";
          echo "<hr>where's the peck $peter_piper, 
                                            peter piper picked?";
        }
    }
    
    ?>
    note the extra functions required:
    array_push() and array_key_exists()
    This is typical of php, lots of extra functions.

    I don't like needing to research new functions because the language doesn't support what I want to do out of the box.

    To be fair it's easy to google for the code you need.

    here's the python version
    Code:
    peterpiper={}
    peterpiper['had']=['peck','of pickled peppers']
    
    if peterpiper['had']:
         print "peter piper picked a " + peterpiper['had'][0] + \
                  " of " +  peterpiper['had'][1]
    
    for peter_piper in peterpiper['had']:
        if 'of pickled peppers' in peter_piper:
            print "<hr>if peter piper picked a peck " + peter_piper
            print "<hr>where's the peck " + peter_piper + \
                    " ,peter piper picked?"
    Learn more from python programmers at the Jamaica Python Users Mailing List http://python.zope.com.jm/subscribe
    Last edited by pigeonflight; Jun 22, 2006 at 08:33 AM.
    Zope, Linux, Web, Intranet
    www.plone.org

  3. #23
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default

    Lame! The problem is you don't know enough about PHP you recomend or even compare it to anything. The extra array functions are necessary in order to allow you to WRITE BETTER PROGRAMS. You need better examples to prove your point. More functions allow for programming freedom. There is no one way to do anything.

    Basically the 2 pieces of code that you posted are identical. Even though the php one is more readable.

    Code:
    <?php
    
    $peterpiper = array();
    $peterpiper['had']= array('peck','of pickled peppers');
    
    if ( isset($peterpiper['had']) )
      if( is_array($peterpiper['had']) ){
       echo "peter piper picked a " . $peterpiper['had'][0] .
                      " of " .  $peterpiper['had'][1];
     }
    
    foreach ($peterpiper['had'] as $key=>$value) {
       if ($value == 'of pickled peppers'){
          echo "<hr>if peter piper picked a peck $value,";
          echo "<hr>where's the peck $value, 
                                            peter piper picked?";
        }
    }
    
    ?>
    You need to learn more PHP. Register at my site and look at the source code.

    Learn more from python programmers at the Jamaica Python Users Mailing List http://python.zope.com.jm/subscribe

  4. #24
    Join Date
    Jan 2004
    Posts
    2,011
    Rep Power
    0

    Default

    i just love that look that zope sites have. wish i took plone and zope more serious when the frame work was just released.

    as of late i'm only interested in frameworks cause i'm sick of the age old method of development (ground up design). also i hate the crud ops.. (creation retrieval updating and deletion) by far the most repetitive type of code i find my self doing. turbo gears, which is python based, prado (php based object oriented framework ) everybody done know bout the popular ruby on rails, there's django (which runs on pythong as well)

    and something that caught my eye th4e other day. open laszlo it sorta seems like an open sourcce implementation of macromedia's flex... frameworks ar our future (programers)

  5. #25
    Join Date
    Aug 2002
    Posts
    1,236
    Rep Power
    0

    Default

    Quote Originally Posted by owen
    Lame! The problem is you don't know enough about PHP you recomend or even compare it to anything. The extra array functions are necessary in order to allow you to WRITE BETTER PROGRAMS. You need better examples to prove your point. More functions allow for programming freedom. There is no one way to do anything.

    Basically the 2 pieces of code that you posted are identical. Even though the php one is more readable.
    Perhaps I should start again.

    1. The reason I used arrays was in order to WRITE A BETTER PHP PROGRAM, I am thankful that PHP HAS arrays.
    2. I found it akward to work with arrays when compared to working with dictionaries (comparable to associative arrays),lists(comparable to arrays) and tuples (not sure what to compare this to) in Python.

    I have found the data structures in python simpler to manipulate. Again, please correct me if I'm wrong about this.

    Your version of the code does clear up a few things, for example, I didn't need to assign the second array to a variable silly me.

    BTW... what's Lame about my assessment?
    Zope, Linux, Web, Intranet
    www.plone.org

  6. #26
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default

    Quote Originally Posted by pigeonflight
    Perhaps I should start again.

    1. The reason I used arrays was in order to WRITE A BETTER PHP PROGRAM, I am thankful that PHP HAS arrays.
    2. I found it akward to work with arrays when compared to working with dictionaries (comparable to associative arrays),lists(comparable to arrays) and tuples (not sure what to compare this to) in Python.

    I have found the data structures in python simpler to manipulate. Again, please correct me if I'm wrong about this.

    Your version of the code does clear up a few things, for example, I didn't need to assign the second array to a variable silly me.

    BTW... what's Lame about my assessment?
    there is this data structure called a "pointer". Its lame because you complaining about minor differences in data structure names. A dictionaries = lists = tuples = pointers = strings = integers its all symantics. Some people just like their chicken fried and some people like eggs.

  7. #27
    Join Date
    Dec 2002
    Posts
    500
    Rep Power
    0

    Default

    python and php sux!

    dont answer that...
    Cultured in Aggression and Koding like a Warrior!!
    “Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
    "The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •