You have to be really smart to code PHP!

In Terry Chay’s brilliant blog post about Rails and PHP, a comment read:

I agree, PHP is great, but you have to be really smart to remember 3000+ core functions, totally inconsistent function names, and writing non object-oriented nonsense like $x = some_function(’x’, ‘y’, $x) .. some of us just need something simple and logical.

I  agree.  So, if you are not smart, then stop coding PHP.  Its a good thing that C developers are smart.  They have to remember all those functions.  Assembly language developers don’t have to remember functions.  I guess they are not smart?

Ok, that last paragraph was tongue in cheek.  Knowing 3000+ functions does not make you smart.  It means you have a good memory.  I will take intelligence over smart or a good memory any day.  Intelligent people can use a manual to find the function they need right now and then forget it until they need it again.  If they need it enough, it will be set in their long term memory.

I also want to comment on “non object-oriented nonsense”.  Its good that working with objects means never having to call a function.  See, they call them methods.  And they don’t return stuff a lot of the time.  Its like magic.  Grow a set people.  How hard is $x = some_function($x,$y) to understand.  That is like the simplest programming concept in existence after $x=1.  OOP appears to make coding easier on the front end.  However, it almost always makes it more complicated on the back side.

As for inconsistent function names, I have no solid defense.  I understand why they are what they are.  But, that does not make it any easier on a new comer to the language.  Having experience in C, the functions that are direct ports of C functions (e.g. strcmp) make sense.  The PCRE functions make sense because I know that regular expressions have always been expressed in /search/replace/ format.  Image Magick functions are the way they are because the API calls they are making are in the same format.  That is what a lot of people don’t get about PHP.  Many of the functions you are calling are (or at some point were) direct ports of some C library function.  Therefore it makes sense to keep the function names and parameters in the same order as the API they are wrapping.  But, like I said, that is a weak defense.

About these ads

14 Responses to You have to be really smart to code PHP!

  1. Kaitnieks says:

    Surely you’re right about functions and methods, but I think the commenter had in mind languages like Java, which have nice editors that allow stuff like when you write “System.” a list of methods appear that apply to System. Wouldn’t it be cool if you could write “MySQL.” in your favourite php editor and get an autocomplete list of all mysql functions?

  2. doughboy says:

    Zend IDE does this. So does Eclipse with the PHP plugin. So does PHPEdit. The problem/nice thing about PHP is that you don’t HAVE TO HAVE a “nice editor” to use the language. And remember, this person was talking about Ruby on Rails, not Java. That was the subject of the post. I am not sure how many integrated IDEs there are for RoR.

  3. Rich Zygler says:

    Autocomplete for function names? Most PHP editors offer this, don’t they? I know Zend Studio does, which is what I use most.

  4. Uatu says:

    Even DreamWeaver does autocompletion on PHP. I use Eclipse with PDT plugin and it works like a charm. I don’t see any problem in the naming inconsistence, as any serious PHP programmer should be using a serious IDE already.

  5. Brian Moon’s Blog: You have to be really smart to code PHP!

  6. [...] Moon has posted some thoughts about “the post” that Terry Chay recently wrote including comments on smart versus [...]

  7. WhoreChurch says:

    I is not smurtz enuf 2 rite php’s an I is not dun manul cuz it got numbrs n stuf.

  8. chuck says:

    You don’t necessarily have to be smart to “remember 3000+ core functions, totally inconsistent function names,” and so on. But perhaps you have to be kinda dumb to want to. :D

  9. doughboy says:

    Which is why no intelligent PHP developer ever would. =)

  10. Coops says:

    I tried for three years. I gave up. I guess I’m not smart enough.

  11. [...] relate when I read this experience. Maybe you can. Programmers like the clean design of Rails and hate the messiness of PHP. Rails is like a rounded rectangle and PHP is like a ball of nails. All I’m asking is for a [...]

  12. Kaitnieks says:

    What I meant was – when you write a and press ctrl+space or whatever your autocomplete shortcut is in your php editor, you get a HUGE list of functions, all that start with “a”. You can’t really get, for an example, a list of math functions only as you could with “Math.a + ctrl + space”.

  13. [...] here it is the full article from which is taken this quote. read it – you’ll enjoy it [...]

  14. [...] Brian Moon of DealNews puts it, You have to be really smart to code PHP. [...]

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: