Hacker News new | past | comments | ask | show | jobs | submit login
PHP solves problems. Oh, and you can program with it too (nikic.github.com)
68 points by nikic on June 29, 2012 | hide | past | favorite | 88 comments



Let's talk about the conclusions that are drawn in this article. I'll try to challenge them one-by-one.

> PHP is a great language to start programming!

No. PHP is not a good language to start programming. And I mean programming in a broad sense, not slapping together websites (which is not really programming, let's be honest). Let's look at people who know how to program, you know, the guys who participate and win awards at ACM ICPC and TopCoder. There are several such people among my friends. Exactly zero of them have started with PHP. Some have started with Pascal, some with Java, some with C++. None with PHP, even though it was available and widely used when they started. I wonder why.

> Once you started, PHP is also good for “real” programming (you know, object orientation and stuff).

First of all, "object-orientation and stuff" is not a measure of how good a programming language is. So you'll have to bring a better argument to explain why PHP is good for "real" programming (whatever that term means). Saying "but Facebook and Wikipedia use PHP!" doesn't count :-)

> PHP is not as bad as they say. There are issues, like with every language, but they rarely cause problems in practice.

Actually, it is. It has some deeper issues that lack of consistency in function arguments. Some of them really do cause problems in practice, like its retarded type system and lack of sane support for multithreading. But I'm not going to name them here because there are tons of articles on the internet explaining those issues. You have probably read some of them. If they did not change your opinion about the language, then I surely won't be able to do it.


I hate PHP too, but this:

> Let's look at people who know how to program, you know, the guys who participate and win awards at ACM ICPC and TopCoder.

Is goalpost moving. He's not suggesting that PHP is a great language to start with if you aim to become a great algorithmic programmer, rather that it's a great language to start with if you aim to become a competent web developer.

> Saying "but Facebook and Wikipedia use PHP!" doesn't count :-)

But why not? Surely "X and Y outrageously successful projects use Z" is a valid argument for Z's power as a programming language?


It's an invalid argument because not all projects are alike. Facebook and Wikipedia are indeed very successful projects but they have a massive advantage over the types of projects I deal with in enterprise environments. For instance:

- technical environment: the Facebook/Wikipedia/generally-any-web-startup architects get to choose their technical environment 100%; in most corporates you need to integrate with legacy applications and databases in a specific environment, often enforced by IT policy, and this imposes significant constraints on which languages will be feasible options

- interoperability: for large, modular systems developed by disparate teams over decades with little or no standards or co-ordination, a statically typed language can be absolutely invaluable for ensuring interoperability and discovering usage (documentation is typically non-existent in these environments, as are tests, and the latter is seldom - often impossible - to retrofit); even for new systems, static typing can save a lot of time when developing and integrating new work across large teams, in my opinion

- resistance: business and technical knowledge lives in developers who are part of an ancient stack, e.g. Microsoft or Oracle or Borland; switching to PHP or Python or Ruby etc. means convincing these people to learn very different new technologies (good luck - won't happen), figuring out how to interface with legacy stuff using a language outside of the stack, introducing new tool chains, etc.j

- time & budget: even if the existing developers are keen to learn, it's tough convincing the project manager you need an extra month to go through the upskilling process and that you need to spend time researching interoperability options, and that inevitably you will run into future issues, etc.; the problem is most projects are run and budgeted for on a local cost benefit analysis and very rarely would the benefit of switching languages for one project be worth it (even though, in the big picture across multiple projects, it may very well be)

An observation: whenever this debate comes up on the HN, the proponents of modern, dynamic languages are invariably people working in closed environments where they have the freedom to set standards, do things right from the beginning (coding standards & reviews, tests, documentation) and the ability to make technology selections across the board. Often this freedom is not a characteristic of other environments, and consequently the language used in a one environment may be unsuitable in another.


he didn't specify what kind of programming, so I'm free to interpret it in the most general way


> No. PHP is not a good language to start programming.

Any language is a good language to start programming.

Explain how learning PHP first somehow cripples your advancement as an engineer. You can't just say "my friends didn't do it". Otherwise you're really just being elitist.


Because when you're learning php first, usually you are not learning how to solve problems in an algorithmic way; you're learning how to set up apache or upload a file to the server, or scrape an html page for weather forecast, and other stuff like this. I'm not saying those are useless skills, but it defeats the purpose of "learning to program".


I'm from a generation where BASIC was the go-to programming language since it was available on every single computer sold at the time.

Everyone I know who was a kid in the mid-80's and who is still programming today learned programming from this crappy language called BASIC.

When you start out learning to program all you need to learn is about variables, functions, basic constructs such as loops and if's etc. and maybe a bit about data types. PHP let people do exactly that and guess what, today people don't write command line apps anymore. Their context of learning to program is by making a website.

Most people who are serious about programming and learn to program with PHP are smart enough to learn other languages as well just like me and my friends did after we first learned BASIC.


It's funny because it was precisely how I learned programming: first a bit of Visual Basic, then PHP.

I want to warn people against it, because I think I lost a lot of time along the way doing stupid irrelevant things.

You see, instead of learning the basic stuff like algorithms and data structures, I was writing visitor counters and guestbooks. As a result, in a few years, those who started with Pascal or even plain old BASIC, were already coding circles around me :)

