Author: Manuel Lemos
Updated on: 2015-01-18
Posted on: 2012-07-04
Categories: New site features, PHP Performance, Lately in PHP Podcast, PHP opinions
That is the main topic discussed in episode 25 of the Lately in PHP podcast on which Manuel Lemos received Gustavo Lopes, a PHP core developer.
Listen to the podcast, watch the podcast video or read the transcript to learn more about these and other interesting PHP topics discussed on this episode.
Download Size: 31MB Listeners: 3347
Introduction music Harbour used with explicit permission from the author Danilo Ercole, from Curitiba, Brazil
In iTunes, use the Subscribe to Podcast... item of the Advanced menu, and then enter the URL above to subscribe to this podcast.
Note that the timestamps below in the transcript may not match the same positions in the video because they were based on the audio timestamps and the audio was compacted to truncate silence periods.
See the Lately in PHP podcast play list on YouTube and Subscribe to this channel there.
- Article about the New Features of the PHPClasses site on the 13th Anniversary
The 7 Main PHP 5.4 Optimizations Explained by PHP core developer Gustavo Lopes (0:31)
The speculation about future variable type declaration support (32:24)
New Feature Announcements on the PHPClasses site 13th birthday (40:49)
Winners of the PHP Programming Innovation Award of April 2012 (58:43)
Manuel Lemos: Hello, welcome to the Lately in PHP podcast. I'm Manuel Lemos, always the regular host of the podcast.
The 7 Main PHP 5.4 Optimizations Explained by PHP core developer Gustavo Lopes (0:31)
Manuel Lemos: Today, we are going to have a special episode, special for several reasons. Not only because today, on the day of recording, is the birthday of the PHP Classes site, but also because we have here a special guest, Gustavo Lopes, a country fellow of mine.
Oh, I did not know Gustavo but, you see, since he has been participating in the PHP Core somehow, I decided to invite him because of an article that he recently published in PHP Classes regarding PHP 5.4 optimization.
But first, let me welcome Gustavo. Hello, Gustavo. How are you doing?
Gustavo Lopes: Hello, I'm fine.
Manuel Lemos: Well, it's great that you're here for several reasons. As I mentioned, there was an article in the PHP Classes site. Basically, an article that mentioned some PHP 5.4 optimizations.
Well, one thing that I wanted to comment on, discuss with you, is about the main topic of this article - as I said, PHP 5.4 optimizations, not only specifically one that I mentioned in the article that I learned about this optimization by watching a thread in the PHP internals list in which you participated and gave an interesting contribution by clarifying what exactly happened, because another developer, also named Rasmus, which is not Rasmus Lerdorf, the PHP creator - Rasmus Schulz - mentioned something that he notice regarding an apparent performance improvement in PHP 5.4 which you happen to explain.
But before we move there, I'd like you to talk a little bit about yourself and specifically, what has been your involvement with the PHP world. And I think it would be interesting to start from there, because from what I understood, your background is not exactly computer science. Can you tell a bit more...
Gustavo Lopes: Yeah. No.
Manuel Lemos: Talk about what you do, where you live, how have you reached the PHP world?
Gustavo Lopes: Well, I studied in Lisbon, initially not Computer Science but bio-medical engineering, but developed an interest in this industry. And eventually, I decided to pursue a professional career in this industry. I'm currently living in the Netherlands, in fact, since December.
My involvement with PHP, I started learning PHP and doing some PHP programming. I don't remember exactly when, probably around 2004, 2005. But my involvement with PHP development was accidental, so to say.
Basically, I had a problem that I needed to solve and thought with the right extension, I needed to be able to stream files from a RAR archive without extracting them. And I made some modifications to both the library and to the PHP RAR extension to allow such a thing to be done.
Then, I submitted my modifications back to the maintainer of the extension, Antony, if I'm correct. And he said, "Well, I'm not using this extension anymore. You maintain it if you want." And so basically, I took over that extension in 2009.
And that involved creating them creating an account for me, so I also had access to the bug database. And when I had nothing to do, I would go over bugs and sometimes, I would fix one or two. And eventually, I got PHP src karma and my involvement was a bit more comprehensive since then.
Manuel Lemos: OK, that part is interesting especially for a person that is not exactly from our area of computer science, as I mentioned, not only because, well, being from a different area but also because to understand how extensions work, how they integrate the PHP core and how to actually fix them, which is your original intention with the RAR extension, you need to understand C which is not trivial.
Many PHP developers do not have C knowledge. And even more difficult is to ever understanding of PHP Core knowledge.
That is interesting and hopefully that will be helpful in this podcast, specifically on the topic of PHP optimization. It is one of the most interesting topics that many PHP developers want to know, especially, I'll bet, may affect or not the way they write code.
And specifically in this case, as mentioned in the article, I think we could start from there, so you can maybe try to explain in simple words for those that are not so acquainted with lower level of programming but understand how that affect their programming.
Can you start explaining what exactly is this optimization and how it affects people's way of programming PHP?
Gustavo Lopes: Well, the optimization that was referred in that thread was the way properties are stored in objects. So basically before PHP 5.4, all the object properties would be in a hash table.
Basically, each object instance would have a hash table where the keys would be the properties, the property names. Eventually, with some modifications, but the keys would be the property names and the values would be the values of those properties.
Manuel Lemos: So, just one question - properties, you mean the variable names?
Gustavo Lopes: The fields. The fields of ... Yes. So...
Manuel Lemos: So, functions - does it include functions or just variables?
Gustavo Lopes: No. The functions of upper class, you can add functions to an object instance so all the functions are shared between all the objects of the same type. The table of the functions for an object is shared between all the objects of the same type. Because all of the objects of the same type have the same methods.
This is not the case with properties. An object of class A may have different properties from another object of the same class because you can dynamically add properties to objects. So you can for instance, a class doesn't have any properties by default but you can instanciate one and can add properties after the creation.
So while all the other same type have the same methods, that's not the case with objects. That's not the case with the fields, with the properties.
Manuel Lemos: That's because you can declare...
Gustavo Lopes: That's because you have... They're called dynamic properties. You can...
Manuel Lemos: Assign new values of properties to variables that did not exist.
Gustavo Lopes: Yeah. And the idea behind this optimization was that while that's the case, you can always add more properties to an object, that's the exception, not the rule.
So if we can assume that a large number of objects of a certain type will only have these properties, then we can optimize both the storage of the property values for different objects and also optimize their access. Instead of having to do a hash table lookup to find their property, we can assign an offset to each property and access it directly without doing a hash table lookup.
That's why, now in PHP 5.4, accessing the property is generally faster than accessing an array, an array element. The other part was that this also allows to do away with the hash table and this allows to save a significant amount of memory because the hash table has a lot of overhead than the hash table structure.
Then so the buckets and generally, you have more buckets than elements. We can store a simple, a simple... If we can just store the property values in a simpler way, we can save a significant amount of memory that way.
Manuel Lemos: Right. Well, that is one optimization and or the developers, they want to benefit from that optimization from what I got as long as they do not declare... As long as they declare all variables that they will use initially...
Gustavo Lopes: Yeah, this also means that basically, now when you assign a new property to an object, you basically have a penalty that you didn't have before. So, you should try to avoid doing that. If you have some class that in the constructor assigns the property that is not declared basically of the members, all the instance of that class will be severely penalized because of that.
Manuel Lemos: But so, it's OK to just declare variable without initializing it to some value?
Gustavo Lopes: Yeah, right. Initially, yeah.
Manuel Lemos: As long as it's declared, that will be part of the class properties lookup table, right?
Gustavo Lopes: Yeah, basically, what this does when you assign a dynamic property it will revert to the old behavior. But even then, you might think, "OK, I have the PHP 5.3 performance." Well, you have a bit of overhead because you also have to free the previous optimized structure and then, add the new one. So, this optimization assumes that in most cases, you won't have dynamic properties.
Manuel Lemos: Yes. Well, I think right now, for those that somehow may not have got that from the article, it should be clear that they should declare all variables, whether or not they have an initial value and they can benefit from this.
From what I also got here, if you do not use many objects of the same class in the current script, probably you will not notice much difference, right?
Gustavo Lopes: Well, you'll notice the difference if you use many objects that don't have... I think I know what you mentioned. If you have many classes, the thing is, now you don't have to store the field names on a per instance basis.
You don't have to... Each instance doesn't know the names of the fields. It's not stored within the object storage. You only have a simple array with all the values, not the field names. And that's what Rasmus in his message in the internals mailing list was testing, he was using rather large field names and noticing that these would be duplicated for each object instance.
Manuel Lemos: Yeah.
Gustavo Lopes: And that doesn't happen in PHP 5.4 anymore. So if you have a lot of types, obviously, the names of the fields would have to be stored at least once for each class type. But you still have some savings as long as... You still have some savings because you use a lot of objects.
What this also means - and I've seen actually some project type propelled to use this kind of optimization is that since it's now very fast to access.... I think to access fields, class object fields, now you have an incentive to abandon encapsulation and expose public properties for a fast access. That might make sense. Because, as I've said, accessing object fields now is faster in general than using, than accessing array elements.
Manuel Lemos: So, are you saying...
Gustavo Lopes: And it's especially much faster than using function calls. Function calls are rather expensive in PHP. Of course, in most cases, this is a micro-optimization that won't matter but it might matter also.
Manuel Lemos: So if I got you right, are you saying that accessing public variables or public functions, I don't know if that is... Is it faster or slower than private and protected variables?
Gustavo Lopes: No, it's not faster just because they're public. It's just the fact that they're public allows it to access from anywhere. But now, well, in general, accessing public fields maybe faster, I don't know, because you don't have to do a visibility checks.
But my point was more general than that, was it accessing a field is generally faster than.... Because you don't have to do, for instance, a hash table lookup, basically, when that it involves... of course, hashing the name of the fields involves comparing them, the name of the field without storming the server buckets and finally, adding to the value.
Manuel Lemos: Yeah, also talking about the name of the field, one question that... one doubt many people have, including myself is does it make it a noticeable difference whether you use shorter variable names or longer variable names in this case for classes? Or is it not something that you should be concerned?
Gustavo Lopes: I think that in PHP 5.4, it's not something that you should be concerned because unless you're accessing the field names in a dynamic way, all these string, all these field names that now appear in the script file have now their hash values pre-computed. So, I don't think... It might make some difference but it's certainly mitigated in PHP 5.4.
I remember in that in that internals thread, he was concerned with using long variable names because of the memory impact, not so much the CPU impact. Because the name was being duplicated and if it was long, it would take more memory, et cetera.
And that's not, in the memory side, a concern anymore. But I think - and I hope I'm not saying anything wrong here - I think that in the CPU front, that's also at least a mitigated concern now.
Manuel Lemos: Yeah. But before 5.4, do you think that the variable names would make any difference or...
Gustavo Lopes: Yeah, it might make some difference because to access the fields, you have to do a hash table lookup and that involves calculating the hash of the field name, calculating the hash of a larger field name takes a little more time, but I don't think that's... And of course, there's the memory penalty. But I don't think that's a very significant penalty. But, well, you can always....
Manuel Lemos: You'll never know, there's always people that are obsessed with tminimal details. But that is quite interesting, yeah...
Gustavo Lopes: I think those people should try to use another implementation. As we know, there are faster implementations of PHP right now, if they're really concerned about performance.
Manuel Lemos: Yeah.
Gustavo Lopes: I mean, performance...
Manuel Lemos: Well, that would be another topic because people sometimes do not have that option. But for those that who can, maybe they should take that concern.
Gustavo Lopes: Yeah, I mean the main advantage of the optimization made in PHP 5.4 is that most of them are basically free. You don't have to do all the things to your codes.
Actually, this change to the objects was the most significant terms of impact in backwards compatibility but not for userland code. A lot of extensions had to be changed because of the optimization. The other ones have significantly less impacts in terms of extensions.
Manuel Lemos: Well, talking about the other ones, previously, before we started recording, you mentioned that there were like seven performance optimization, right, that went to the 5.4 version. Can you give a brief overview where those and how that may impact or not the way you write your PHP code?
Gustavo Lopes: I don't think these other have a lot of impact in the way you write PHP code. But basically, we have now some caching of functions and method calls. That is, we usually have to do a hash table lookup to determine, to find the implementation of a specific function or method.
But these are now generally cached, so it allows to save some hash table lookups. I don't know how much difference it makes in the real world but probably some loops, some small loop that takes a lot of time but that calls some function, may have some noticeable difference, I don't know.
The other changes are listed in an RFC in the PHP Wiki, under performance improvements, that's Engine Performance Improvements. And the people, they can read it here but they're basically empty hash table optimization. Basically, hash tables are used all over PHP. PHP has a data structure, basically a double-linked hash table that's used to store almost everything in the engine.
And this optimization defers the creation of the hash table buckets until there's actually something to store in the hash table and this saves both memory and also some CPU because the allocation of memory for the buckets itself implies some CPU time, implies finding basic PHP, manages the memory that's given to the extension, to the engine. And let's also say here that patch improves the speed of a benchmark, a very synthetic benchmark, from 4.31 sec to 4.06.
Manuel Lemos: Yeah.
Gustavo Lopes: And the other benchmark, something very noticeable. There's an optimization more difficult to explain - literal tables that...
Manuel Lemos: Well, I can see that probably those... The way those patches work, probably too technical. Maybe we can get to the point of that most people want to know, what is the gain? Is it memory? Is it performance? And do they need to change the way they write their code like in the the case of these ...
Gustavo Lopes: Yeah, for these other ones, I don't think that you can really optimize your code, take advantage of these. I mean, these are various intern strings... Basically, PHP now has a weak form of intern strings. Basically, all these strings, PHP doesn't actually allow sharing strings between several groups.
You may share the container of strings but the strings themselves are not shared. And this, sometimes, would cause the same string appears several times. This cause unnecessary memory consumption.
And basically, now the engine reserves a certain amount of memory to hold strings that are found during the compilation phase. Not strings that you generate but only strings that are found during the compilation phase in PHP is transforming the script.
Manuel Lemos: Constant strings.
Gustavo Lopes: Yeah. And these allows also some CPU savings because when you have intern strings, you can compare them using the simple pointer comparison instead of comparing them character by character, because you know that if they are equal, then they are also stored in the same place. I think this is one of the optimizations that allowed for a lower memory consumption in PHP 5.4.
Manuel Lemos: So do you have any information regarding how much is saved in general? Or does it depend a lot on what you do?
Gustavo Lopes: Yeah, it depends a lot on type of application, but generally, heavily object-oriented applications, all these optimizations considered are the ones that benefit the most. The benefits, I think, are especially important in terms of memory, the performance in terms of CPU.
There are several... if people can check the RFC page and having in mind that some of the optimizations are not considered here. Like I said, the objects fields and I don't remember the other one.
But all these... Yeah, the cache. In fact, the function point of cache. But here we see, at best, an improvement in the order of 10%, maybe 20%, in terms of the amount of request that can be served.
If that's important for you or not, well, depends on how many servers you have and of course, of the cost that it represents to you to acquire the PHP 5.4. I don't know, it's also something that depends a lot on the applications you have.
Manuel Lemos: Yeah. Well, I think most people will need to always evaluate whether first if they were trying to decide whether or not it's worth upgrading to PHP 5.4. Now, they have more information but there are some benefits regarding more efficient use of memory which eventually makes each spend less CPU to execute a regular PHP code.
Gustavo Lopes: Yeah.
Manuel Lemos: Of course, there are other factors that people want from there. Well, they need to make sure that the code will work well and then, new versions.
Gustavo Lopes: In my experience, the major problem in migrating to 5.4 is the elimination of call-time pass-by reference. Because that's sometimes not so easy to fix. There are other significant changes like changing the default encoding and default character set in HTMLEntities, HTMLSpecialChars. But those are very easy to fix. The elimination of call-time pass-by reference is a bit more problematic.
I mean, I think the best reason to upgrade to 5.4 is because you eventually have to.
Manuel Lemos: Right.
Gustavo Lopes: I mean, PHP 5.3 is still gonna have a lot of long lifetime. It still has a year and a half left. But, well, there are always many factors, but you eventually have to.
Manuel Lemos: Well, we don't know, I think it looked like at least four years for PHP developers to take more drastic measures to force the PHP community to upgrade from PHP 4 to PHP 5. And we don't know yet what is the intention regarding this.
Gustavo Lopes: Yeah, I think...
Manuel Lemos: For how long they will support these older versions.
Gustavo Lopes: Yeah, I think we usually see some surveys talking about the usage of PHP 4 and a version that has been dead for several years have a significant share. I think those statistics have limited value. I mean, it's more or less, you hear often that some dead blog still running PHP 4.
Manuel Lemos: Yeah.
Gustavo Lopes: I think what's more relevant is which, actually, versions have been targeted in recent frameworks. And eventually, if you look, almost everything is in 5.3 now.
Manuel Lemos: Right. I think it's more problematic for custom applications that have been developed many years ago and trying to test them if they will work on newer versions or not, it's probably tricky because sometimes they do not have tests that cover all the codes, if they have any tests at all.
And the developers are afraid to upgrade and see, to break in production, even though in development, it look like it would work. And especially, mission critical applications that deal with, for instance, money or people's lives, to see their codes break in production may be chaotic. And well, it's actually something that we discussed before here.
Gustavo Lopes: I don't think PHP is competing with COBOL and stuff like that in making application. I mean, it's also a gamble not to upgrade publicly accessible because those of 5.2, by now, it has a lot of known public remote vulnerabilities. So, people also has to evaluate the likelihood of being attacked and the damage that it causes.
Manuel Lemos: Yes. You also mentioned that in the previous episodes. Actually, any version before PHP 5.3.11 is vulnerable to that attack of the hash tables. Actually, that people that write in PHP see has arrays for the request variables. But we know that a lot of people are still waiting to be attacked to believe that they need upgrade.
But at least, we already mentioned that in the previous podcast, that if people did not upgrade, because they did not listen or they did not understand, at least I try to spread information.
The speculation about future variable type declaration support (32:24)
Manuel Lemos: But moving on with the podcast, I also want to comment briefly about another aspect that I commented in the article which is more speculation than actually something that can be predicted about the future of the PHP, eventually PHP 6, even pre-based on hypothetical Zend Engine 3 that would not only feature the byte code compilation but also a JIT compiler that would eventually compile Zend opcodes into native machine code that would eventually run faster.
Do you think that is something that we may see or not in the future? Actually, we already covered that in the previous podcast, but different people have different opinions. What do you think?
Gustavo Lopes: I think depending on how you see it, the future is here. I mean, HipHop now has a virtual machine with their own instructions. And actually, they also have the closest that thing that there is to a PHP compilation. And but, of course, there are also several problems that may make that not viable for most companies.
I mean, developing a new engine is something that ... That's a lot of work. If not just the engine itself, but because the engine is relatively coupled with the extension. It also would involve a lot of rewriting in those areas.
It simply not something that there's guaranteed manpower to do. So I think, if we're going to see a different engine implementation gaining market share, it's to be something from Facebook or something like that.
Manuel Lemos: Right. Just for those that are listening, to understand better what we are talking about, in the article I mentioned some what I call what would be something that would operate in the scope of the variable type optimizations on which I imagine that a future PHP version would allow developers to declare not only the names of the variables and their initial values but also their types.
And that would allow JIT compilers to do what is called type inference which is to figure which is the type of the variables. So they can use more optimized storage for those variables in the native machine code and eventually make the code faster.
Well, obviously, this is just a speculation. It is not based on something that I know that Zend will do, because we don't know even if Zend has resources, as you mentioned. I think, well, I'm not sure.
I know that there is Dmitry Stogov that worked on on a lot of those optimizations that you mentioned. But other than Dmitry, I don't know if they have many other developers working on these lower level things related with PHP engine.
And I understand what you're saying, that it's probably easier to adopt a Facebook HipHop Compiler than actually expect that Zend developed Zend Engine 3. I can understand that it's probably not only expensive, because it requires dedicated developers to do it. But also, it will take a lot of time.
And obviously, I understand your suggestion that it would be easier to adopt a Facebook HipHop compiler. But well, we'll see what the future will...
Gustavo Lopes: I mean, you can already declare the types et cetera. I mean, you can use PHPDoc for that, but...
Manuel Lemos: Well, the idea... I understand what you mean, use the documentation to infer the types. But I think what I have in mind is probably something that would simply typecast the values when you actually declare.
Like this value, if you declare it to be of some type, it will never change the value type to something else. And any assignments of that value to the variable without declaring type would always incur in typecast. Or maybe an exception, in case it does not make sense to typecast it.
But this is all in my imagination. I'm not even the person that is considering to mess with the PHP engine. It was sort of a proposal or a speculation depending on how you see it. Well, I agree with you. It's probably easier to adopt Facebook which is also the main conclusion I get from this.
Gustavo Lopes: Well, I think that we don't even have to... Those type of considerations, I don't think they're even relevant at this point where we have a Web. And Web... It's certainly never going to be a consensus in the foreseeable time for some type of type coercion of variables and fields or wherever.
I don't think that we even have to get to the merits on that case because there are so many other considerations that had to be taken into account before...
Manuel Lemos: Right. Well, I was not really holding any hopes that this happens. But the suggestions still stands. Maybe, we'll see a different future for PHP on which there will be a closer cooperation between the Facebook developers and the work on the HipHop compiler and...
Gustavo Lopes: Yeah, right now, I don't really see Facebook interested in actually promoting the implementation for awhile. I don't know if you've used it. I mean, you have to use a patch library. And only runs in AMD 64, I mean only Linux... I mean, they don't really have at this time motivation making it user-friendly or anything like that. That would be something necessary for a wide...
Manuel Lemos: Yes, I see what you mean. Eventually, it would need more work to make it usable in all platforms the PHP supports. Basically, all these to say that these things are much more complicated than that. But let's just leave the suggestion the way it is and we'll see whether or not maybe in a more distant future, something like this that will ever happen or not.
New Feature Announcements on the PHPClasses site 13th birthday (40:49)
Manuel Lemos: OK, but moving on with our podcast. Now, I want to just mention not extensively, but just mention that today, coincidentally, it happens to be the 13th anniversary of the PHP Classes site.
For those that are not familiar to the site, I created that on 1999. Precisely on June 24th it was launched, the first public release. And the idea was to do most what it does today. It was simpler in the early days. It would just allows to publish classes, objects that allow people to reuse code developed by others.
So there is this benefit of reusing code from a broader community. Fortunately, this site has grown a lot and many, many things have been added on top of this platform. And nowadays, the site practically reached 1.1 million registered users and it has over 3,300 contributing developers. Some are no longer active in the site but their work was submitted there and still available and everybody can benefit.
And I just want to take this opportunity just to mention few features that have been working on the latest times. There was one feature that was released like a few months ago but I didn't mention much about it because it's not fully done. Which is basically the possibility to log in the site using your Facebook or Google or Microsoft account. So you don't have to go through the process of validating your email address.
And this is one feature that was sort of asking to be implemented for many years, because the registration in the site is bureaucratic. A lot of people do not like it. And the reason why I did not mention it yet in any blog post, or even podcast, is that I still want to support the possibility for people to log in with their Twitter accounts, as well as Yahoo! accounts.
But since those use OAuth 1.0 version, and for now, the site only supports OAuth 2.0, those authentication providers are not yet supported. But they will be soon because that goes in line with more recently implemented feature which is basically the possibility to integrate your PHP classes account with social networks.
So when new interesting components are published in the site that are considered notable, that is one thing that may happen for users that want to help spreading the good content that is published in the site, the site will be able to integrate with, initially, just Facebook - but will also support Twitter later - and have posts submitted to their timelines, timeline, actually, in the case of Facebook, so they can help spread about the god contents, not only packages, but also interesting blog posts and also the actual activity of the users.
So all you need to do is to go in this page that I'm showing here which will be linked from the options page that shows the list of social networks to which you have your account linked. And in this case, I already have here linked my Facebook account, so whenever there are interesting notifications about new content, those notifications will be posted in my timeline.
And below, there are some options that allow you to control which content you allow to be published in your timeline or not. In general, I recommend that people leave all these options set because the more interesting content is posted in your timeline, the more users will eventually check into the site to benefit from this content.
There is also a small detail regarding the initiative of the Friends of the Site, which is basically, an initiative that gives credit to users that bring more new subscribers to the site. And in this case, when content is posted in the social networks using this integration that I just mentioned, you will be credited for any users that you bring and you can raise into Friends of the Site ranking.
All this was already mentioned, about the Friends of the Site was already mentioned in previous episodes and blog posts. But I will mention again in a blog post, that by now, it has not yet published. I have plan to publish later today. But when you watch this podcast, it will be already available.
And this is just to mention few things that have done recently in the site. As you may see, all this is to increase the community, the size of the community that uses, that benefit from the site and also contribute to the site and eventually will make the site better.
But other than that, I have also other features, very interesting features, to implement specifically this year. One of them, I would not like to comment much about it in detail because between now and then, things may change.
But very briefly, I can say that the main idea is to give more exposure, give more evidence to users that contribute more, not only by sending classes but providing all types of interactions that can make the site better.
Basically, what I plan... Actually, it is planned. It's just waiting to be implemented right after I finish this integration with social networks. There will be a sort of a privileges system that will give more privileges inside the site to users that somehow contribute more in many aspects.
That is all that I am going to say about this for now, because there are several things that are not yet fully defined. But I will get back to that in the future episodes.
And for now, I just recommend that if you want to know more about this, just go and read the blog post article that will be published already by the time that you'll be listening to this podcast.
Manuel Lemos: So now, moving on with our podcast. We are going to move to one of the final sections of the podcast on which we comment on the latest classes published, first, in JS Classes site.
Recently, as I mentioned also in this podcast, there was this initiative to encourage more users to send more components to the JS Classes site. So we can start also the Innovation Award in the JS Classes site.
But for now, we'll just comment on some of latest components. Gustavo, can you start mentioning some of the latest components that you thought would be interesting to comment on?
Gustavo Lopes: Sure. First, let me just... Like I told you, I'm not exactly a regular user of these sites.
Manuel Lemos: OK.
Gustavo Lopes: But a few things that would be interesting would be some sort of package, some sort of integration with package management. Like some people can easily install this component obviously using PEAR or Composer. I think that's...
Manuel Lemos: OK, we're going first to start by JS Classes.
Gustavo Lopes: Yeah, sure. That wouldn't apply to JS Classes, yeah.
Yeah, I would think here, the bzChess... Let me just... The bzChess is a component that allows to show, to design chessboard representation using several standard, several ways of...
Manuel Lemos: Can you share the window? Can you share the browser window to show the class?
Gustavo Lopes: In there? Oh, sorry, I though that I... I'm clicking screenshots but it's not exactly working.
Manuel Lemos: OK, let me try to share here.
Gustavo Lopes: Yeah, instead of... Because...
I'm clicking here but nothing's happening. So I thought...
Manuel Lemos: It's Murphy's Law.
Gustavo Lopes: Yeah. I thought it was... The first time I clicked show esktop and I thought it was working, but then, you told me it wasn't. So yeah, that's a glitch.
Manuel Lemos: Yeah, this one is the bzChess from Gábor Martini from Hungary.
Gustavo Lopes: From Hungary, yeah. And well, of course, the audience here is limited to sites about chess. Maybe some of those newspapers with chess puzzles. But I think it's an interesting component.
Manuel Lemos: Yeah, this one, let me see if I can give you more details. Basically, what it does is to just show the board of a chess game. And it also manages the positions of the pieces of each turn that each player does to move in the game. I think it is interesting. I think the only thing it does not do is to actually play for one of the players.
Gustavo Lopes: Yeah.
Manuel Lemos: So you could...
Gustavo Lopes: Yeah, it has no...No AI, yeah.
Manuel Lemos: Right.
Gustavo Lopes: It's going to be outside the scope.
Manuel Lemos: It could be difficult but I think it's still useful.
OK, other than that, any other class?
Gustavo Lopes: Yeah, the other one is a...
Manuel Lemos: You find more interesting.
Gustavo Lopes: Yeah, the other one is a rather more simple component. Country Flag, which basically is from Dixan Santiesteban from Cuba. And basically, it's an image with several flags and the way to convert to other country names to a certain flag by using CSS codes to show correct flag in the sprite.
Manuel Lemos: Right. It uses what they call CSS sprites which, as you mentioned, is basically a set of images contained in a single image and it just changes the position of the rectangle that it will clip from the whole sprite to show the right part of the image, in this case are flags of countries.
Although this is a very simple object, I think it may be useful for many sites including the PHP Classes and JS Classes that need to show flags of countries, as you may see here. So despite being simple, kudos to Dixon for his contribution.
And one of those that I wanted to comment first is one from Hensel Hartmann, a regular contributor of both JS Classes and PHP Classes site. He's from Switzerland. Basically, what this component does is to position elements of the page automatically in a way that is relative either to the other elements or actually the whole page.
For instance, if you have a page and you scroll the page you want to make certain page element always visible, you can make it stick to a relative position of the page, could be the center, could be on edge, and it will follow even if you move the page or resize the page.
And it can do also relatively to other page elements. It is not exactly trivial implementation but you can see its uses. So, kudos to Hensel for yet another great contribution.
And talking about great contributions, I also would like to mention one that is really awesome. Let you see where I have opened it, or not. I think I did not open it.
But this one, Titanium Gestures, basically this is a follow-up class of another class also published by Arturs Sosins. Arturs Sosins, needless to say, for those that have been listening to previous episodes and following the site, he is the top contributor of the site with many, many very good objects.
And this time, he contributed with an object that is now adapted to work with the Titanium framework. For those not familiar with Titanium, it's basically a framework that allows you to develop applications for mobile devices. And these devices, can be either Android or iOS or Windows Mobile based.
And in this case, what this component does, it's the same of another component that he already published, also named Gestures, but the previous component was meant to work on Web pages and was meant to detect shapes that the user was drawing on the screen using the mouse pointer.
But in this case, the object Titanium Gestures is meant to work with touch events on the screen of the device . So it can detect shapes that the user is drawing. For instance, you can make it detect squares, or rectangles or other shapes.
And if the user draws those shapes with the mouse pointer, he will be able to actually detect those pointers regardless if you draw those shapes in a small area or in a larger area. The component is quite bright in detecting these shapes. And kudos again to Arturs Sosins for yet another good contribution.
There are many, many more contributions to talk about, not only from Arturs but from other developers these month, but unfortunately we don't have time. Actually, we would just want to comment on a few components.
Winners of the PHP Programming Innovation Award of April 2012 (58:43)
Manuel Lemos: But the main components that we want to comment this month, as in previous months, are components that were nominated to the PHP Innovation Award in this last regular section of the podcast.
This time we are going to comment on the winners, the nominees and winners, of classes that were published in April. So they were nominated in May, and users have been voting for them. And lately, in early June, the results were announced and the winners were listed here in the Winners' page.
Gustavo, can you start by mentioning a couple of those six that you thought would be more interesting to comment about?
Gustavo Lopes: Yeah, sure. Let me just open the page here. Now the button has started to work again, so I'm going to give it a try.
Manuel Lemos: OK. Go and figure.
Gustavo Lopes: OK.
Manuel Lemos: You're on the Winners, right?
Gustavo Lopes: Yeah. Well, I'd mention the first one, APK Parser. It is from Tufan Baris from Turkey. And it's basically an application that can dump some information about APK files which is a package format used in Android.
And of course, the interest here is basically limited to sites that provides files. Possibly, some repository and you want to show some details about the file before someone downloads it. But I think it's well suited for that niche, basically.
Manuel Lemos: Yeah.
Gustavo Lopes: But basically, I find it interesting because my involvement with PHP basically started also via a repository and I wanted to show the details of large files and how to access it and its contents. And this is basically also a similar task where you want to show details about the archives you have for your visitors.
Manuel Lemos: But I think APK files are in fact zip files, right?
Gustavo Lopes: I'm not sure but probably.
Manuel Lemos: Yeah. I think...
Gustavo Lopes: Debian format is gzip tars, I'm not sure if this is zip. But jar files are zip files.
Manuel Lemos: Oh, I see.
Gustavo Lopes: I'm not sure, but possibly.
Manuel Lemos: PHP file is also tar gzip or...
Gustavo Lopes: Well, it supports several compression methods. It supports both of those, yes. It's supposed to support bzips. So basically, it's mostly zip, bzip and yeah, gzip.
Manuel Lemos: Yeah, that's probably more relevant than APK for PHP developers. But OK, moving on, what other class would you like to mention, to comment about?
Gustavo Lopes: Yeah, the other I'd mention would be CSS Fix from Arturs Sosins from Latvia. And it's basically a component that converts some standard CSS... How do you call them? The CSS...
Manuel Lemos: Definition or style sheet.
Gustavo Lopes: Yeah, they have this specific name but I can't remember it now. Basically, the last part of the column.
Manuel Lemos: Oh, the properties.
Gustavo Lopes: Yeah, the properties. Yes. Basically, some browsers support or prefixed properties before they are standardized. And what this extension allows is to convert some properties to other browser specific properties that have sites. And I think this can be useful to build a more inter-operable Web site.
Manuel Lemos: Right. This tries to solve that problem, as you mentioned. There are some certain properties that are not standardized yet, but certain browser developers implement them on their browsers. But each one...
Gustavo Lopes: Yeah, the general advice given is that you should, when you use the prefixed properties, you should also use them unprefixed in case they're standardized in the future. But that has its problems. Maybe, it's never standardized. Maybe, standardized with slightly different semantics. So I think this could be useful in some context.
Manuel Lemos: I think I can see the purpose of that. At least for awhile, while those properties are not widely adopted in newer versions of the browsers, I think this class makes sense to adapt your CSS style sheet without being concern much about your browser, the current browser that the user is running on.
OK then, on my part, I also would like to comment on a couple of interesting classes. I would like to start first with this Image Embedder class by Karl Holz. Basically, what it does best is to take an HTML page that, let's say, eventually has images.
Usually, there are URLs pointing to the images that are in a remote servers. But if for some reason, you need to download that page and include the images in a single file, there is this possibility to use data URLs in the place of remote HTTP or whatever is used to reference those images in the remote servers.
So, the image gets embedded as the same file as the HTML. And this can be useful for viewing HTML pages offline without having the problem not seeing the actual images that may be needed. And so, this seems to be a great idea and kudos to Karl Holz from Canada for sharing a solution to this problem.
Another class that I wanted also to mention is... And some people may say, "Oh no, yet another CAPTCHA class. Why is this one nominated for the Innovation Award?"
Well, actually, this class written by Nguyen Duc Thuan from Vietnam, what it does basically is to change the usual way that CAPTCHA challenges are presented. Usually, you just see an image and you have to determine what is the text on the image.
In this case, this CAPTCHA solution is a bit different because not only does it challenge the user to determine what is the text or the information that is on the image, but also connect it to one of several probable, possible solutions that respond to the challenge. And this is somewhat different than the usual CAPTCHA solutions. Although by now, most people may have adapted one or another CAPTCHA solutions.
They may also want to consider this CAPTCHA object from Nguyen to provide eventually more robust CAPTCHA in their sites that are probably harder to break. We all know that CAPTCHAs eventually are breakable, so it's a matter of how hard and how difficult it can be to actually break the CAPTCHA that is presented to the user.
Well, there were a couple of classes nominated this month. One by Marcus Brasizza, Simple Complex Type Builder and another named PHP Dialog from Michele Brodoloni. But unfortunately, we do not have more time.
Manuel Lemos: I just like to thank Gustavo for his presence this time. I know he's in a hurry to watch the Euro Soccer Cup games. And although, Portugal is not playing today, Portugal is already qualified for the semi-finals. We don't know if Portugal will make it. We are...
Gustavo Lopes: That's doubtful.
Manuel Lemos: Maybe we can get a pleasant surprise,I mean, us, Portuguese. But we don't know. By now, Portugal did not play yet with Spain, so we don't know yet if Portugal will overcome that challenge.
But this is just to end this podcast on a positive hope note, I would like to thank Gustavo for his presence and for his insight regarding this very interesting topic related to PHP optimization.
And I think on my part, that is all for now. I don't know if you have some final remarks.
Gustavo Lopes: No. I'm happy to be here. And the best luck for your projects.
Manuel Lemos: OK, do you like to leave any comments, any information regarding your contacts in case somebody wants to ask you more details about anything that's...
Gustavo Lopes: Sure, they can send me an email or find me on EFnet. On...
Manuel Lemos: On IRC?
Gustavo Lopes: Yeah, on IRC. If they search for my name, my email is cataphract at php.net. My nickname in EFnet arise because of the eight-character limit and because cataphract has nine characters. But it's something like that. I'm usually in php.echo in EFnet. So yeah, they can reach me there.
Manuel Lemos: OK, so thank you again for your presence and that's all for now. Bye.
You need to be a registered user or login to post a comment
1,469,668 PHP developers registered to the PHP Classes site.
Be One of Us!
Login Immediately with your account on: