Live data from Hacker News

PHP Hacking aka trying to push PHP internals forwards

xarg.org

51–60 of 62 posts

Re: PHP Hacking aka trying to push PHP internals forwards

#51
Might be not completely offtopic if I asked here: is there some reason array, resource and object were never folded into one type (object)? It seems like array and resource are kept separate just because it's done this way internally (with array and resource super classes). Why can't resources or array be native-code-backed objects like some modules in python?

It seems like many special cases were left over from old versions and the inertia prevents any change.

Re: PHP Hacking aka trying to push PHP internals forwards

#52
post #38

Earlier quoted context omitted.

No it wasn't. As sc68cal says, its a patchbomb. And if you think otherwise, let me know how I can revert his changes to remove short tags and the mysql* changes using a single git command (hint, there isn't). I'm all for changes to an open source project - whether it acts like one or not - but every open source developer should, at some point, learn that gigantic patchsets with lots of unrelated changes are a big no-…

I'm just pissed that he didn't even bother to actually fork the project. On Github! WOW! All the previous commits before the fork? Gone. Poof. It's completely without any context. Even though there's a big "FORK" button!

I work on it. I currently update the git repo with the svn sources. This is somewhat slow... May I ask what you want to do with the dissected patches? Try to build a "clean" version as pbiggar has said?

Re: PHP Hacking aka trying to push PHP internals forwards

#54
Minor nitpick given the scope of these additions, but his use of a boolean argument to enhance implode is not my favorite.

  implode(',', $array, true)
A new function (or even leaving it the way it was) is far more readable.

  implode_keys(',', $array)

  implode(',', array_keys($array))

Re: PHP Hacking aka trying to push PHP internals forwards

#55
post #20

Good to see. It's about time PHP got forked even if experimentally. It seems to me that you could fix a lot of the problems with PHP by breaking backwards compatibility.

Many of the problems and annoyances with PHP could be fixed while keeping backwards compatibility. Just a short list I can think of now: - Short array syntax. Completely optional but would clean up the language quite a bit. This has been proposed several times and shot down each for no real good reason. - Promote complex primitives into objects. With the proper interfaces it wouldn't break any old code. Once this is…

Regarding your first point: it seems short syntax for arrays may well make it into PHP 5.4.

http://www.reddit.com/r/PHP/comments/hw8da/php_fork_based_on...

Re: PHP Hacking aka trying to push PHP internals forwards

#56
post #19

Good to see. It's about time PHP got forked even if experimentally. It seems to me that you could fix a lot of the problems with PHP by breaking backwards compatibility.

What would a sane version of PHP look like? What are the good parts of PHP besides easy setup?

The good parts of PHP, just off the top of my head: Extremely forgiving syntax which makes it quick and easy to bash together something that just works, implicit type conversion, a vast array of built-in functions, readability, near-ubiquity, generally very strong documentation with a healthy focus on example code, and the way it interpolates with static HTML, which I'm sure there's a word for but I can't remember offhand.

Re: PHP Hacking aka trying to push PHP internals forwards

#57
post #56
post #19

Earlier quoted context omitted.

What would a sane version of PHP look like? What are the good parts of PHP besides easy setup?

The good parts of PHP, just off the top of my head: Extremely forgiving syntax which makes it quick and easy to bash together something that just works, implicit type conversion, a vast array of built-in functions, readability, near-ubiquity, generally very strong documentation with a healthy focus on example code, and the way it interpolates with static HTML, which I'm sure there's a word for but I can't remember of…

Date and time handling with date() and strtotime(), magic methods, simple and practical array handling, proximity to the HTTP so you can solve problems the way you want instead of the way someone tells you you should.

Re: PHP Hacking aka trying to push PHP internals forwards

#58
post #56
post #19

Earlier quoted context omitted.

What would a sane version of PHP look like? What are the good parts of PHP besides easy setup?

The good parts of PHP, just off the top of my head: Extremely forgiving syntax which makes it quick and easy to bash together something that just works, implicit type conversion, a vast array of built-in functions, readability, near-ubiquity, generally very strong documentation with a healthy focus on example code, and the way it interpolates with static HTML, which I'm sure there's a word for but I can't remember of…

What I see as the big strength is how easy it is to set up mod_php - possibly in no small part due to how most Linux distributions have solid defaults for mod_php5 and keep it up to date. The things you listed I'm not so sure about.

I don't think it's the syntax that's forgiving as much as the type coercion. JavaScript is actually more forgiving syntax wise, for example - PHP throws a fatal error when a semicolon is missing at the end of a line, JS interpreters fill it in. Unlike PHP, though it will throw a ReferenceError and die upon referencing any undefined value. PHP just coerces that to something falsey... they'll both die trying to call undefined functions or methods.

I don't see how PHP is not more readable than Python or Ruby, either. There's really nothing about the language itself that makes it readable or better for beginners.

The docs are definitely good, I agree. I think they need to do something about the outdated and not-so-well curated comments on each entry though.

Near ubiquity is good, but it also makes a lot of good PHP resources get lost in horrible noise. WordPress, for instance - if you search to solve anything, you find scores of outdated tutorials offering solutions to problems which have been solved by the official branch for years. Then, you find more blogs blog-spamming the incorrect solution... so it's actually easier to search for and find Rails or Django help, in my experience. A large percentage of the PHP code out there is notably terrible, for whatever reasons.

The 'interpolation' would be called templating. You can do this in most languages (erb for Ruby, for example) but it's not always considered a good idea to give the template language logic capabilities. It happens that this is the default for how PHP and Apache work together, and I think the straightforward concepts of files, directories, scripts it's easier for beginners to understand and work with than framework style URL routing.

The large software eco-system centered around tools consumers use such as WordPress or joomla has helped PHP grow.

Set up is easy, but the majority of PHP users probably never set up their own Linux boxes with Apache anyhow. If they wanted to, though it would be easier than say, Django since last I checked Ubuntu was still providing Django .96 packages.

The ease of setup comes from every shared host offering PHP and MySQL. If they all offered Python, Django and Postgres support, with cpanel configs and PhpPgAdmin or the like, people would magically find Django really easy to set up. That's just how it goes when you have lots of market share.

Re: PHP Hacking aka trying to push PHP internals forwards

#60

Boo, deleted short tags. Why do people hate short tags again? I can't remember because <? is not valid XML so there shouldn't be any problems with mixing php and xml... hmm... I wonder ....

Short tags are why I don't need a template engine for PHP. And can write instead of . This had been a unique feature that no other scripting language offers. This is a historic sign indicating that PHP was designed for the web.
Post reply on HN