Tag Archives: PHP

Libraries Should Use Liberal Licenses

One of the biggest concerns I have working on WordPress and developing libraries is that any library I develop is going to fall into the GPLv2 license and I’d rather people use my code anywhere for any purpose. Quite frankly, if someone wanted to take the code and develop a commercial product, then so as long as they don’t say they wrote it, then I’m happy. When writing libraries and code for WordPress, you don’t have that choice or power.

The advantages of having your library as part of WordPress is the support. If there is a bug in the library, then a fix is going to be patched for WordPress and hopefully sent upstream. Plus, the amount of people working on WordPress and fixing problems is going to be more than your project and the number of users is going to be greater as well. This has benefits in that bugs will be found and fixed sooner leading to a faster development cycle that isn’t completely dependent on your work schedule.

That said, a library can be another license just fine and work within WordPress. Any library code I develop for WordPress (controller) is going to be New-BSD and whether it is included or not is up to the developers with commit access and the community. There are others developing a solution that will be more GPLv2, so it is unlikely that within the next few months that I finish my project and port it to WordPress that it will be needed.

The point is, is that applications should be restricted, because they take longer to develop and thus developers using the project have more incentive to follow the rules of the license. A library can probably be recreated within a reasonable amount of time depending on the developers skill and experience.

I think given that fact is why I keep weighing the benefits of using WordPress verses not using WordPress for a current project. Sure, if I focused on just the project elements I could have the project completed relatively soon, but contained within the confines of WordPress and the way it does things, the project wouldn’t stand on its own well enough. The license of WordPress itself is compatible or will be compatible with my project. I’d be using GPLv2 for the application HTML and administration code. It is just simply that I can get away with coding the framework quickly on my own without all of the so called bloat of WordPress.

I can build much of the WordPress core for what I’m needing, the news and content feeds. Really, I think I can probably just strip down what WordPress has and just have a even more limited subset. If I did this, then the code base would be smaller. I could also build a bridge that would take advantage of WordPress, if the application had DB access to the tables. Alas, I could even just go with RSS and ATOM standards to allow for the news to be pulled, but that doesn’t complete the content portions.

Really, that is what drove me to using WordPress in the first place, but I’m thinking that writing a library that is New-BSD would serve my purposes better. I could always use another class library or framework that used a liberal license. That is really the beauty of using such a non-restrictive license, in that you are open to do and enjoy a larger amount of freedoms.

I don’t really mind someone creating a commercial component for the application, because really if there ever grows a community that draws upon the project, then I did something right. Serving a purpose and not limiting people based on some perceived notion of fairness for users totally ignores the real problem. I wouldn’t want someone stealing my code and making money off of my back and off of others, but most programmers don’t sell libraries, they sell solutions and products. A library is not a product and its usage serves only to help create a product, if it helps to create one quicker and better than the programmers using it could have otherwise, then I believe both parties were well served.

Another problem I have with WordPress is that you’re required to work around its flaws to create a product. What does WordPress do well? It does content and administration well, so plugins and applications are built around WordPress that extend these areas. What it doesn’t do well is allow itself to be without neither content nor administration. If you use the administration, then you must use the content portions, there is just no other reason to use WordPress. Alas, you either must use the content portions or you must hack your way around them.

WordPress doesn’t lend itself to applications that aren’t related to content in some way. I do think that WordPress will become better and I believe that most people look beyond the license, because it really is an okay one. For those that wish to do without, there are other projects and frameworks that exist and recreating WordPress wouldn’t take very long.

Well, I say that and really I think people might miss the point with the statement. What I mean to say is that a programmer can develop a theming system pretty easily, it may not have all of the features of WordPress, but it would work fine. WordPress theming and plugin system is simple for most competent programmers to reproduce and even hopefully do better. The bulk of what gives WordPress its size and what would take the longest to reproduce is the Administration and convenience APIs. What I mean really, is that you can do without them. I’m not really saying it would be simple to rewrite WordPress, but to take what it is and recreate it.

Which is what I’m doing, all I need is the content management (pages) and the news (posts). Everything else about WordPress, I can either do without or recreate fairly quickly myself. Still, it seems I would have been better served if bits of the API were liberal licensed. I don’t believe BackPress has a liberal license and I believe that is a shame. Even more so, because most of BackPress could be quickly rewritten with a liberal license and would make it obsolete. Not to say anything about bugs and documentation. However, generally, once you’ve written the API that obsoletes one in BackPress it becomes relatively simple to maintain it and match any improvements made to BackPress.

The point that I’m trying to get across is that applications, if they are done well, are harder to reproduce than libraries. And really when I say fairly quickly, I generally mean someone or a group with a lot of time of their hands with three months to kill.

Possibly Related Posts:


Dynamic Tree Building in PHP

I know of the data structure, I just never had the privilege of ever using it. It seems not many others have been intimate with building trees dynamically. Yeah sure, building a tree statically is easy and most people do so whether they realize it or not.

The problem I had is that PHP doesn’t offer built-in procedural or object-oriented tree support. Just Hash, Queue, and Stack, but you can use many of those functions with Tree data structures to traverse and edit a tree. Nothing that allows easily creating one or normalizing the tree. The Tree data structure has its own methods for easily searching for internal data that isn’t compatible with Hash types.

I decided to copy some of the resource above and also create an object-oriented Tree that better manages and searches the internal data.

Procedural Tree

To create a tree you have to first create an array and then create an reference to that array using its index.

$node = 0;
$parent[$node] = array();
$child = &$parent[$node];

It is better to create a recursive function if you are going to go into an unknown depth.

  1. Check to see if you need to continue
  2. Calculate which nodes will be children.
  3. Create a loop to add the children.
  4. Add a child to the parent.
  5. After each addition of children recursive go into the function with the previous child.

It is possible to crash PHP or use up vast amounts of memory very quickly within the infinite recursive loop. Therefore you need to make sure you allow for breaking the flow1 when the tree should not be created further. 2 is figuring out which nodes should be added to the parent and creating a loop3to add them. You’ll need to go into the recursive function5 right after adding each child4 to build the tree out.

My incorrect implementation of building a tree for Shortest Path First will give a better example of what I mean. You should not however use it, because it hasn’t been tested for correct functionality. It does build the tree, but it doesn’t do any additional checks, such as building the tree based on score and it needs to keep the coordinates somehow without going into an infinite loop. This isn’t showing how to implement the Dijkstra algorithm, or more accurately how to poorly implement the Dijkstra algorithm, but just the above algorithm.

// $Closed an array of nodes that will be used to create the tree.
// $measure is used to find the children.
// $tree is the reference to the tree data structure
// $end is used to end the recursion.
function buildTree($closed, $measure, array $tree, $coord, $end)
{
    // 1
    if(count($closed) == 0)
    {
        return;
    }

    // 2
    $perimeter = $measure->getPerimeterCells($coord);

    // bug
    // Part of 1
    $perimeterIndex = $closed->lookup($coord['x'], $coord['y'], $coord['z']);
    $closed->remove($perimeterIndex);

    // 3
    foreach($perimeter as $cell)
    {
        // This tests to see if the child node should be added
        // Part of Shortest path first so no explanation (which
        // would probably be incorrect anyway)
        $exists = $closed->lookup($cell['x'], $cell['y']);

        if($exists !== false)
        {
            // Index Creation: yes it is an string and yes it is
            // the index. Don't ask.
            $string = "$cell[x], $cell[y], 0";

            // WOOT! The end was found, no need to continue
            // The recursion, go back to the parent.
            if(($cell['x'] === $end['x']) && ($cell['y'] === $end['y']))
            {
                // The 0 would allow us to traverse the tree later to
                // find the instances where the end was found
                // and only keep those.

                // 4
                $tree[$string] = 0;
                return;
            }
            // Breed the parent
            else
            {
                // 4
                $tree[$string] = array();
                $nextNode = &$tree[$string];
            }

            // Ignore this
            $nodeCoord = $closed->seek($exists);

            // 5
            buildTree($closed, $measure, &$nextNode, $nodeCoord['node'], $end);
        }
    }
}

You would have to create the parent yourself, but the fun part is that nothing has to be returned. Since you created the parent you can then use that same parent for anything else you’ll need.

$parent[$node] = array();
$firstchild = &$parent[$node];

buildTree($closed, $measure, &$firstchild, $coord, $end);

print_r($parent);

One thing to look out for is that when doing recursion, much like loops, is that you have to give yourself a way to break out of the recursion to keep from having an infinite loop. There are a lot of ways for doing this, my example uses the easiest, but not the best.

Possibly Related Posts:


My Standards, Your Standards, Your Standards My Way

In response to Cal Evans, reply, I’ll have to say that if a group of people wish to join together and develop using a similar standard, then I’m all for it. That does not mean I am going to follow it and actually, I was all ready to follow suit, until Cal opened his email client and typed his opinion.

I believe it is great for people to follow standards, and Cal Evans does say that they aren’t for everyone. That is true. I don’t follow the PEAR spaces indentation, nor will I ever. Well, unless I wanted to submit something to PEAR, but I highly doubt that I’ll have any involvement with PEAR in the future. It is true that to debate the tabs vs spaces issue, is well futile. I have my personal reasons for using tabs based on some “facts,” but if I wasn’t project leader and the project leader had a standard for using spaces then I’d do it.

The issue is that some people don’t agree with some of the standards and since it isn’t really open for discussion, unless you opt to join in and become a member of their group. Well, what they say goes, just like in PEAR, project or work coding standard, and now your own project.

I can see some PEAR influence in with the standard and I hope that in the future several unlike minded members join. The problem is that while they might have some disagreement, I don’t want to follow PEAR. If that is the case, then I won’t follow the convention based on that. Of course, I wasn’t there, so really, in two hours, they only formed three standards, so it sounds like it wasn’t group think.

I hope they don’t dive into the tab vs spaces, because then they’ll develop into a war. When you follow a standard, you can’t just follow bits and pieces. What I’m going to do is use what they have as guidelines for an upcoming project, because well, I like them.

What I don’t like, is a small group of people (hell, quite a few of them are kick ass developers that I respect highly) dictating what I should or must do with my code. Shit, I’m a big boy now. Damn it! Now pass me my bottle!

Possibly Related Posts:


PHP TRUE vs true — Case Differences

When you use “TRUE” as in all caps, you are saying that the Boolean is a constant. If you are saying that the variable value is a constant value, you are saying that the value is 1 and not ‘true’. This has always been a bit of contention for me, because I’ve always felt that Boolean values should be more than numerical values.

Those from the C background or languages where there are no Boolean keywords, may prefer the constant, since it is familiar to them. Well, that is to say that I have a C++ background, which does have Boolean keywords (that is also to say that those who have used C, before they finally added the Boolean keywords to the language in the C99 Standard). That is beside the point, it is true that computers don’t understand “true” or “false” the words. It is say that programming isn’t about what computers understand, but what people understand.

So, it is a standards subject and up to a matter of preference rather than a matter of what you should or should not do. I prefer to believe that “true” and “false” are keywords in the language, but the technical background is that they are constants with case sensitivity turned off.

I will say, to further my point is that, you should try this code sometime.

if( 0 === false ) {
    echo "0 is the same as 'false'.";
}
if( 1 === TRUE ) {
    echo "1 is the same as 'TRUE'.";
}

You will find the answer isn’t exactly accurate, in the same sense that a numerical value is not the same as a Boolean value, but if TRUE is a constant and then the value should be one (I really forget what the value might be, it could very well be ‘TRUE’ to ensure that 1 !== TRUE).

Possibly Related Posts:


What I’ve Learned From WordPress

The experience with working with WordPress the past year and a half has been educating. While the solutions found in WordPress aren’t exactly perfect, I’m finding that verses others a lot of what WordPress does, is what I wish other web projects would do. I’m also finding that I develop more per the techniques that WordPress uses for themes.

Plugins

On the topic of plugins, if I had not worked with WordPress, then I would never have seen it as filters and actions. My solution would have been to use the Adapter Class Pattern for replacing functionality. The problem is how to handle allowing multiple implementations and the Adapter pattern does not handle those well. Could use the Observer pattern, which is more or less what WordPress uses.

