There, I said it.
I know it’s fashionable to mock PHP for its antiquated syntax and semantic quirks, but I just like it. Here is why.
PHP is like C
This is really the main point of this post, and it’s a realization so simple that I’m surprised not more people made it. I have often observed that developers mocking PHP tend to be much more positive when I ask them about C.
“C is alright, it’s not OO but it was designed with a simple goal in mind and it does that very well. It’s straightforward and very well documented”.
Does that remind you of another language? That’s right, PHP! PHP is exactly like C. Either you like both or you don’t like either, there is no claim you can make about PHP that can’t be made about C as well, and vice versa. PHP was created with one very simple goal in mind: enabling the insertion of programming logic in web pages. And it does this fantastically well.
The absence of OO functionalities in both languages is a bit of a bummer (PHP 5 tried to address that with mixed success), but with some discipline, it’s really not hard to reach a reasonable architecture for your programs.
PHP never let me down
I write PHP code very sporadically, whenever I need to update one of my web sites or when I need to put together a small piece of web functionality that requires some programming. I am familiar with the PHP syntax but I don’t know much of its API, because I use it so rarely, so I pretty much need to relearn it from scratch each time. Whenever I need to get something done, I spend a decent amount of that time looking up docs on Google. And PHP absolutely shines in this area. It’s not just that looking up a function name will give you its API documentation as a first hit, but you can literally type what you need in English (e.g “most recent file in PHP”) and it’s very likely that you will find how to do it in just a few clicks.
You can even misspell function names (see for example the result of my incorrect query for strtime) and you will still land in the right place.
PHP is robust
I know it sounds silly considering how primitive and old the language is, but the bottom line is that code that I wrote more than ten years ago has been working absolutely flawlessly and without any changes for all that time. I don’t even bother writing tests for most of the PHP I write (obviously, I would be a bit more thorough if this code were destined to be used in a more mission critical web site). Not writing tests is not the only software taboo that I break when I write PHP: I happily mix up presentation and logic all the time. That’s just how PHP is supposed to work, and when the site you are working on is low volume and only of interest to a very tiny fraction of users, you probably don’t want to spend too much time on tasks that look overkill.
PHP’s documentation is great
It’s hard to pinpoint what exactly makes PHP’s online documentation so useful. It’s probably a mix of the content, the syntactically colored code samples, the CSS and most of all, the examples at the bottom. These are absolutely priceless and I don’t understand why not all API documentations do this.
Whether you are looking up an API function or a UNIX command, the first thing you want to see is examples, not a laundry list of its options and switches or a formal definition of its parameters. Very often, reading the example is all you need to carry on with your work and you can always read the more formal documentation if you want to use the function in a more advanced manner.
Universal support
Most Internet providers offer PHP support out of the box, so you don’t need to resort to more expensive VPS providers. I have yet to see this kind of universal support for any other language than PHP. Not even Ruby on Rails, let alone Java, is available on mainstream providers, thereby validating the claim I made five years ago that Ruby on Rails won’t become mainstream (I regularly receive emails about this article asking me this question, and I keep responding “Nope, still not mainstream”).
High reward
There is nothing more exciting than modifying a file, hitting Refresh on your browser and seeing the result right away. This brings me back to the very first days that I started experimenting with a web browser, more than fifteen years ago. Modifying an HTML file and seeing the result almost instantly hasn’t lost its appeal, and PHP is certainly continuing the tradition.
Sometimes, I don’t even bother editing the files locally and then transferring them: I ssh to my server and modify the files live. If something goes wrong, git makes sure that I can always back up my changes very easily. By the way, the combination of git’s branches and PHP is very powerful, allowing you to switch between entire web sites with just one command.
Conclusion
Even though writing in PHP always feels like going back in time, I’m never reluctant to doing it because I know that it will be rewarding and relatively easy. PHP has by far the highest “Get in, code, get out” factor that I have found in a language, and until another language comes around that can do better on this scale, I will be using PHP for many more years to come.
Update: Discussion on Hacker News, reddit and Google+
#1 by Pascal Bleser on August 9, 2011 - 11:13 am
Myeaah, myeah… kinda… Sure, quite a few things are nice about it, I agree on the documentation and just-press-reload bits. Although in terms of finding examples just by googling, I would tend to say that it works almost equally well with Java, or Perl, or Python. Stackoverflow has been helping a lot with that too, lately.
There is a point where I really, really prefer having a Java based framework such as Wicket (for example) — obviously not the bloat horror of JSPs, or JSF.
Eclipse with static typing, with instant compilation while you write the code, the ability of using the compiler for strong contracts and catching a lot of errors right while you’re coding, and not when running it, and there are lots and lots of opensource libraries for Java.
Yes, PHP comes bundled with a large amount of stuff, which I believe is one of the main reasons for its success.
But I believe that you get even more for Java, a lot more.
So it’s always a question of tipping point. For me it’s usually somewhere along the curve of bash -> perl -> python, maybe -> java
Having Java with just-hit-refresh would be awesome though. Some frameworks implement it, or try to, and then there’s JRebel but still…
#2 by Pascal Bleser on August 9, 2011 - 11:15 am
I’ve recently been hacking a bit on Drupal modules again (have written and modified a few in the past).
Sure, the framework is pretty nice, and you can do pretty nice things with minimal effort thanks to its hook system.
And there is no question that the huge success of Drupal comes at least in significant part from the fact that it’s in PHP and has a lower barrier than if it was written in Java.
But.. hmh… when it gets a little more complex, when you need to do some debugging.. Damn.. I wished it was in Java, with an even more helpful framework, where the compiler can already help you on the way there…
#3 by noah on August 9, 2011 - 11:17 am
PHP is great for its purpose. Quick scripts that generate web content. It’s even OK for small applications. But just like C, PHP is lousy for the medium to large. Any software project with a duration in months or greater that is entirely in PHP is going to be painful.
#4 by Maurizio on August 9, 2011 - 11:41 am
PHP has a negative fame due to a lot of novice developers abusing the language. I agree, it’s not the best for large projects, but it’s not its scope: if you keep it in the presentation layer, as it should be, it can do its job.
With a little help from mature components libraries, like the Zend framework, it is possible to manage a good amount of complexity even in PHP.
#5 by Steven on August 9, 2011 - 12:42 pm
Ouch…
This post feels half sarcastic and half condescending. Sure, PHP isn’t the nicest of languages and doesn’t have the prettiest of syntaxes, but it has made rather large improvements in more recent versions. As you said yourself, you don’t often code in PHP and I’d probably argue that when you do, you likely don’t do anything particularly complex.
Without a doubt, PHP is now being used for problems it wasn’t originally intended to solve, but that doesn’t mean it isn’t up to the job. The language tends to have a terrible reputation, mostly because there’s a low barrier to entry (for some of the reasons you covered), which leads to a lot of bad code produced by an equally large number of bad developers. With that said, I know there are a lot of poor developers working with other languages (such as Java).
@Pascal, referring to Drupal as a nice framework? If this is the extent of your PHP experience, then I don’t think you’re very well placed to comment on its usage. Drupal is popular, but it’s not great – it’s a big mess of procedural spaghetti code. Maybe take a look at some of the frameworks like Symfony or Zend Framework, which seem closer to Spring framework for Java.
I’m not sure why I’m defending PHP; I work with it professionally and even I’m annoyed by many of its quirks. In fact, the documentation, which Cedric praises, annoys me. It merges multiple major versions into a single page. They never want to break BC and this leaves me pretty frustrated at times. There are issues with PHP, but you can write decent, OO applications with it.
I guess I’m not really going anywhere productive with this comment and it’s probably turning into more of a rant. Have a good evening/day, guys.
#6 by Bruno Rohée on August 9, 2011 - 1:13 pm
“PHP is like C”, well, not its fucked up, unintuitive, breaking principle of least surprise ternary operator.
As for people keeping PHP at the presentation layer where it belongs, there are a lot better alternatives for this role…
#7 by Mohamed Mansour on August 9, 2011 - 1:25 pm
I “liked” PHP before, it was my first language that I learned on a bus ride home. I had so much fun with it that I developed many apps and it was great to finally see them running pretty fast. I memorized the syntax and it was a pure obsession.
But, then there comes Python with Django. I got so hooked regarding the simplicity creating the webapp. Prototyping something was every so quick it made my PHP obsession die. The integrated solution Django has and its documentation/simplicity it brought to the table, made me stop using PHP and start using Python.
PHP was my baby that I adored and enjoyed, but I am more productive with Python because it makes the developers life easier to enjoy and more focused on the algorithms and business logic. Creating C extensions and integrating external libraries with Python was really straight forward as well.
But … I did I ever mention that I love JBoss Seam …
#8 by Paulo Gaspar on August 10, 2011 - 2:32 am
Dear Cedric, can we talk again after you finally spend some meaningful amount of time writing something meaningful (read big/complex) in PHP?
#9 by Alexander Surma on August 10, 2011 - 3:04 am
You miss one important difference, Cedric. PHP is very inconsistent.
Just take a look at the Array-Operations, some take a “reference” to an array as first parameter and work directly on it, some take an array and return a new one as a result.
Some other functions, when passed a new variable, initialize it for you and work on it, some throw a warning, some die().
The documentation is good, no question about it (although there’s some stuff in the OOP area where it just reads “Not documented yet”) – but having to look up every single function you want to use to see how it behaves is a PAIN and costs way too much time.
For me, PHP fails for upper-class small projects already.
#10 by James on August 10, 2011 - 5:38 am
Yeah PHP is totally like C, its statically typed, compiled language… oh wait no its a dynamic language with an interpreter.
PHP is great at what it does but I so rarely want to do that I tend towards Grails/Rails/SpringRoo for my “get in, code, get out” situations.
#11 by Cedric on August 10, 2011 - 5:50 am
James,
And you found an ISP that supports Grails/Rails/SpringRoo?!?
#12 by Jonathan Cremin on August 10, 2011 - 9:15 am
Any modern install of WHM/cPanel supports Rails apps. I think that covers the likes of Hostgator (one of the largest shared hosting providers in the world).
#13 by Eevee on August 10, 2011 - 9:15 am
C fills a very particular niche: systems programming. You can write semi-high-level code in C if you put a bit of effort into it, you can eke out whatever insane performance you want, and you can link against basically anything. There just haven’t been any contenders in the same space that offer something new and still preserve C’s advantages. Maybe some newcomers like Go and Rust will finally help out here.
On the other hand, PHP’s niche is overflowing; you can write Web software in whatever language you please, and there are web frameworks for any obscure language you can think of (including COBOL and bash). The PHP/C comparison doesn’t hold up very well.
PHP is on every cheap web host out there, yes, but… er, so what? If you’re only concerned with installing a forum, sure, throw up some PHP. But any software I’m writing myself from scratch is surely worth twenty bucks a month for a VPS, and then I can install whatever I want. (My desktop certainly didn’t come with PHP, by the way, but it *did* come with Perl, Python, and Ruby.)
That doesn’t leave many solid advantages. Every language has some way to do seamless reloading while developing. (And ONLY while developing; you take a performance hit if you ping every file you use on every request!) Most languages have excellent documentation at this point. PHP has poor support for any kind of structured programming, a needlessly convoluted OO model, very little sanity checking, a long list of gotchas in the syntax/builtins/configuration, and on it goes. You can argue away every single one of these problems, I’m sure, or tell me how to work around them… but they’re still problems, and similar languages have far fewer such problems, so why use PHP over anything else?
#14 by Kwpolska on August 10, 2011 - 9:19 am
> PHPs documentation is great
Haven’t you seen Python’s docs? It’s much, MUCH better. And it has a nice tutorial.
#15 by Daniel on August 10, 2011 - 9:19 am
this post seems misguided.
is the point that PHP is adequate for insignificantly small projects that have no hard engineering requirements?
is the point that PHP allows (even encourages) sloppy design such as intermingling logic and presentation?
is the point that PHP is faster to develop than statically typed, compiled languages? sure it is. would you wager that its also faster to develop than other dynamically typed, interpreted languages? didn’t think so.
is the point that PHP has good documentation? it doesn’t really. only the language built ins. when was the last time you found a php open source library with good documentation? approximately never. and the problem isn’t unique to php, its endemic to all types of development. Have you ever found a language where the built features were not well documented by the language creator? Thats the stuff you can learn in one weekend. its library documentation that makes a real difference.
#16 by Sohan on August 10, 2011 - 9:24 am
I like your viewpoint. If you feel good about PHP, you should just use it. However, at the same time, I think its worth taking a look at the new languages/frameworks – just because they often came out of frustrations arising from their predecessors. That way, you know, you are using the right hammer for the right nail.
#17 by bee cee on August 10, 2011 - 9:47 am
please do not compare php and c. you really aren’t establishing any similarities, you’re just trying to correlate something woefully flawed (php) to something that is more or less unassailable (c), in order to make the flawed seem unassailable.
php is not consistent. no one who has used the core array functions would tell you that .
the rest of your points i can ascribe to any half dozen tools available
#18 by Robert on August 10, 2011 - 9:58 am
As a veteran of a number of large websites for corporate environments, I truly enjoy developing in PHP. Some may say, well, it’s not great for making say a mail server. Of course not. It is a fantastic language for web development. It is an ok language for system scripts. It is definitely not a language for daemons or system applications.
In the corporate environment, I’m seeing a good amount of ASP.NET in C#. For web development, this is a pain. It does some things ok (webforms), but if you want low level stuff, you can’t do it. Most ASP developers are used to dragging a bought grid component onto a bought database component, and trying to figure out why it doesn’t work…
One item I don’t believe you mentioned is the IDE. Zend made Zend Studio 5.5 which is a fantastic IDE. It’s written in Java, but feels fast and works great. Works well with all web files (PHP, HTML, CSS, JavaScript, etc). One of my favorite features is the great debugger. I can connect to any server and run a custom piece of code against the existing code base. So, in a production environment (the debugger is locked behind a firewall, username / password credentials, and IP filters), I can test a bug fix in one file while utilizing the existing production codebase. This is important for hotfixes against a very large system with multiple large backend databases and webservices. Try to do that in ASP.NET. You actually can, but after seeing how you do it, you might wish you never found out.
Oh, and a quick note, do NOT download the Zend Studio 6+. This is based on Eclipse and is flat out bloat ware. Doesn’t have the SFTP options (or at least, they don’t work well).
In PHP, I feel there are built ins for just about anything. Want to quickly resize a JPEG and convert it to a GIF? No more than say 4 lines to do that. Etc, etc…
I was in a shop where we converted a large (3 million unique visitors a month) website from PHP to .NET. In the end, nothing was added, the process took much of a year, and now the development cycle takes twice as long… No good blogging solutions out there, for those who need them. The message boards suck (Community Server blows). In the PHP world, the leading class products are there (WordPress, etc).
PHP gets a bad rep as it gives you enough rope to hang yourself. True, but I believe bad code can be written in any language.
#19 by Pedro on August 10, 2011 - 10:05 am
LOL @ most of the comments. This is like instant humor. Say something positive about PHP and watch the cool kids raging.
“Is inconsistent”, “is not like C because it’s interpreted”. Honestly, is that all you can come up with?
Having worked with web development in PHP, Java, python and Ruby, I allwaysfind the PHP hate rather entertaining. I actually like them all, if you’re a fanboy then your opinion is suspicios for starters.
Python documentation more complete than PHP’s? That is not truth in any extent. The python official documentation is not even complete. Many modules have a single code snippet that doesn’t even use all the available methods.
Also, what’s with allways refering django and rails. PHP has a sh_tload of MVC framworks for all tastes. I fail to understand why rails and django deserve special mention. In fact I find web2py undoubtly superior than django or rails.
That said, Java is by far the most robust option if you want to build medium/large size sites investing large amounts of hour.man.
#20 by Pere on August 10, 2011 - 10:22 am
I will answer in one line: http://www.phpsadness.com/
#21 by Mikushi on August 10, 2011 - 10:45 am
Robert hits it right on.
Most of the PHP developers don’t know how to write proper and efficient PHP code. And it can be said about all languages in the world as well. Stop blaming the language (it has its problems for sure don’t get me wrong) when most of the problem is the developer.
I’ve work with PHP for years, created websites serving over 15 Millions users a day, had a first hand comparison with .NET in this context, and PHP still kicked ass in a lot of ways : faster development, better performance and easy maintenance.
#22 by ivanhoe on August 10, 2011 - 11:20 am
PHP was by far the easiest and the fastest to learn programming language for me back in 1999 (as I already knew C/C++ and Perl). Back at that time it was absolutely the best way to do web stuff, and it was easy to pick it up as new developers were coming mainly from linux programming environments, with background in C, bash and perl, making php’s syntax very simple and familiar. Last few years newbie web developers don’t have any programming background or they come from academic (mainly java) environment, and also the choice of languages that can be used on the net is now much bigger, so it’s to be expected that tastes have changed. But that doesn’t make PHP a bad language, in the same way that Perl or Pascal are not bad, just a bit old-fashioned…
#23 by Aram H?v?rneanu on August 10, 2011 - 12:11 pm
Oh god.
OK, you may like PHP and proselytize it if you wish, but don’t compare it with C.
This must be absolutely satire. I don’t think anyone can troll much harder than “PHP is exactly like C”.
#24 by Big Earl on August 10, 2011 - 12:17 pm
Sorry, but posts like this are generally useless, and I often wonder why someone writes them. For instance,
I like gravy on my potatoes, I spell potatoes with an “oes” at the end, and generally wear shorts in the winter. How about you? Really? Neat! Tell me more about what YOU like to eat and wear.
Whups, just wasted some more time.
#25 by Cedric on August 10, 2011 - 12:19 pm
Sorry but comments like the one above are generally useless, I wonder why someone writes them 😉
#26 by Mark Skilbeck on August 10, 2011 - 12:22 pm
“but I dont know much of its API, because I use it so rarely”
Do you then think you’re of an informed opinion?
#27 by Cedric on August 10, 2011 - 12:25 pm
Do I think I’m of an informed opinion to decide whether I like something?
Not only do I think “Yes”, I actually claim to be the most qualified person on this planet to answer this question.
#28 by Dear Paulo Gaspar on August 10, 2011 - 12:35 pm
Dear Paulo Gaspar –
This article was an awesome troll, and revealed what I absolutely detest in this industry. It should be pointed out that you obviously missed out on the satire.
But then you turn this into some sort of job interview. Why don’t you first take the initiative and state how you define “meaningful” “big” and “complex”? I’m guessing you mean anything you have made since you seem to hold the job title as a software architect. Why don’t you first prove you’re not someone who’s risen to competence via the Peter Principle?
#29 by Ted on August 10, 2011 - 12:53 pm
Best satire I’ve read in weeks. I nearly fell out of my chair laughing. Excellent work.
#30 by Adrian Scott, Ph.D. (CoderBuddy) on August 10, 2011 - 1:54 pm
Neat… I really got into PHP and used it for many years (remember when it was PHP/FI!?), including to build Ryze. Now I mainly use Python and Django, though I still feel that I can crank something simple out more quickly in PHP…
#31 by sam sinclari on August 10, 2011 - 4:03 pm
PHP is like your parents’ house. If you’re older than 18, you’re only there because of cheap hosting.
sorry, but you lack discernment if you’ve been programming more than a year and you’re still using PHP by choice…
#32 by Cedric on August 10, 2011 - 4:08 pm
Sam:
I’ve been programming for about thirty years and in this past year alone, I’ve been using PHP, Java, Scala, Ruby, Python, Bash… what else, some Haskell and Agda on the side, Fantom and Gosu. I’m probably forgetting a few.
And yes, when I use PHP, it’s by choice, and as stated in this post, I find it does its jobs pretty well.
#33 by Herdy on August 10, 2011 - 4:04 pm
@Pascal Bleser check out Play! Framework (http://playframework.org) for a Java web framework with with ‘just-hit-refresh’.
#34 by royi g. on August 10, 2011 - 4:07 pm
Something I’m confused about – if this is a real post (and I like PHP, too), then why is it that your LinkedIn profile shows that you program in a bunch of languages/frameworks EXCEPT for PHP? Are you now at LinkedIn as your profile shows? If so, is LInkedIn using PHP?
Personally, I believe the language that makes you most productive and allows you to realize the scale necessary is appropriate. I don’t believe in dogma.
#35 by jay on August 10, 2011 - 5:15 pm
>>>Its hard to pinpoint what exactly makes PHPs online documentation so useful
Personally, I’ve always found that the user contribution section more useful than the actual documentation – I’ve found many a gem by scrolling down and reading. I can’t think of any other site where user feedback on documentation was so useful.
#36 by Evan on August 10, 2011 - 6:28 pm
I’ll just leave this here:
http://twenty-somethingtravel.com/wp-content/uploads/2010/08/haters_gonna_hate.gif
#37 by Justin on August 10, 2011 - 8:57 pm
To my ears (eyes), this post is less about PHP the language and more about the author’s affinity for the easy-going (and some might say unprofessional) approach to web programming that the PHP community is known for. I am not here to criticize that. It can be fun and refreshing to pump out code like that.
Rather, I just want to point out that you can use the same development style in a lot of other languages/frameworks as well. You will just have a harder time convincing anybody that what you are doing makes sense.
Take ASP.NET as an example. It is also available on practically every cheap hosting plan on the web. If you want, you can code an ASP.NET page (in C# or Visual Basic for example) entirely in-line with code and mark-up mingled on the same page. The only difference is you are using instead of .
If you do this, you even get the same exciting ability to log in remotely, make changes directly on your production pages, and see the results on the very next refresh. The code will be automatically compiled on first load (and the executable cached). Pass all your state around in session variables and URL query strings. Knock yourself out. This gives the exact same experience as PHP (except much better performing). Of course you don’t write tests. Anything other than end-to-end functional testing would be practically impossible.
Backwards compatibility is extremely robust for .NET so code you wrote in 2002 still works. You can even run multiple generations of API at the same time. And of course, if you want documentation, it is pretty hard to compete with MSDN. So, it seems that .NET has all the advantages that the author claims for PHP.
Yes, you can achieve the same liberating, roll-up-your-sleeves and get-er-done experience on .NET if you want. Except, if you were to do that, people would turn away in disgust. You would be betraying every best practice there is.
That said, classic ASP was almost exactly like PHP. Also, this approach is a bit what it seems Microsoft is trying to emulate with their Web Matrix/Web Pages product. It is meant to appeal to the same class of developer. I get the appeal for casual or inexperience coders.
I am not trying to boost .NET here (although I do love it). It is merely an example. Also, I am not trying to vilify PHP. I actually wrote a PHP View Engine so that you can use PHP as the presentation layer for an ASP.NET MVC site. My point is that the lack of rigor and ceremony in PHP can be easily achieved with other tools as well. It is just counter-cultural in most other communities.
Given that, I hardly see it as some kind of exceptional trait of PHP itself. It is just how the PHP community and ecosystem finds itself operating based on an accident of history.
I will not go on too much about how much I dislike the PHP comparison to C. I have heard this a lot from PHP folk. I get that PHP has historically been a non-OO (global namespace) language with a simple syntax and an API full of C-like naming conventions. That hardly qualifies PHP as a peer of C.
If they are so similar, why is the whole PHP standard library written in C instead of PHP? Why isn’t anything else written in PHP other than skunk-works style web pages?
One wonders…
#38 by Cedric on August 10, 2011 - 8:59 pm
Fair enough, Justin, but one advantage of PHP over .net is that it’s multi-platform. I don’t see how I could easily maintain my personal web sites with a Mac or Linux laptop…
#39 by Ted on August 10, 2011 - 9:42 pm
Oh my. You’re serious. “PHP is exactly like C. Either you like both or you dont like either, there is no claim you can make about PHP that cant be made about C as well, and vice versa.” You’re serious about this. This entire post is serious.
I’m not drunk enough yet, but I bet I can go fix that right now.
#40 by Cedric on August 10, 2011 - 9:49 pm
Ted: Do share.
#41 by Marc Seeger on August 10, 2011 - 10:44 pm
> Not even Ruby on Rails, let alone Java, is available on mainstream providers
Just picking a few of the “big” ones:
dreamhost.com: supports RoR
hostgator.com: supports RoR
bluehost.com: supports ROR
hostmonster.com: supports RoR
godaddy.com: partially supports RoR (fastcgi)
I guess that is simply not true anymore…
#42 by Jey Keu on August 11, 2011 - 2:56 am
They say PHP is not suitable for very large projects!
and they say Facebook does well because of HipHop.
and I say to them, who cares as long as I Like PHP!!
#43 by Gary Trakhman on August 11, 2011 - 3:21 am
for the JVM, also try clojure, it can be as simple or as complex as you want, with proper concurrency support, interactive development with a REPL and you can hit f5 to refresh. I got a web page running in about an hour starting from ring/moustache, building in stringtemplate for the views (though there are other simpler solutions), setting up static routes, etc, then I bundled it up as a jar when I’m done.
#44 by Ben on August 11, 2011 - 3:27 am
Mono for mac users. I do .NET and PHP, I like .NET better, but PHP is good.
#45 by Mark A on August 11, 2011 - 3:45 am
I’ve always been happy with PHP but I think its more like Javascript than C.
Better than Javascript thou as you can read and write to files and hide your code if you don’t want others to see it.
#46 by DV on August 11, 2011 - 3:52 am
In PHP there is the most non-intuitive and ugly FOR-cycle I’ve ever seen. I’m talking about the “for ( as )” construction. I think it’s the worse syntax that could be imaged. A lot of languages use the “as” keyword as a type-cast operation – and this IS intuitive. But here, in PHP, what is the sense of treating a as ?? There is much more logical construction “for ( in )” or “for ( in )” which should be used in this case.
Pingback: Mo?na lubi? PHP. Programista wyznaje i uzasadnia swoje uczucia | Pomoc webmastera – kursy, porady, informacje ze ?wiata IT | Pomoc webmastera – kursy, porady, informacje ze ?wiata IT
#47 by Radu on August 11, 2011 - 5:28 am
Offtopic: If you liked the documentation of PHP have a look at the Qt one its the best documentation I have personally used
#48 by Craig Saboe on August 11, 2011 - 5:45 am
Cedric – I admire your courage. You just professed affection for the disowned weird cousin of programming languages that everyone forgets to invite to family reunions. I’ve been working with RoR for a nine months now, and I definitely see why there’s a lot of enthusiasm for it. But there’s quite a few issues I have with it that never get noticed in comparisons like this – rather, it seems it’s all just PHP bashing. First, yes you can run a VPS rather than use shared hosting – but you want to be a sysadmin too? Put Postgres on there, whatever other software you need, and up goes the time investment. It doesn’t do it itself. Second, Ruby’s community is tight, but it’s so fluid it’s hard to find best practices because someone’s always creating the next library du jour for authentication or some such. Third, Heroku is cool, but it’s nothing like either shared hosting or a VPS. No static file uploading so you need to use S3 buckets for some content – so if you’re deploying several client sites to Heroku using the same codebase, how do you generate or handle separate buckets? Under just one account? And Python has a lot of benefits too, but the transition to 3 complicates things – which libraries are compatible, which aren’t? Frankly, if you want to get some idea on the web for rapid iteration, and you aren’t already a RoR or Python guy, it’s almost premature optimization to go that way because it’ll take you so long to get up to speed on the massive paradigm shift to take advantage of those languages/platforms. PHP works, it has most of the libraries you’ll need built in, and hosting/deployment is well-established and straightforward. I’m at the point where I almost feel I need to stop reading most blogs because I’ll stop feeling like I’m behind the times and missing some panacea that will bite me later. Just my quick 2 cents.
#49 by Higor on August 11, 2011 - 5:50 am
Great post! By option I use PHP to develop social games back end and it’s doing great.
Pingback: Regarding “I Like PHP”… | Keritas
#50 by Ali on August 11, 2011 - 6:33 am
I’ve used php for several years. It is very easy and comfortable. There is a lot of applicable free sources in the internet written by php.
But recently I had to implement encryption on some data from dot net. I searched a lot for encryption methods in php. But It was very disappointing. There isn’t perfect implementation for cryptography. I couldn’t solve padding problem at last. I used dot net in this regard.
In case of data encryption php lets me down!!
#51 by Justin on August 11, 2011 - 7:01 am
Cedric said “Fair enough, Justin, but one advantage of PHP over .net is that its multi-platform. I dont see how I could easily maintain my personal web sites with a Mac or Linux laptop ”
Cedric, I just got notified of your post and what a coincidence!
I am at this very moment enhancing an ASP.NET MVC 3 app that I wrote a couple of months ago. I am coding on my MacBook Pro (running OS X 10.7 Lion). I also worked on it a bit earlier from my Linux Mint 11 laptop. The production application is hosted on CentOS 5 (Red Hat Enterprise Linux essentially).
http://mono-project.com
http://monodevelop.com
I do most of my web work in .NET/Mono and the majority of it is done on Mac and Linux machines (because that is what I have).
My next project is a small app for iPhone and Android. That one HAS to be written on a Mac to target the iPhone. I will be using .NET (Mono) for that as well.
http://xamarin.com/
It is not like .NET/Mono is best for everything. That said, your comment really made me chuckle.
On an unrelated note…If you are a fan of PHP, you might be interested in the Laravel project. It looks pretty nice.
http://laravel.com/release/1.5
#52 by Dan Sutton on August 11, 2011 - 8:24 am
“PHP is exactly like C. Either you like both or you dont like either, there is no claim you can make about PHP that cant be made about C as well, and vice versa.”
— Really? Have you tried writing an operating system or a device driver in PHP recently? I have to say that this comment is one of the more ridiculous things I’ve ever seen.
It’s also probably worth pointing out that C is a time-honored and robust standard, whereas PHP is a buggy heap of barely-coherent crap… but I digress.
#53 by austin on August 11, 2011 - 8:29 am
one of the best things about php, imo, is that its so much like c.
when i first learned php i had no internet and was teaching myself, i already knew c so i decided to try various functions i was familiar with (like the scanf family or printf family or read and write) and was amazed to see they worked. i could start doing things in php without even knowing any of the vocabulary except what it shared with c.
every day for an hour a day id go to the library,look things up, write them down, and come home and work on php. one of the big reasons i love php.
#54 by Fred Thekat on August 11, 2011 - 11:31 am
Really? Then you’ll really writing DOS batch files! And DOS batch files that I wrote in 1986 still run on my Windows 7 machine. PHP is no better than VBScript for building web applications. But I suppose that if you rarely use it, and only for web pages, and aren’t familiar with the syntax, and its documentation is great (yes, all the other languages like C#, VB, Java are so poorly documented), then I guess PHP is the right language for you.
#55 by Craig Tataryn on August 11, 2011 - 12:09 pm
I found this was a great blog post:
http://www.odi.ch/prog/design/php/guide.php
I sum it up as: It’s like any language, you don’t have to write code like you just had a lobotomy. It’s just that people can, so they do.
#56 by David Fisher on August 11, 2011 - 12:25 pm
An odd curly brace language, looks messy, now working beyond its original role… What? You don’t mean Javascript? But the low level of entry to Javascript rock stardom and the fact it even runs server side now? Seriously? But you can’t build a web UI without having to do it these days.. Php? Oh right. Well Php rocks because I can build what I want in it and it does it well. *I also like JavaScript.
#57 by Dave Lock on August 11, 2011 - 5:14 pm
Why does every blog article on the net about the pros or cons of a programming language seem to end up in a pi$$ing contest amongst programmers who start their comments with “I’ve been programming for 30 years…”? If your opinion is different, write about the details on your own blog.
@Cédric, nice article, I enjoyed reading it. To me, PHP feels comfortable, scales ok & does its job, & sometimes that’s all a ‘programmer’ can wish for. 🙂
#58 by Davyd McColl on August 11, 2011 - 11:21 pm
Some good points — and very much the reasons why (amongst the 10 or so other languages and platforms I use), PHP has a special place. Yes, you can’t write a device driver in PHP — that wasn’t the point of the article. “Exactly like C” should perhaps have been written “will feel familiar to a C programmer”.
PHP may not have every bell and whistle that a dedicated “everything is an object” OO programmer would like — but it does have the basics which allow you to write cleaner, more extensible code with classes.
PHP exhibits some of the great attributes of another worthy language (Python): it has a relatively low barrier-to-entry but doesn’t run out of steam once you’ve achieved a modicum of ability in it. PHP, like classic ASP, teaches the server-side web developer to respect that the web is not the desktop — unlike asp.net. Not that asp.net is bad — but, like VB did, it allows the developer to create a crappy experience by making it too simple to do so.
But to all of these and all haters, I would say “A tool for a task”. Every programming language and library stack which has survived for more than a year or two must have some merit — or people wouldn’t be using it. If you can find a language/framework/environment which works for your project requirements and isn’t totally blown away by a competing language/framework/environment, then use it! Just bear in mind the usual: functionality, performance, scalability (within the scope of your project) maintainability and ease-of-use.
#59 by deovince on August 12, 2011 - 1:25 am
Fanaticism is certainly everywhere! a powerful caterpillar is probably not capable of winning a Formula 1 race. But it still very efficient for what it is done. Nice post Cédric !
#60 by CariD on August 12, 2011 - 4:29 am
PHP is Hypertext Processor for scripting a language in the web language to produce webpages. Though today the HTML code offers better and quick results, the application of PHP becomes complementary
Pingback: StartupDigest
#61 by jlafay on August 12, 2011 - 10:48 am
I like C and I like PHP, but PHP != C.
Pingback: Knowledge casts « Otaku, Cedric's blog
#62 by CariD on August 12, 2011 - 9:06 pm
PHP has served its purpose. Still it is competent. Even though new innovations may find an alternative the roots do strengthen the exposure.
Pingback: I like PHP « Otaku, Cedric's blog | Linux Blog
Pingback: Top 10 Wrong Ideas About PHP That You Should Get Right | Dacoders Pvt. Ltd.
Pingback: Top 10 Wrong Concepts About PHP « think foss