News for hackers. Stuff that matters.
Re:PHP solves problems. Oh, and you can program with it too by 10098 on Friday June 29, 2012 @06:44PM (#4179522)
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.

Re:PHP solves problems. Oh, and you can program with it too by llimllib on Friday June 29, 2012 @07:13PM (#4179648)
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?

Re:PHP solves problems. Oh, and you can program with it too by lusr on Friday June 29, 2012 @07:51PM (#4179771)
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.

Re:PHP solves problems. Oh, and you can program with it too by 10098 on Friday June 29, 2012 @08:04PM (#4179825)
he didn't specify what kind of programming, so I'm free to interpret it in the most general way
Re:PHP solves problems. Oh, and you can program with it too by fragsworth on Friday June 29, 2012 @07:12PM (#4179642)
> 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.

Re:PHP solves problems. Oh, and you can program with it too by 10098 on Friday June 29, 2012 @07:28PM (#4179697)
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".
Re:PHP solves problems. Oh, and you can program with it too by pan69 on Friday June 29, 2012 @08:52PM (#4179981)
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.

Re:PHP solves problems. Oh, and you can program with it too by 10098 on Saturday June 30, 2012 @01:43AM (#4180820)
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.

Re:PHP solves problems. Oh, and you can program with it too by dr42 on Saturday June 30, 2012 @03:56AM (#4181061)
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.
Re:PHP solves problems. Oh, and you can program with it too by smsm42 on Friday June 29, 2012 @10:01PM (#4180171)
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.
Re:PHP solves problems. Oh, and you can program with it too by ericingram on Friday June 29, 2012 @08:28PM (#4179922)
False
Re:PHP solves problems. Oh, and you can program with it too by dr42 on Friday June 29, 2012 @07:51PM (#4179770)
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.

Re:PHP solves problems. Oh, and you can program with it too by 10098 on Friday June 29, 2012 @08:24PM (#4179908)
> 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"?

Re:PHP solves problems. Oh, and you can program with it too by Chlorus on Friday June 29, 2012 @08:47PM (#4179963)
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.
Re:PHP solves problems. Oh, and you can program with it too by 10098 on Saturday June 30, 2012 @01:55AM (#4180844)
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:PHP solves problems. Oh, and you can program with it too by dr42 on Saturday June 30, 2012 @03:52AM (#4181052)
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!

Re:PHP solves problems. Oh, and you can program with it too by dr42 on Saturday June 30, 2012 @03:45AM (#4181043)
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.

Re:PHP solves problems. Oh, and you can program with it too by 10098 on Saturday June 30, 2012 @05:03AM (#4181162)
> 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 :)

Re:PHP solves problems. Oh, and you can program with it too by blindhippo on Friday June 29, 2012 @07:16PM (#4179658)
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).

Re:PHP solves problems. Oh, and you can program with it too by 10098 on Friday June 29, 2012 @07:35PM (#4179721)
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"

Re:PHP solves problems. Oh, and you can program with it too by blindhippo on Saturday June 30, 2012 @07:52AM (#4181402)
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.

Re:PHP solves problems. Oh, and you can program with it too by oinksoft on Friday June 29, 2012 @08:00PM (#4179806)
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.

Re:PHP solves problems. Oh, and you can program with it too by ericingram on Friday June 29, 2012 @08:30PM (#4179927)
I wonder if you've actually built a web app before? Your statements about PHP are so off base.
Re:PHP solves problems. Oh, and you can program with it too by 10098 on Friday June 29, 2012 @08:34PM (#4179935)
For example?
Re:PHP solves problems. Oh, and you can program with it too by dr42 on Friday June 29, 2012 @07:56PM (#4179789)
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.
Re:PHP solves problems. Oh, and you can program with it too by jules on Friday June 29, 2012 @10:09PM (#4180182)
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.
Re:PHP solves problems. Oh, and you can program with it too by 10098 on Friday June 29, 2012 @08:02PM (#4179814)
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.
Re:PHP solves problems. Oh, and you can program with it too by dr42 on Saturday June 30, 2012 @03:28AM (#4181007)
"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.

Re:PHP solves problems. Oh, and you can program with it too by xd on Friday June 29, 2012 @07:24PM (#4179684)
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.
Re:PHP solves problems. Oh, and you can program with it too by 10098 on Friday June 29, 2012 @07:41PM (#4179745)
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 :)
Re:PHP solves problems. Oh, and you can program with it too by xd on Friday June 29, 2012 @07:45PM (#4179757)
The way you worded it implied PHP had insane multithreading support.
Re:PHP solves problems. Oh, and you can program with it too by 10098 on Friday June 29, 2012 @07:58PM (#4179798)
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 :)
Re:PHP solves problems. Oh, and you can program with it too by xd on Saturday June 30, 2012 @09:07AM (#4181517)
I think it would be a case of insane developer, to do that ;)
Re:PHP solves problems. Oh, and you can program with it too by rythie on Friday June 29, 2012 @08:23PM (#4179904)
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.
Re:PHP solves problems. Oh, and you can program with it too by 10098 on Friday June 29, 2012 @08:28PM (#4179919)
> 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.

Re:PHP solves problems. Oh, and you can program with it too by 1SaltwaterC on Monday July 02, 2012 @03:14AM (#4187722)
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.
Re:PHP solves problems. Oh, and you can program with it too by rythie on Saturday June 30, 2012 @05:48AM (#4181229)
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.
Re:PHP solves problems. Oh, and you can program with it too by kemayo on Friday June 29, 2012 @07:40PM (#4179740)
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
Re:PHP solves problems. Oh, and you can program with it too by 10098 on Friday June 29, 2012 @07:54PM (#4179780)
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.