5 ms·
> That might be just how I feel though. No, I got the exact same impression. PHP is a language that takes away all the fun in programming for me.
by ch0wn 15y ago
> That might be just how I feel though.
No, I got the exact same impression. PHP is a language that takes away all the fun in programming for me.
- glassx 15y agoI believe that this (ideas thrown around) is the truth, Rasmus Lerdorf comes across as a very pragmatic developer who's more interested in getting things done rather than being an architectural perfectionist. But I'm not saying that in a derogative way. Coming from C#, Java and Ruby, I feel that PHP is kinda fun and refreshing. The object model is quite simple, and I love the $$ (variable variable) syntax, and how 'reflection' is way simpler than any other language. It's language for hackers.
- mccutchen 15y ago"and how 'reflection' is way simpler than any other language" I've never heard this claim made, and it has been a long time since I've actually used PHP in any meaningful way. Care to expand on this? I'd be interested in a comparison to Python's support for reflection, which is simple and pervasive.
- glassx 15y agoJust a disclaimer: I have zero work experience with PHP, just personal experience. I put it inside quotation marks because it's not the true-reflection API per se, but I believe it was a mistake to even bring that up, and to generalize by saying it's easier than 'any other language'. I was talking about old methods like get_class_methods, get_class_vars, get_object_vars and $$. Here's an example which I used to answer another user above: $a = new A; foreach(get_object_vars($a) as $name => $var) { $a->$name = $a->$name + 1; echo $a->$name . "\n"; } By no means those things are absolutely "beautiful", but they get the job done and they're one-liners, hence, simple. They're simpler than Java and C#, languages which I worked for years. Also they're easier than Ruby sometimes. To be honest, I just think it is fun. I can make things in PHP with five lines that would take me multiple pages in C#, but the opposite is true too, for other areas.
- jessedhillon 15y agoReflection is simpler than any other language? Here's an example from the PHP docs on the reflection API, in the comments: $a = new A(); $reflector = new ReflectionClass('A'); $properties = $reflector->getProperties(); $i =1; foreach($properties as $property) { //Populating properties $a->{$property->getName()}=$i; //Invoking the method to print what was populated $a->{"echo".ucfirst($property->getName())}()."\n"; $i++; } You have to instantiate another object to inspect the first one! Here's Python, just as an example. (Most languages would be simpler. As with most things, it would be difficult to find a language where reflection was more clunky than in PHP.) a = A() for i, key in enumerate(a.__dict__): setattr(a, key, i) f = getattr(a, 'echo'+key.capitalize()) print(f()) On another thread somewhere, someone once suggested that PHP is actually Blub -- a fictional language whose immense and inherent superiority cannot be explained, only experienced. As a long time PHP dev, let me assure anyone who thinks that this is the case: in no way is PHP Blub.
- Zak 15y ago"Blub" isn't a fictional superior language; it's a fictional average language probably imagined to be similar to Java. It was, so far as I know first described here: http://www.paulgraham.com/avg.html http://www.paulgraham.com/avg.html PHP is Blub in the sense that it is not the most powerful language[0], and some of its users decline to recognize that other languages have advantages over it. From my perspective, there can be no perfect language; certain characteristics are more optimal in some situations, less so in others and mutually exclusive. Type safety and certain kinds of dynamic behavior are an example. [0] I'm not claiming here that any specific language is the most powerful, just that PHP certainly isn't.
- jessedhillon 15y agoYes you're right, I got the Blub parable wrong. What I mean is that the commenter believed that all other languages are Blub to PHP, as in, PHP is higher on the spectrum of powerful languages and other language users did not realize that they were looking up when they looked at PHP.
- aw3c2 15y agoAnd for someone programming-dumb like me it is the opposite. PHP enables me to quickly create websites and it is fun to do that.