The solution in WordPress is not tied to any one class, uses an unified API, and is extremely easy to work with. That I think is what allows WordPress to be as simple and easy as it is. Sometimes, adding content, replacing content, and extending, doesn’t or shouldn’t involve editing source code, but hooking into a filter or action. It is not required to know how it works, just that if you use this hook that you can manipulate the feature to your requirements.

With the Adapter Pattern, you have to know specifically what it is you are replacing, and how your replacement will work with the code. It works well the use cases where the implementation you are handling isn’t as simple as filtering content or specifying an action. The advantage is that, you can use the same API within the code to do something else. So a multiple step process would be great for the Adapter pattern.

Themes

For themes, what I’ve learned from WordPress is that it is not enough to provide data and handle it, but to also provide the API for handling that data. It is easier and a lot more faster for the developer who doesn’t think or realize that other non-developers may need to make changes to the theme to handle the data directly. The problem stems from those who do not know the PHP syntax and what problems arise when you screw up that syntax. I think that is why Smarty is used for some templating systems. If you screw up Smarty, you are not going to bring down that page, it just won’t display correctly.

I’m not saying that Smarty is better than straight PHP, just that Smarty has its purpose. You can make PHP just as fool-proof as Smarty, if it is done correctly. I suppose, the issue is still one of education. I create iterators with my data, and also methods for handling that data. The work flow is not simple for others and I have to supply documentation for how to use the iterators and methods. I believe that once people know what they can do with the iterators that they find it is easy to work with. Looking at the code, is another matter and you really need to know what you are doing in order to modify it.

Beautiful code is not in the implementation but the use, you are abstracting away difficultly from the user and sometimes the implementation is going to be seriously ugly and there is no way to make it beautiful. The best that can be done is making sure the user doesn’t have any problems in understanding how it can be used.

Developing Solutions

It is always my goal to strive to develop the best solution, no matter what, but given my limitations, I think the best I can give is one that is working. That I think is important regardless of the solution. I think developers get caught up on how well the solution functions verses that it is even working. It is not to say that improper or poorly developed solutions shouldn’t be criticized, because eventually, the solution is going to have to maintained.

The better the solution is developed, the easier the solution will be to maintain, extend, test, and refactor. That has always been my goal. The problem is that when you work with new patterns, data structures, and APIs, the solutions don’t always work out that way.

Roles and Capabilities

The point with WordPress is that, it has shown me solutions that don’t work that well. The Roles and Capabilities API and data structures work within the WordPress application, it is just not something you want to duplicate elsewhere. What is great about the Roles and Capabilities implementation, is how the API works and what data it contains. There are probably three or four core ways to develop Roles and Capabilities in web applications. Well, there are many more; anybody who developed any PHP application will have their own, it is just that they’ll fall in line with the general other solutions.

What I like about the WordPress solution is that you aren’t using levels, which if you’ve ever developed a solution using them, you’ll soon find that it is very limiting. You aren’t using the sort of CRUD permissions that phpBB and Zend Framework uses. I’m not saying that the solution found in phpBB and Zend Framework are bad, it is just that for most simple applications, you are more concern with simply if they have the capability to do something and not whether they can browse, but not delete, or read, but not browse.

That is not to say that certain aspects of the WordPress roles and capabilities doesn’t fall into that model, because certainly parts do. It is that not enough of it does and that you can still implement the CRUD way using the WordPress implementation. The difference is that instead of having one row, you will have, at most, four or five. Not that it makes any difference, because your concern will be for one or at most two of them and not all of them.

Also, it is difficult for me at least to visualize how every capability would even need most of the permissions. If I just need the capability for reading, why am I needing to tell whether they can delete, there is nothing to delete anyway. I believe those work that way, because in administration, you are going to be implementing the majority of the permissions anyway. Administration, yes, normal web applications you don’t, where you still need to be able to tell someone can to do something, but not whether they can delete, read, browse, edit, etc. In this instance, the way WordPress does it works very well.

You can work both ways into any application, it is just that the way WordPress does it, is easier to visualize, easier to implement, and a lot easier to check against. It is the way the roles and capabilities are stored in WordPress that I don’t agree with and well, it is something else in developing a table structure, because there are many ways to implement that as well.