Maybe it's not as much about the language as about having a wise teacher who can push you in the right direction. I didn't have one, unfortunately.

P.S.: on the other hand, I was able to sell my skills much earlier than my peers: I made my first money on php. But I don't think it's important: it's about being a good programmer, not selling you code as early as possible.


Just because you built visitor counters doesn't mean the language can't do a whole lot more. You're whole criticism seems more leveled at your early jobs, rather than the language.


That's an absolutely baseless claim. Nothing prevents you from learning both in the same time. You are saying "you're not learning programming but learning to copy-paste from internet and copy-pasted examples are in PHP - ergo, PHP sucks as a language". That's baloney - PHP is perfectly suited to be used as beginner's language to learn programming - the only precondition being you have to learn programming. Otherwise, of course, PHP couldn't help you - it's not some magic dust that can make you know programming just because you copy-pasted some PHP code. Blaming the language for that is just wrong.


False


Haha, this is so not true! Using php has nothing to do with setting up apache. You're mistakenly associating solutions with the language. It's like saying you can only write enterprise apps in java, or only write machine learning apps in python.

PHP has all the usual programming constructs and is easy enough to get into that I think it's a great language to start out in.

And discounting web apps as not real programming is just wrong. Some of the most challenging programming problems today are in the web field. Some people write low level software algorithms, and some write higher level ones that scale to billions of people using them concurrently. They are all 'real programming'. Not all web programming is request.getParameter("foo") and form processing.


> PHP has all the usual programming constructs and is easy enough to get into that I think it's a great language to start out in.

Yes it does, so what? Programming is not just fors and ifs and classes you know. There is more to it. You won't learn it if you limit yourself to the PHP cage forever.

> And discounting web apps as not real programming is just wrong

Did I say anywhere that web applications are not "real programs"?


Huh? "You won't learn it if you limit yourself to the PHP cage forever" That's true of ANY language; you seem to think that just because someone starts out with PHP they're permanently crippled and unable to grasp higher programming concepts. Hell, I'd rather someone start out with PHP than, say, Pascal.


No. In fact, as I already mentioned, I started in PHP myself. The thing that annoys me is that "Meh, PHP is good enough" attitude, which a lot of people seem to share. With that kind of thinking, your progress will be seriously hindered.

On a side note, why the hate on Pascal? It's a lot better than PHP as a starter language, it teaches structured programming from the ground up.


Re pascal, that really was a language that had unpredictable order of evaluation. Not to mention its issues with forward declarations leading to infinite recursion. Fortunately i have relegated pascal to the attic of my mind. These days I seldom stray far from python or JavaScript. Both of which are wonderful languages. Java's ok when eclipse is used to auto complete the verboseness.

Start out in pascal these days and try getting a job!


I learned programming 25 years ago, assembly, pascal and c. Over the years I've learned and used Java, php and python.

PHP is only a cage if you let it be. PHP has all the tools you need to build anything. I prefer python any day, but I don't like to see people who never got beyond the newbie level criticize something just because they couldn't make it work for them. As the old phrase goes, a bad workman always blames his tools. The criticisms you have leveled at php are all the usual newbie ones, not understanding how stings and numbers are equated etc, it's like a python programmer not getting is vs ==, or a JavaScript programmer not understanding undefined, or a SQL programmer not understanding why null = null for purposes if group by, but not in equality testing. You have to undertake the language in hand properly before you can use it properly.

And yes you did make that assertion at the beginning of your thread. Go back to the first comment you made here on this thread.


> PHP is only a cage if you let it be. PHP has all the tools you need to build anything.

I don't think we understand each other. PHP has all the tools available to allow you to build anything within a certain problem domain, i.e. web programming. If you start with it, your focus will be shifted towards that domain. I think a better idea is to start with something more general-purpose, more consistent, get a good foundation, and then look at all the available options and say "ok, now I want to work in this field".

> I don't like to see people who never got beyond the newbie level criticize something

It is true that I don't have 10 years of experience in php, but I don't see why I should have continued investing valuable time into learning this platform when there were clearly better options available.

> not understanding how stings and numbers are equated etc

I understand it. I just think it's a bad decision to do it that way. Also note how all of your examples with other languages have reasonable logical explanations. The particular type conversion rule we were talking about does not have such an explanation.

> And yes you did make that assertion at the beginning of your thread

I only said "..slapping together websites (which is not really programming, let's be honest)" Web sites are web applications are different things in my book :)


1) why is PHP's type system "retarded"? 2) why does PHP need multithreading?

Serious questions.

I've been using PHP professionally for 5 years now, haven't once needed either of these "deeper issues" to be solved, so I'd appreciate it if people would stop bitching about the language and actually explain why PHP is bad (with examples).


1) 0 == "" && 0 == "0", but "0" != ""

Does that convince you?

2) because processing some HTTP requests can be a tad bit more complicated than "do a select from a database and substitute the values into a template"


1) Isn't this a problem with all dynamic languages? And isn't this why the '===' operator exists?

2) Explain - seriously. To me this level of thing isn't the realm of PHP but rather the web server in front of it. If someone is doing something that requires multi-threaded programming, they clearly don't know what PHP is used for and they chose the wrong tool. Their choice doesn't invalidate PHP for it's intended use case.


1) Certainly doesn't convince me. In the third test, no type coercion is performed.

2) I'm not sure what this statement has to do with anything.


I wonder if you've actually built a web app before? Your statements about PHP are so off base.


For example?


This may appear 'retarded' until you understand how type conversion works. Then those examples are perfectly logical and expected. PHP has === if you want to disable the type conversion in the conditional operator.


Knowing how something works does not make it a good idea. I see this attitude a lot: if you've mastered something complicated, it seems so logical and inevitable. I had this attitude myself once when I only knew PHP. But then you discover that PHP is not god given or a natural phenomenon. A human put each and every behavior in a programming language. Some choices are better than others. Significantly worse choices were made in PHP than in e.g. Python. Therefore new programmers should learn a language like Python, not PHP. It's a waste of time to learn the intricacies of things that ended up that way due to a bad decision or even by accident. Note that Python is far from perfect too, but it's one of the least bad to start with.


I know about ===. I do understand how type conversion works. I just don't think that it works "correctly". Converting "0" to 0 implicitly seems completely illogical to me. A string is not a number.


"a string is not a number"

Well then use ===, but when a string contains numbers then php will do the type conversion for you. It's a convenience.

It may not work correctly by your definition but it's pretty intuitive and useful the way it is.


Im sorry, but what do you mean by "sane support for multithreading"? You are aware that PHP has no threading support, right? I mean you seem pretty damn confident in your opinion of PHP for someone obviously lacking in any real world experience with it.


Huh? I think I made it perfectly clear that I'm aware of it? Unfortunately, I've had enough experience with PHP to decide to never ever use it again voluntarily :)


The way you worded it implied PHP had insane multithreading support.


Well, if you _really_ wanted to spawn a thread, you could do it through an extension written in C, but it does not look like a sane option to me :)


I think it would be a case of insane developer, to do that ;)


Why would you want multithreading in PHP? If you require multiple remote I/O there is Curl. If you require more than one CPU per web request you most likely doing something wrong. Multithreaded code is hard to get write, hard to code and hard to debug and not suitable for generating webpages. In case you haven't guessed I think it's actually a benefit it doesn't have that feature, it stops people doing something silly that PHP is not designed for.


> Why would you want multithreading in PHP?

To not write cron jobs that get triggered every n minutes to do some potentially time-consuming tasks, for example.


I wish one day people would stop using mod_php5 and start using PHP-FPM. That way we might get proper documentation and support. fastcgi_finish_request() does the neat thing of finishing the request in the user side, but continuing to do the work in the server side: http://php.net/manual/en/install.fpm.php Must be used with care in an environment that uses a fixed number of processes per pool since it may be DoS'ed.


A threading system doesn't help you with that, the web request will have died by then. Use a queuing system if you want to do that, just as you should do in other languages.


Avoiding taking a position on the core issue... "but Facebook and Wikipedia use PHP!" is the same argument as "the guys who participate and win awards at ACM ICPC and TopCoder", no? If you want to object to the former, don't then use the latter. :P


That's a correct remark. I detailed about why I think php is a bad language to start in one of the comments below :)

Basically, the "facebook argument" is widely used to prove that php is good for solving real-world problems, but the truth is, facebook is a complex system and it is not written entirely in php, like some people seem to think.


Oh, please. Stop it! Not another fucking PHP vs. the world thread on HN! C'mon kids, get off it!

Any number of us could name tons of very successful (profitable, popular, worth tens, hundreds and billions of dollars) companies that rely to a large extent on PHP.

And the same could be said about a dozen other languages and frameworks.

Be done with this shit, will you? Haven't you had enough?


I blame Atwood for trolling PHP yet again with this link bait. I'm deadly serious: he has a history of posting anti-PHP rants, then sitting back and watching his blog traffic grow.


No one is disputing that you can hammer a nail with a brick. Most of the criticisms around PHP revolve around the idea that it's better idea to use a hammer (with one claw side, and one hammer side)

Likewise, when you have a real problem that isn't needs to run on a $5 shared host, or written for $4/hour in China PHP is rarely a good choice unless you happen to already know it.

If I needed to solve either of the above two problems I'd choose PHP. I write a lot of PHP (mainly wordpress sites) and it's certainly workable, it's just annoying once you've used languages like C#, Ruby, F#, Scala, Clojure, or Python.

None of the problems with PHP are unmanageable it's like driving an old diesel car, you just remember to plug it in the night before if it's going to be less than 40 degrees.


$5 shared host

Modern shared hosting can actually handle long-running processes and complex frameworks that used to require a VPS. I don't have broad experience with it, but I did just deploy a client's site to webfaction.com, which supports Django, Rails, arbitrary long-running processes, JVMs, custom Apache configurations etc.... Pricing can be as low as $5.50/month there, and there are probably even cheaper services for those who shop around.

you just remember to plug it in the night before if it's going to be less than 40 degrees

People in warm climates who have never seen electric engine heaters might not understand this.


Good point on the block heaters, I guess that's a cultural reference most likely to be picked up by Canadians.

It's especially bad for diesels as when they age even with new glow plugs it isn't enough heat to make the diesel ignite with out waiting 5 to 10 minutes if it isn't a nice summer day.

Yeah I've run a couple rails apps on dreamhost, it's becoming more common but you know for sure that PHP is going to be installed.


it's interesting to read the comments here. Most of them go on bashing PHP because it's a terribly designed language. They're probably right, but they're totally missing the point, primarily because this is a very technical community.

I'm not a programmer. Yes, I can solve problems with code, I can whip up a webpage, I can talk to a database, I can use Jquery. But I don't know what lambdas are, I don't understand what LISP macros are all about, and I wouldn't know where to begin writing image recognition software.

But you know what? I get stuff done. And PHP helps me do it. Because I can make things without worrying about not having a CS degree, not caring how a compiler works and not having to set up a server from scratch.

If you look at all the sites out there making money and getting views I think you'll find that an awful lot of them are made by people like me.


And guess what, you'd get stuff done more quickly and with less annoyances and bugs if you were using another language. The article is encouraging people to start programming with PHP. This is bad advice, because there are better options. If you already know PHP and you don't plan to program a lot, then learning a better language may not be worth it and staying with PHP is fine. If you're just starting you have no such investment and you're better off learning another language which is both easier to learn and more productive.


And what exactly prevents you from getting stuff done using other tools? Are you saying that only PHP let's you get stuff done?


What I'm saying is that if you're not a programmer and need to get things done PHP is a great fit because it's so easy to just do it.

I looked at python because it's supposed to be relatively easy to set up. But you need to understand compiling, importing classes, etc. just to get a simple HTML page up and running. With PHP you install apache, create a file and you've made something.

This quip from the article explains it well, and is exactly how I started using PHP:

People come to PHP because they have some problem and they need to solve it. This is what PHP really shines at. You can simply take your static HTML website, add a simple <?php include 'counter.php'; ?> in there, and … be done!

From there you start writing simple scripts, learn how to process forms, how to talk to the database, etc. After some time you start using object oriented programming and maybe make use of some framework.

That’s actually pretty much how I got into programming.

With most other languages it is the other way around. With them you first study computer science for five years and then you go out into the world to find some problem you can solve. (You could say that PHP is a programmer-producing language, whereas most other languages are programmer-consuming.)


Ok, I may have to agree with you there. There is definitely a measure of 'getting something working' that you may not get anywhere else.

Although I disagree with the last paragraph there. If you think PHP is ok, then maybe perl would suit as well. I know there are a few perl frameworks, but not sure if they are as quick as PHP.


But you do know what a function is? Or a class? Or an object? It is not like those are non-trivial already or that knowing what a lambda is needs years of studies if you understood these things.

The fatal flaw in the "PHP is simple"-Argument is that its actually not simpler than other things (I wouldn't say that its harder either). Sure, it gets stuff done (tm), but so do others, also without any deep knowledge. They may not be Lisps or Haskells, but Ruby and Python are coming close.

The problem I have with the PHP community is that "its so easy to start" seems to be their main argument. Wouldn't the world be a better place if we had an easy to start stack _without_ a shitty language?


The problem is that any popular "easy to start" stack attracts people who have no idea how little they understand. And then they start building things badly because they don't understand. Some of it proves useful to other people who don't know what they are doing. And before long the ecosystem built around that stack becomes a horror to behold.

This has happened with PHP. It happened with Ruby on Rails. (Before disagreeing with me, think about how much abuse of monkey patching happened, and how many have been bitten by it.) It happened with Perl back when Perl CGI scripts were the de facto standard.

So yes, it would be wonderful to have an easy to start stack that is popular that guides people towards doing the right thing. But human factors guarantee that any that get popular will go downhill over time.

(I've ignored the obvious argument that the same features that make you popular also make you worse. See the famous essay Worse is Better about Lisp vs C for context.)


Wouldn't the world be a better place if we had an easy to start stack _without_ a shitty language?

Yes, and I hope someone will build it!


I think PHP's problems are actually quite solvable without core language changes. The OO model is actually pretty good, there's even reflection functionality that's sufficient to do stuff like auto-generating docs and self-validating DTO objects. The issue are the "legacy" api's, and the primitive types. What's missing are object api's wrapping the primitive and legacy functionalities. Those could be built quite easily though.

You could have something like jQuery's $ function, but for PHP variables, that gives you an OO api on top of that value (especially now that you can use the -> operator on return values of functions without intermediate assignment). I wonder why nobody's built that yet. I suppose because those in the PHP community are all busy programming instead of meta-programming.


Do you mean something like this?

  function s($string) {
    return new String($string);
  }

  class String
  {
    public $string;

    public function __construct($string) {
      $this->string = $string;
    }

    public function __toString() {
      return $this->string;
    }

    // several helper methods like the following:

    public function toLower() {
      $this->string = strtolower($this->string);
      return $this;
    }
    
    // this would create lots of extra objects,
    // but leave the original unchanged
    public function alternateToLower() {
      return new String(strtolower($this->string));
    }
  }

  $username = s('ExampleUser');
  echo $username->toLower();
My concern would be the memory used to create several dozen extra objects. If this is indeed what you're talking about, is there any strong benefit besides convenience?


Yes, lots of memory, much worse performance, but it doesn't really matter. If you care that much about those, you're not using any interpreted language.

Besides, most PHP code is linear without much looping other than iterating database records. The overhead of such an approach wouldn't matter that much, and when it does you can always use the old way of doing things.

But you wouldn't need to create an object per call, you could reuse a singleton that gets initialized by a wrapper function to work on your current variable (using references). Fix($str)->replace("foo", "bar") is a syntax that doesn't require object instantiation or string copying. And the singleton could use the mb functions internally to be multibyte aware.


One reason to abstract away strings is that you can gain security. For example, your template might only accept an HTMLString, which can only be created from a String by escaping. Your database library might only accept a QueryEscapedString, and so on.

Of course all of this is possible without creating a wrapper for vanilla strings.


> PHP's problems are actually quite solvable without core language changes

How do you fix weak typing?


Javascript has weaker typing than PHP (in php you can have typed parameters for object parameters), but javascript is the new hotness and php gets no love. Typing is not the issue that makes php so ugly.

Also, i write php all day and i almost never run into bugs due to typing. You adopt some habits like always casting before use, and use an ide that warns you when you're doing stuff like using uninitialized variables (phpstorm is awesome), and the whole issue goes away for 95%. I'm not saying it doesn't cause bugs, just that i've found it to not be that big of a deal.


Ostensibly, by writing lots and lots and lots of unit tests. In practice, however, no one has time to write or update unit tests. Which is bad, but understandable, because circumstances can be pressing. In that case, the only fix for weak typing is praying that nothing blows up :-)


While I appreciate that your post is mostly jest, it's worth noting that a "fix" that places an immense amount of additional load on the programmer is not worthy of the title (in part due to the consequences you describe). And even then, even the best unit tests rarely cover every case.


As C++ has taught us, the solution to the errors made in a badly misdesigned language is not to continue cramming every feature you can think of into it.


Right, and in recent years, PHP has been really cautious as to how it adds certain features, but more importantly, has been cleaning up old edge cases.


TFA seems to argue that people's complaints don't apply to PHP5 because it added a random assortment of features.


I guess it's irrational, but the fact that there are some good points nestled inside this post only makes me more irritated about the post as a whole. You see, it's easier to just shrug and say "meh" if the whole thing is crap.

Te problem with the main premise is the same thing PHP apologists have been harping about all the time:

some poor soul wants to create an online encyclopaedia, or some teacher needs an online teaching platform, or someone wants to write a blog. Those people do not want to learn to program, they want to solve problems.

Newsflash: solving those kinds of problems is called programming. That's what programming is. You want to make the computer do something that it can't do with the existing programs, so you create a new program.

If a programming language is easy to use by everyone, it's because it doesn't require you to think like a programmer. It's part of the language design. If you start fixing those design decisions, you'll most likely end up with a decent language that simply isn't easy to use by everyone anymore.

This idea that you don't need to be a programmer to write programs has already failed on several occasions in history of programming: dBase, Visual Basic and Access are notable examples. Not repeating the history is too much to ask for, but let's at least try to avoid making it look like it's a good thing.


I'm at least as opinionated about programming languages as the next HNer, but surely it's a misrepresentation to call Visual Basic, Access, and, yes, even PHP "failed" in light of their widespread use in successful products and/or businesses.


It's probably a mistake to think these technologies failed. You won't find many programmers who consider VB and Access tools of choice, but a lot of people have gotten a lot of use out of them in business.

If it's possible to make a general-purpose programming tool that's reasonably accessible to non-programmers that programmers won't hate, I don't think anybody has come very close yet. DSLs may be the best we can do.


"PHP apologists" -You've got to be fucking kidding


You do not need to be a writer to write, a driver to drive, a cook to cook, a runner to run, or a businessperson to conduct business...and you don't need to be a programmer to program.


And yet you need to be a dentist to work on someone's teeth, a doctor to prescribe medical treatment or a pilot to fly a plane.

Yes, you can program without being a programmer, just as you can drive a city car to your office and back, but you won't take that same city car to Monza and expect to beat Ferrari's Formula One team in a race.

So let's dispense with the sophistry and admit that you need to learn a specific skill set to do a skilled job and that you need adequate tools for that job.


A race car driver is a very different thing from a driver. There are also restrictions placed on who can be a race car driver. It sounds like what you are really saying is that programmers need to be certified by a professional trade organization, following a period of 2-6 years of education and apprenticeship, enforced by law. After all, that is what separates doctors, dentists, lawyers, and accountants from other professions. (Race car drivers have contracts and other measures to enforce exclusivity, as racing is generally illegal except on dedicated courses or in licensed races.)

Programming is a skill/trade. It is not a profession. That is a good thing. If programming were a profession, it would not be open to everyone to learn and do.


This is offtopic, but I just wanted to say that I really enjoyed your "PHP's Source Code for PHP Developers" posts. Please keep writing!


The fact that people have to constantly defend PHP says something in itself.


That people constantly attack PHP?

In all seriousness, it just works when your building for the web (unless it doesn't.)

Is it often messy? Absolutely. Is it sometimes a bit verbose? Sure. Can it sometimes be like laying a snare, only to accidentally step back into it? Yes, but it's not alone, just seems to make it a little easier to occur.

It doesn't have to be that way, it just tends to be like that.

I prefer Python and Scheme, but I don't enjoy them when it comes to working with web development. There are frameworks that help with this, but it's still a pain. PHP is quick and easy, in that area and works 95% of the time in about 99% places you stick it.

I've been trying for years to embrace Python in web development, but it just annoys me during the setup. PHP gets out of the way, in that area, and let's me go.


What language do you use?

If you had a bunch of influential yet hopelessly ignorant people writing blog posts about how awful that language is and possibly devaluing your skill set because of it, you'd want to correct things as well.

The fact that the majority of complaints about PHP as a language boil down to your comment says A LOT about the ignorance of most of the complainers.


Sure. It says PHP is popular enough and mainstream enough so that people feel attacking it would not be pointless and would bring them some clicks. And it says there are arguments in defense of it - otherwise there would be nobody to defend it.


Coming from someone who didn't start with PHP. Has used a variety of other programming languages. And programs in PHP daily I will say that it fails in many important respects and will for some time to come. The first things that come to mind are functional programming (it has some abilities but is fairly quirky and harder to read than other languages). Being able to use array_map or array_reduce is useful in many places but certainly not elegant in PHP. Code reuse is also not that easy with PHP (though traits may fix it, but we don't use PHP 5.4 yet because it's seemed fairly problematic for us in production) and the need for autoloaders is somewhat insane once you've used a language with an actual package system. It doesn't have a mature dependency management system (though Composer is currently an up and comer). It's great for small projects but horrible to maintain at large scale - and this is from someone who has written 100K+ line programs in PHP.


That's what i like about PHP:

- low maintenance. That's true.

- straight forward coding. Yes you can shot yourself in the foot. But it's easy.

- controlled file descriptors, functions, etc:

Tell me, how can you restrict the baseopen dir, certain functions such as exec'ing, how can you log all mails going out from.. python's wsgi, or ror, etc?

That's right. You can't. Well PHP can.

So, I dislike PHP for all the reasons everyone are going to write for the umpteen time too, but it does have several unique strengths too.


Wrong! Nope!

PHP OO is screwed up and hacked together. Look at crappy support for late static binding, being unable to bind $this in closures, and all of the hack-glue that is get_class(), get_class($this), get_called_class(), self:: vs static::, the list goes on.

The thing is that, with PHP, the "new, modern" features are only surface deep... once you do anything slightly advanced, you can always tell that they were hacked on to a language that was never meant for anything more than 'include counter.php', and maybe that's okay, but stop saying it's a real programming language because it's NOT.


but stop saying it's a real programming language because it's NOT.

Any definition of "real programming language" that can inexplicably exclude the Facebook stack is just meaningless. Saying that another stack could do it better is pointless since PHP is what does it. And just to preempt any "HipHop is the stack, not PHP", just remember that front-end Facebook engineers don't write C++, they build Facebook in PHP, inconsistent parameter orders and all.


Does everyone think the facebook stack is just built from PHP, there is a boatload of C etc too. Don't forget they have HipHop which makes thier PHP a little non-standard. Also they have a MASSIVE legacy codebase I presume so just swapping out to something might not be justifiable despite how much they wish they could.


Ok, I'll fall for this one. Tell me what a real programming language is (in a bulleted list prefferabily).


My guess is that what GP considers a "real" programming language is a language that tries to solve at least one problem some of the other programming languages have, instead of incorporating pitfalls that most other languages avoid in order to make programming accessible to everyone.


What do you think PHP did when it came out exactly?


Could you be a little bit more specific?

What is crappy about the late static binging support for example?

Btw, you can bind and rebind $this as of PHP 5.4.


Still solving problems...


Just cause I can solve problems in BASH doesn't meant that it's a real, modern language.

http://bashlib.sourceforge.net/


Actually it does make it real. It may not be popular or modern or the best tool for solving a particular task, but it isn't any less real than the real languages: C, C++, Java, Objective-C, C#, Python, Ruby, JavaScript. Even http://en.wikipedia.org/wiki/Brainfuck is a real language - it sure is restrictive and impossibly hard to use for nearly all projects. Let's not use the word 'real' in this discussion. It seems unnecessary and quite frankly, fanboy-ish


There's nothing particularly wrong with this article. It describes some aspects of PHP.

It's just that Atwood's article describes PHP much better. (http://www.codinghorror.com/blog/2012/06/the-php-singularity...)

I think the latter view is spot-on, and nikic's view here just serves as a perfect example of why certain people are still addicted to their awkward toolset.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: