3 ms·
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 on
by blindhippo 14y ago
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).
- 10098 14y ago1) 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"
- dr42 14y agoThis 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.
- 10098 14y agoI 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.
- dr42 14y ago"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.
- jules 14y agoKnowing 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.
- oinksoft 14y ago1) 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.
- ericingram 14y agoI wonder if you've actually built a web app before? Your statements about PHP are so off base.
- 10098 14y agoFor example?
- blindhippo 14y ago1) 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.