If I had not seen the way WordPress developed their solution for roles and capabilities, I would probably continue to either use levels (where I needed a simple, quick hack). If I needed something more complex the way Zend Framework and phpBB solves it.

Interfaces

I’m used to torturing myself when developing user interfaces. What I’ve learned from WordPress is that it isn’t a good idea to do so for your users. They want simple, easy and less steps. What we are fine with doing as developers of our own work, users only concern is just getting stuff done.

I think I’m taking that more to heart as I use more JavaScript (jQuery, etc) to develop user interfaces. I’ve found that you can go overboard and interfaces should still be developed for those who don’t have JavaScript enabled. It is easier to work with JavaScript to give the interactivity of Flash for web sites, but all the features of HTML with regards to search engine support and mobile browsers.

Well, the study of User Interfaces is a whole another topic on to itself. There are jobs out there just for those who develop user interfaces and research and develop them. For me as a developer, it will continue to be something I research and study, but will never be my primary focus. I’m hoping to meet someone who can do that for me, eventually, or if the projects I work on start making a profit, I can hire someone to do it for me.

Installing

I used to take installing for granted. I’m not saying that I included them in all of my projects, because I don’t. It is just that I was used to modifying configurations manually and setting up the tables and what not manually as well. Most of the projects I’ve used have always had a manual installation process.

I don’t think that is as useful any more, because the best web applications out there, have automatic installation process for which you can configure when you setup and it will do everything to get the web application functioning for you.

For me, after seeing the many installation processes that exist, I don’t think I’ll ever develop an open source project that forced you into running SQL to create the table structures yourself. It isn’t too difficult to implement something that does it for the user. Well, to be honest, the previous projects I’ve developed, the installation has always taken a backseat, because I didn’t need it and given the time I had to work on the project, it just never got to the point where I could devote time to it.

I’m going to change that. It doesn’t have to be difficult, nor does it have to hold your hand completely. Therefore, I’ve done it easily before. It was just a page you went to, that would do a few things to setup the application so that it was ready to run. It didn’t take that long and while it isn’t the best implementation, it works.

Conclusion

I think this is mainly why I’m not going to be developing patches for WordPress any more. I need to spread my wings and take flight and make my own mistakes. Working and fixing the problems within WordPress has been fun and a learning experience. I need to make my own mistakes and hopefully someone will come along and show me a better solution.

That is not to say that I won’t go back to WordPress in the future, because I plan on it. I plan on taking what I’ve learned in my future open source projects and applying them back to WordPress. Hell, given the time it is going to take to finish the PBBG projects I have in store for myself, I think by the time I go back to writing WordPress patches, other problems and solutions will have found their way into WordPress.

So I’ll like to thank the WordPress community for helping me and not kicking my ass when I was too harsh.

Possibly Related Posts:


PHP5 Straw Man Argument

Perhaps I’m wrong with this, I don’t want to have my foot in my mouth, so I’m not going to mention very many people by name. Except for Matt Mullenweg, just wanted to plug his new domain for reasons I’m not entirely sure of. Well, or it could have been that I started this off, in an attempt so that you’ll be baited to believe my lies, sort of how Al Franken works with his books.

The argument basically with why WordPress doesn’t transition over to PHP5 has two parts, or two main parts. The first is that users won’t benefit by any way from the transition. The second is that PHP5 offers nothing that can’t already be done in PHP4. These two are true, but I’ll counter them anyway.

The point with programming standards and languages is never about users, only the end result is. End users don’t give a rat’s ass what language the product is as long as it fulfills their needs. Quite selfish of them really, wonder why they matter in the first place. Ah yes, they pay the bills, so I suppose it is a good idea to kiss the ground they walk on then. If users don’t care about what programming language is used, then who does? I wonder.

Could it be programmers? Nah, if that was the case, then the argument wouldn’t have any relevance. It is funny, because the people shouting and arguing about transitioning over to PHP5 are not users, but developers using WordPress.

See the issue with the statement is that the argument actually is relevant, because users and their needs runs the direction of the project. If the users wanted WordPress to wash your feet, while giving you head, then by damn it will be done! It might take forever and cost an exorbitant amount of money for the end product. As I said before, users of WordPress don’t care about the language, if it was written in Python, then people will be looking for hosting that offered Python in order to use WordPress.

To say the least, the reason, which bears the most importance in the discussion is that there is still a large minority of users still using PHP4. With most hosts, they’ll be able to upgrade with either a click of a button or at least a directive in their configuration. No, they won’t benefit at all, but that leads to the second part to emphasis the straw man more.

“There is nothing that PHP5 offers that can’t be done in PHP4.”

This is true. It is completely possible to offer WXR support in WordPress, however the regular expressions does amount for a fair quality of bugs and WTF?s when other people don’t follow the format set by WordPress correctly. If something like SimpleXML and, or DOM was, were used, then there wouldn’t be an issue and the iteration might even be faster. The point still stands that a great deal of XML features would be tricky or require a whole lot of additional work to support both PHP4 XMLDOM and PHP5 DOM extensions.

The other problem is providing automatic Daylight Savings transitions, where you don’t have to set the time manually. This is easily solved with PHP5 DateTime classes and functions, but not everyone has the non-standard PECL extension to allow it in PHP4. Actually, shared hosts don’t have it at all. Well, at least one feature that could be provided, if WordPress required PHP5 and dropped PHP4 support.

Well, besides the XML stuff, the DateTime seems to be the only known issue that can’t be easily solved without moving to PHP5. That is, I’m writing a library, which is for WordPress, that is completely OOP, so we’ll see just how well it holds up with the ease of use of the current WordPress API.

I believe that as developers push the limits with WordPress, more and more reports will come in that basically say, “Well, if WordPress supported PHP5, this would be incredibility easy.” Well, I think that is sort of the issue with the statement. Sure, the daylight savings issue could be solved in PHP4, you could connect to the timeserver for the timezone and get the time based on that server and update the time for the user. That is quite convoluted solution. I think using regex to parse XML is also convoluted. Better solutions exist in PHP5 and as the development of PHP4 has stopped, continuing support for it becomes an issue.

No new code should be written for PHP4

Truth is, no new code should be written for PHP4, because that version has reached the end-of-life and no new versions will be made for it. That said, projects like plugins, themes, and independent projects using WordPress should all be written using PHP5. It has almost been a year since PHP4 has end-of-life, and 6 months since they’ve released any patches.

I think that version 3.0 of WordPress will be PHP5 only. Why? Matt Mullenweg has recanted what he said in his PHP5 post made quite a while ago. PHP5 is faster, more stable, and quite frankly better than PHP4, so it makes sense that he would do so. As project dictator, it is really up to him when the project moves over to PHP5+ only and drops support for PHP4.

Possibly Related Posts:


No longer on Planet PHP

I’m not quite sure when I was dropped from Planet PHP. I haven’t been there in a long time and certainly haven’t posted on there for a long time, so it is no surprise. I think it is nice actually. I said what I wanted to say and I don’t think I have anything else to say about PHP, well at least not for a while.

The reason I joined in the first place was that there weren’t that many posts that I wanted to read. Now, there are more than enough posts that I want to read and also need to read. Many and better bloggers on PHP have joined the Planet PHP site, so I am not needed. It was fun and I’m glad they allowed me to join the community, but I’m happy being pushed aside and replaced by far better people.

I started visiting the site again and well, I enjoy it once more. I’m visiting the site more and more, so my addiction to PHP news is coming back. It is a safe drug I can get used to. I’m still addicted to WordPress news, but a little bit of PHP here and there couldn’t hurt.

I plan on retiring the Planet PHP category and moving the posts over to the “PHP” tag.

Possibly Related Posts:


Talk at WordCamp Dallas 2008

I think it has more akin Mike Naberezny talk at OSCON, except once you watch my video, you’ll probably realize that Mike knows more than me on the subject. I am just guessing.

My focus was to get more people to build test cases for the Automattic WordPress Tests automated test suite, which focuses more on integration testing (what I commonly call functional testing).

I look forward to slides or whatever for OSCON and hopefully, I’ll be able to go next year, if another testing methodology presentation is given.

Possibly Related Posts:


Joseph, PHP, Ruby, and Python are Languages

I think Joseph Scott doesn’t realize that PHP, Ruby, and Python are languages and therefore try to solve computer languages problems. I was listening to the CouchCast Podcast with Joseph Scott and if what he said could have been interpreted one way, in that he went off on a tangent that these languages should solve the Web Problem together. This counter rant to that interpretation would probably go ahead like below.

However, other than PHP, none of the other two are geared towards the web.

What this means is that, and even with PHP, is that computer languages try to solve the computer language problem. It is hard enough to decide how to implement lambdas, objects, and how libraries and code interacts and then have that compounded by these general web problems, which are different for every body.

PHP does not concern itself with page caching, it is up to the developer. Ruby and Python do its best with general programming solutions and the developer has to write for the web. Ruby and Python Languages do not concern itself with the web. Would it be better if they did? Probably not, because they do a great job at allowing developers to solve these solutions and to allow other developers to solve the problems for other developers. They do this very well, so to say that the language engineers of Ruby and Python should jump aboard with PHP to solve page caching or whatever solutions is probably wishful thinking.

It isn’t going to happen. The language engineers are concerned with helping other developers solve their problems and that takes a long enough time than to branch out and “fix” other issues within the community.

Languages generally try to do this, by implementing a Standard Object/Procedural Library that comes with the language. This allows for all developers to use, instead of recreating the wheel in each software package. However, this is only a language problem, because developers are implementing the same solutions over and over again and if they change projects have to relearn the similar solutions.

For PHP, it might be a good idea for it to solve the page caching problem, but oh yeah, it already has. Yeah, it isn’t going to hold your hand, but it at least allows you the ability to hook into PHP to easily solve the problem yourself. That is what computer languages do, they are supposed to help you solve problems yourself without deciding how to solve them for you.

Also, solutions for problems will inherently be implemented differently in PHP, Ruby, and Python. We all know that Ruby on Rails, a framework, does everything differently than the language PHP, which is to say that other frameworks developed in PHP are differently implemented than Ruby on Rails. The web solution in Python is logically different in implementation, than even the frameworks in Ruby and PHP.

Therefore, you shouldn’t be saying that language engineers should get together, because that is never going to happen, ever. What you should be saying is that Developers of Frameworks should get together to provide closer implementations, so that if I work on a popular framework in one language, I can go to another framework in another language and jump right in. This has been tried with cakePHP with some similarities Ruby on Rails. However, part of the problem hindering full compatibility is that Ruby has features that PHP does not.

Technically then, it is completely up to the users of these languages to take the time to solve some problems together than the programmers working on those languages. Give those people your love, because they spend a lot of time trying to make the rest of our lives easier.

Update: This is what Joseph was meaning to say and I just misinterpreted the podcast. It is funny, I thought, what is he talking about with the mindset of language mailing lists and reading back to Dave Winer rant. It didn’t occur to me until later that the direction could have been toward general purpose language forums that don’t have to do with the direction of where the languages are going. The funny part is that I tried to understand the context by relistening to that portion, but missed the part about it being focused toward local communities.

I’m going to leave this up, since the rant is accurate, whereas the person is it directed to is not to blame.

Possibly Related Posts:


SPL Countable

Introduction

Allows the object to be used in the PHP count() function. Even on PHP 5.0, it can still be used, if called as a class method.

Its purpose is best served in iterators or classes who elements are dynamic.

Interface

It only has one method that needs to be implemented, which is count().

interface Countable
{
    function count();
}

Usage Example

The example given is the not the normal practice and shouldn’t be used in real world applications.

class CountableObject implements Countable
{
    private $count;

    function __construct($count = 10)
    {
        $this->count = (int) $count;
    }

    function count()
    {
        return $this->count;
    }
}

If the user is using PHP 5.0, then they can still get the amount of elements.

$countable = new CountableObject(20);
echo $countable->count();

If the user has PHP 5.1 or above, then they can use the magic the interface provides.

$countable = new CountableObject(20);
count($countable);

Iterator Example

This is how you really should use the countable interface in real world applications.

References

Official Countable Documentation – From offical SPL documentation site.

Possibly Related Posts: