Hacker News new | past | comments | ask | show | jobs | submit login

I've written a few thousand lines of PHP in the last year or so. Every time I do, I want to weep.

It might be better than Perl, but not by much.




> It might be better than Perl, but not by much.

Oh come on.

PHP is more evolutionarily fit than Perl in a handful of very important ways (I would illuminate, for example, function signatures and a pre-built object system, syntactically trivial nesting of data structures, and a newcomer-friendly out-of-the-box execution model).

That said, I wrote Perl for years as a hobbyist (still do, now and then), and have spent the last 6 or so primarily writing PHP. There is not a day that passes that I don't miss some aspect of the rich, expressive, elegant, sophisticated, and intellectually delightful environment that is Perl at its best.

It is a doomed and sinking continent, Perl, but if we let the considerable wisdom of its once-great civilization evaporate into trite dismissal, we as a culture stand to lose a great deal.


syntactically trivial nesting of data structures

I always found PHP's insistence on the array() keyword annoying, and the mixing of associative and sequential arrays ambiguous.

Perl's data structures (in their simplest form) and JSON are very similar, and I think JSON is a fine format.

You're mostly right on the other points though. Although I do love Perl's use of signatures in some cases.


That was actually fixed in 5.4: http://www.php.net/manual/en/language.types.array.php

You can now write

  $numbers = [1,2,3];
Or even

  $numbers = ['first' => 1, 'second', => 2, 'third' => 3];
I'd think the mixing of associative and sequential arrays are one of the key things that lowers the barrier to entry though.


I had heard they were finally fixing that, which is why I made my comment a reference to the past. I'm glad they settled on a syntax that wasn't too far out of the norm from what you would expect, given PHP's roots (i.e. Perl). I seem to recall the RFC at some point had a different syntax, but I could be remembering incorrectly.

I'd think the mixing of associative and sequential arrays are one of the key things that lowers the barrier to entry though.

For me it fails the "similar things should look similar, different things should look different" test. Then again, they aren't really all that different in PHP. I guess it comes down to me preferring my sequential and associative data structures to be separate, which is a fairly fundamental difference to how PHP thinks it should be. I have a sneaking suspicion that the complexity this data structure tries to hide leaks out through the numerous functions used to interact with it[1], which just shifts the pain slightly farther down the line, and possibly from a one-time event (when learning the fundamentals) to a regular occurrence as it causes problems continually later.

1: http://c2.com/cgi/wiki?WaterbedTheory


PHP doesn't insist on the array() keyword, currently. The mixing of associative and sequential arrays is ambiguous, although you can think of them all as being associative; it's just, PHP will supply some keys if you don't provide any. Whether that's kludgey or acceptable is up for discussion. (I don't mind it at all.)


It's not so much that I think it's kludgy, as much as I think it may be a harmful abstraction, as faintly outlined in my sibling comment.


Like Perl, PHP is a long-lived, heavily-used-in-production language, which means there is a lot of cruft that has accumulated over the years that's difficult for the platform developers to just slough off. But much like there is a Modern Perl movement that has coalesced around voluntarily cutting out cruft and using a much cleaner, nicer-to-work-width subset of Perl, there is a similar movement in PHP-land that's doing the same thing.

PHP The Right Way (http://www.phptherightway.com/) is a good place to start if you're curious what "modern PHP" looks like.


This. Nobody taken seriously in PHP world doesn't use modern PHP tools, Good frameworks, Composer, follow PHP-FIG standards, all that stuff... Just because you had to maintain a PHP4 app 10 years ago, doesn't mean PHP hasn't changed. And it also doesn't mean real devs don't have standards and follow up-to-date guidelines.


I'm guessing you haven't spent that much time looking at the Wordpress ecosystem...there's some truly heinous stuff in there.


For sure. WordPress has a lot of legacy backwards compatibility on its shoulders. If they could shrug it off and start again, I'm sure it would be a lot cleaner.

The project I'm working on (https://github.com/idno/idno) is PHP, but explicitly doesn't support legacy versions, in order to rule out the way of working that was finally made obsolete in v5.3. I'm very happy with the language, and I can usually express what I need simply. Reflection could use a little love, mind you.


I'm building some projects that are only targeted at 5.5 -- once you do that, and stick to all the PSR standards, then it's actually really nice, super productive, and the cruft that exists gets ignored. I like PHP still shrugs


True. But Wordpress is a blogging engine with tons of stuff bolted on to make it behave like a CMS. It appeals to the same group of people that disable error reporting to make their spaghetti code work.

I do a lot of PHP programming. Frameworks like Laravel are a godsend. Sometimes I have to work on a Wordpress project and it makes me cry.


Those same arguments would apply to Python too, and it doesn't seem to have nearly as much cruft.


True. But very few languages can claim to be as elegant as Python :-D


Python is elegant, and my first real commitment to a language, but imo nothing beats Haskell in elegance (though scheme has a certain beauty about it). Perhaps this is just me being temporarily enamored though, I can't help but to link to this post:

http://www.xent.com/pipermail/fork/Week-of-Mon-20070219/0441...

Haskell and I have been doing well so far in the "RealWorld" and I hope it keeps going that way :D If not, I'll probably put more time into python and C again.


Can't disagree there. But, Monads are a huge hurdle and memory leaks are hard to fix.

(Although I should add it's a few years since I've played with Haskell. Maybe things have moved on....)


I personally don't feel that I've struggled with monads that much. Perhaps that was because I was okay with "I know how to use monads or wrestle them into getting something to work" (took 20 minutes) until I got to "I understand what monads are for, I understand how to compose them, and I can see how they aren't a hindrance and in many cases are useful." (has taken 4-5 months on/off learning).

I haven't ran into memory issues yet, but I have heard others have a very hard time reasoning about memory/space leaks. However, something I hear less often is that the memory problems people have also happen in other languages.


Monads are a mostly a non-issue, once you understand them.

The accidential memory leaks still exist.


> Monads are a mostly a non-issue, once you understand them.

I prefer to emphasise the "... once you understand them" bit.


Well, that was the parent's point:

PHP, heavily used in production, godawful language.

Perl, heavily used in production, godawful language, but at least it's not PHP.

Python, heavily used in production, pretty good language most of the time. (It's refactoring effort is Python 3, but ended up not changing very much.)


Just ask a Go dev about how "elegant" they think Python is.


I would not call Go elegant. Simple maybe, but not elegant. It's not concise and it's not very powerful (concurrency aside(pun)).




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: