Betsy Devine: Funny ha-ha and/or funny peculiar

Making trouble today for a better tomorrow…

Betsy Devine: Funny ha-ha and/or funny peculiar header image 4

Me and PHP and Mrs. Robinson

November 10th, 2003 · 9 Comments

MrsRobinsonLeg: Naughty display of leg shocks innocent youth, famous scene from The Graduate.

PHP for Dummies now sits on my bedside table–but it’s way too shocking for any late night reading.

Coming to PHP from the genteel, dignified world of C++ and Java is like walking into a room and discovering–Mrs. Robinson! What are you doing?

In Java, defining a variable is something that happens only after long, dignified courtship. Not even porcupines mating are so careful. The imports, the classes, the public static void main (String args [] )–and then finally, after many a bouquet of roses, you’re ready to beg the favor of, please–let me define a variable or two.

Then you have to spell out what you want, to Java’s complete satisfaction:

int number1 = 1;
String dontSayNo = “please”;
String beggingYouNotToSayNo [] = {”pretty”, “pretty”, “please?”};

Wooo–PHP doesn’t care about stuff like that:

$one_variable = 5;
$another_variable = -2.55;
$yet_another_variable = “Just show me that dollar sign, I’m there!”;

OK, that was my shock yesterday–this is today. Today I told Scott Johnson, who’s teaching me this stuff, “Mrs. Robinson just took off her skin and showed me her skeleton–I’m declaring arrays!”

In Java or C++, you have to set aside all the space you need before you start filling arrays. But PHP has that same “Hey–why not?” attitude. You can start an array, throw a couple of elements in it, and then decide later you want to add several more.

What a whole new world of freedom–it’s like being able to say, “Mom, I’m bringing a friend for dinner…” Then you show up with 7 friends, a puppy, plus (Scott adds) a parakeet and a goldfish–and Mom says, “Hey, no problem, who ever runs out of spaghetti?”

When I grow up, I want to be PHP!


Tags: Feedster

9 responses so far ↓

  • 1 Brendyn // Nov 10, 2003 at 10:49 pm

    god bless php and its loosely typed variables :)

    then again, with strongly typed data types, you tend to know what’s holding what. But, it’s also convenient to be able to say

    $myVar = 1;

    Then take in some user input and say:

    $myVar = “string”;

    Not sure that’s the most efficient thing to do (or the safest), but it’s flexible in terms of that if you ever want to use a variable to possibly hold more than one datatype :)

  • 2 jr // Nov 11, 2003 at 4:11 am

    When Betsy Devine passed beyond
    after having 120 years rode
    They opened her up to see whats inside
    and found a tangle of spaghetti code.

  • 3 Betsy Devine // Nov 11, 2003 at 4:45 am

    Brendyn–Yeah, and loose-typing is more tolerant of typos. jr–I’m told that really bad code is immortal.

  • 4 jr // Nov 11, 2003 at 5:36 am

    Bad poetry aside…

    Problem with “variant” data types is when they are used in assignment. Then your at the mercy of whoever wrote the interpreter.

    $var1=”Betsy”

    $var2=1

    $var3=var1+var2 Could return “Betsy1” in var3

    while

    $var3=var2+var1 Could return 1 in var3 not “1Betsy”

    Depends on which variable is looked at first.

  • 5 fp // Nov 11, 2003 at 3:08 pm

    eeeeuuuuwwwww….

    code!

  • 6 Betsy Devine // Nov 11, 2003 at 5:48 pm

    Hey, FP, I put up with post-modernism because I love reading your site–you might have to tolerate some code on mine.

  • 7 Fran // Nov 13, 2003 at 11:37 am

    Betsy

    Untyped variables are quite a congnitive shift when you have been working in typed languages. Personally I prefer the discipline that comes with a typed language, so I dont have to remember what type a variable was in. For my search engine, I evolved my own hungarian notation for variables names, something that is lacking in Java (which does not really matter though since the compiler enforces typing in a draconian fashion). All that being said, I do prefer Perl as my untyped scripting language. It it a little stricter than PHP, offers an object model and has a wealth of modules available for it at the CPAN archives.

  • 8 fp // Nov 13, 2003 at 1:44 pm

    Would an untyped variable be written in cursive?

  • 9 Scott Johnson // Nov 16, 2003 at 5:13 am

    >> Then your at the mercy of whoever wrote the interpreter.

    That’s always the case in ANY language of ANY type.

    I’m divided on this point while I love the flexibility of untyped variables, if I could add it optionally to PHP, I probably would.