Author: Manuel Lemos
Viewers: 3
Last month viewers: 1
Categories: Lately in PHP Podcast, PHP community, PHP opinions
This was one of the main topics discussed by Manuel Lemos and Cesar Rodas on the episode 34 of the Lately in PHP podcast.
They also discussed about the latest PHP releases, updating PHP with minimized downtime, as well how brilliant are some developers for creating pure PHP components that overcome PHP limitations without upgrading to a newer PHP version.
Listen to the podcast, or watch the hangout video or read the transcript to learn more about these interesting PHP discussions.
Contents
Listen or download the podcast, RSS feed and subscribe in iTunes
Watch the podcast video, subscribe to the podcast YouTube channel
Read the podcast transcript
Introduction music Harbour used with explicit permission from the author Danilo Ercole, from Curitiba, Brazil
RSS 2.0 feed compliant with iTunes:
http://www.phpclasses.org/blog/category/podcast/post/latest.rss
In iTunes, use the Subscribe to Podcast... item of the Advanced menu, and then enter the URL above to subscribe to this podcast.
Watch the podcast video
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.
Show notes
- PHP 5.3.23 and PHP 5.4.13 releases
- PHP 5.5 feature freeze, beta 1 and beta 2
- Discussion on Updating PHP sites with minimized downtime
- Discussion on Justifying PHP feature request votes
- Article on How to Create a PHP feature proposal by Chris Jones
- Rejected proposal on Trailing comma in function arguments
- Article about 26 Ways to Show that PHP Can Be Better Than PHP
Read the podcast transcript
Contents
Introduction (0:20)
PHP 5.4.13 and PHP 5.3.23 releases (1:12)
PHP 5.5 feature freeze and beta releases (4:28)
Updating PHP sites with minimized downtime (9:36)
Justifying PHP feature request votes (13:16)
Implementing new PHP features without requiring a new PHP version (21:39)
Winners of the JavaScript Innovation Award of January (32:22)
Winners of the PHP Innovation Award of January (37:32)
PHP is powerful language and some PHP developers do wonders with it (53:21)
PHP Classes is a democratic site to get visibility and recognition to PHP developers (55:09)
Introduction (0:20)
Manuel Lemos: Welcome to the Lately in PHP podcast. This time, as usual, I have here Ernani. Oh, wait, it's not Ernani. Who are you? A guy with a long hair.
[Laughter]
Cesar Rodas: Yeah. Hello! I'm Cesar. Cesar Rodas.
Manuel Lemos: I know. I'm just making fun of you.
Hello, Cesar, how are you doing?
Cesar Rodas: I'm doing fine.
Manuel Lemos: Yeah, well, great to have you here on the show. This time, you are taking the place of Ernani Joppert. Unfortunately, he could not make it, he had a power outage. He could not record this time. But I'm sure he'll get back next show.
This show, we're going to talk about, as usual, several interesting topics, things that had been happening in the PHP world lately.
PHP 5.4.13 and PHP 5.3.23 releases (1:12)
Manuel Lemos: First, I think it would be better to start from the latest PHP releases. Let me screenshare things here. OK. There was the release of PHP 5.4.13. I'm trying to screenshare the right window. OK, I think you can read it more or less well.
Cesar Rodas: Yes, I can read it.
Manuel Lemos: Yeah, there was also PHP 5.3.23, which basically comes on par in terms of bug fixes. Mostly, there are just minor bugs. I think there are few security issues. Nothing that would affect a lot of people, I think.
But, well, everybody that is using this PHP versions should always take a look and see if there are no bugs that were fixed on this version so you can see if it would be worth upgrading.
Cesar, which version of PHP you use regularly?
Cesar Rodas: OK, let me check. In my computer, I use...
Manuel Lemos: You are not aware?
Cesar Rodas: No. I use the PHP 5.3.15. That is my what kind of... With my distro, I use OpenSUSE.
Manuel Lemos: OK, developement.
Cesar Rodas: Yeah. Also, I've got like three or four PHP installations. I have compiled it and I use it to run a couple of unit tests for two or three projects tat I have. But I'm not using it for development. I'm just using it to test it.
Manuel Lemos: Right. What about PHP 5.4 or even PHP 5.5?
Cesar Rodas: Yeah, let me...
Manuel Lemos: Are you using them or just for testing purposes?
Cesar Rodas: Let me tell exactly what versions I have installed here. OK, I need to... OK, so I have the 5.3.23. I have the 5.4.4, the 5.5.0 Alpha 1. Those three versions, I got to testings.
Manuel Lemos: But in production, you are not using those earlier, more recent versions, right?
Cesar Rodas: No, no, no. In production, in one of my servers, I use PHP 5.3.15, I believe. I have one Ubuntu server. And in the other VPS that I have, I have a very old PHP like 5.3.3, probably. It's something old.
PHP 5.5 feature freeze and beta releases (4:28)
Manuel Lemos: Well, another interesting release now that we are talking about PHP... I mean the more recent versions, there is also the release of PHP 5.5, the first beta versions.
First, it was announced that a feature freeze here in the internals list, which means that PHP 5.5 is now closed for new features and if anybody wants to propose any new features, he would have to wait for 5.6 or maybe later.
Cesar, what do you think about the new features of PHP 5.5? Is there anything that you find compelling to something that would be worth the upgrade or maybe not for now?
Cesar Rodas: I haven't played with it. However, I noticed that the unit tests, that they run a little bit faster in the 5.5.0 Alpha, which is the version that I have here.
Usually, because I'm working in a project which uses a lot of CPU power, like it computes a lot of things. For instance in version, with just 5.3.23, it takes like 24 seconds and in the 5.5, it takes like 20 seconds. And that is a huge, huge optimization of five seconds.
Manuel Lemos: Yeah. And what do you think is the reason for the improvememt?
Cesar Rodas: It's hard to say but I would say that they optimized a few things in the virtual machine, I guess. Because the code doesn't do anything. All of that do some mathematics with a couple of matrices, it's nothing fancy. And I don't...
Manuel Lemos: Are those regular scripts or you mean Web scripts? I mean, Web pages?
Cesar Rodas: So, it's an Open Source library that I wrote, that I would send to the PHP site soon. But it is available on my GitHub account which basically its for text categorization. I'm just... and that uses a lot of mathematics. So I don't do any IO. Basically, it's just pure mathematics. So that's why I was impressed by the performance and it gets better in every version. Like in the 5.4, it gets a little bit better and faster.
Manuel Lemos: Oh, I see. So the improvement was probably in the 5.4, when they changed that...
Cesar Rodas: Yes.
Manuel Lemos: Did that optimization of the properties. If you declare all the variables in the class that you used, the properties, I mean the variables are in a fixed arrays instead of a hash table. And that makes the access to variable much faster.
Well, we talked a bit about that. But OK, anyway, talking about the PHP 5.5, which is the newest release that is being launched, there were a couple of beta versions being released. Personally, I did not try them. I did not try them because I do not find anything compelling in these newer versions.
The greatest new thing would probably be to use that to Zend Optimizer+. I'm not sure if they are going to ship it with caching enabled, which is something that I was in doubt.
Well, anyway, there were already two beta versions. I'm not sure what would be the planned release time. I think it depends on how many bugs it still has. Once it gets minimal amount of bugs, they'll probably make a final release. I don't know if it'll probably a month or two more.
But they have been releasing a new beta version every two weeks more or less. Actually, that was the original plan. But between the 5.5 Beta 1 and Beta 2, there was only a difference of one week. Well, we'll have to wait a bit more and see when these new versions will be released.
Let me just, OK, do the screen sharing.
Updating PHP sites with minimized downtime (9:36)
Manuel Lemos: Well, next on this podcast, one thing that I planned to talk about is about a post by Rasmus Lerdorf, the original creator of PHP. He talks about continuous integration of atomic deploys.
Let me screen share the article. It's better to show than tell.
Well, basically, he's talking about when you deploy in the production with minimal downtime, which would be an ideal situation, but if you are running caching extension like APC and now, Zend Optimizer+, there may be a problem because if files are updated and PHP still sees the cached version, the update will not be seen. I mean, the old scripts will still be executed instead of the new ones.
Rasmus talks about a few problems about doing that with a minimal downtime. Well, I don't know what he's thinking regarding the upgrade. I think he's trying to just switch to a newer version, not having to restart the Web server. Because when you restart the Web server, if I'm not mistaken,the shared memory used by the APC is reset, right?
Cesar, what do you think?
Cesar Rodas: I think that's a clever idea. How I've done that in the past, it's very simple. Like we deploy everything into another folder and the current server directory is just a symbolic link. So we change that symbolic link to just have the lowest downtime possible.
And that seems to be working fine but all my experience are with small sites. Say less than two or three million hits per day, so that is not too much if you really want to test it live.
Manuel Lemos: Yeah.
Cesar Rodas: And that is the busiest site that I've worked with and we never have had any issues.
Manuel Lemos: Yeah, I think this problem that Rasmus is talking about is more on those very, very busy sites that they could not accept any downtime of any of the servers or else, they'll probably lose accesses.
Well, if I were you, I would play it safe and restart Web server to be faster because it would cause the caches to be flushed implicitly, I think. Well, that's just one doubt that I have. I think APC would flush the caches because the extension would have to be terminated.
Well, this is just one topic that's probably a bit advanced to discuss even in this podcast. We'll try to cover even the more complicated topics but I think it was worth talking about. But there is not really much more to say about it.
Cesar Rodas: Yeah.
Justifying PHP feature request votes (13:16)
Manuel Lemos: So let's move on to the next topic. I wanted to bring another topic that it's a bit, I would say probably polemic because it is related with the way PHP features are proposed and voted.
I think there was a great evolution when they started with the RFC process, because the features are being proposed and accepted or not.
There was guy named Sebastien Durand that posted an article, actually a proposal, in the PHP Internals List... that I'm trying to share on the screen here... on which he proposed that the voting form has an extra fields for the person that votes to justify his vote, be it yes or no.
Cesar, what do you think of this? Do you think this is necessary? Would it make the process of voting better somehow or maybe not?
Cesar Rodas: Well, I don't have much experience with how it works. As far as I saw, like someone propose something and people vote and all the fun happens in the mailing list.
I often read them, like if someone votes for no, they say why or they say why they don't like one particular idea but they say it into the mailing list. So later, if you are going to their Wiki site and if you want to see why somebody vote for no, you have no idea why that happened.
However, I saw a couple of interesting things like the new URI format, the traits and other features though they all happened through the wiki. That someone propose something and people just talk about it. They debate, they say why yes or why no and it finally happens. I think the process could be a little bit easier for mere mortals but I don't know.
What do you believe? Have you any experience with it?
Manuel Lemos: Well, I usually do not participate in voting or proposals. But from what I have seen, I think the idea proposed in this article of Sebastien Durand, I think it makes a lot of sense. And not so much because of those that participated on the debates about the new features, but precisely because of those that could not participate and sometimes they want get back and propose a similar feature, or even the same feature, probably revised somehow a different feature that was rejected, they don't know exactly why it was rejected by all. Because not all people that voted no justified their votes in the PHP Internals where most discussions on new features take place.
And I think this could be a very good idea to make the process more transparent because truth must be said, some people certainly voted against certain features not because of the features but because of the proponent.
For instance, if somebody does not like the proponent, they will probably vote no, just because they don't love each other. It happens in the real world. And anyway, this should be taken more seriously. There should not be space for people to vote on personal matters, but rather on technical questions, technical issues.
Why a certain feature was rejected, there must be technical justification for at least the votes that were 'no'. Because that the votes that were 'yes', the person that voted for the proposal already agrees, probably does not have much to add and they agree with the proposal.
But for the person that says 'no', he probably has very objections. Maybe, the person that submitted the proposal could come back with a better proposal that addresses those issues.
In this case, if none of the people that voted no are required to justify their votes, how can the person improve the proposal when probably he's not aware of all the objections that the people that voted 'no' may have?
Well, at least, that is my take on this. So, I think this proposal of Sebastian to improve the voting process would be helpful for PHP because if you can have better feedback on rejected features, it means that there'll be greater opportunities to improve the proposals.
Cesar Rodas: Exactly. So you can learn as if you have one idea and if you want to add that idea to PHP, why it was rejected and what you need to change or if you need to just give up and move to other things.
Manuel Lemos: Yes. Also, for people that come back later who were not aware that the features were already proposed, they could go back and use the justifications that would appear on the voting page to learn about issues that they're probably were not aware that justify the rejection.
Cesar Rodas: Yeah. I guess, if it should support some sort of commands like I already know and that's why I like something simple. It doesn't have to be...
Manuel Lemos: [Sneeze]
Cesar Rodas: Blessing. Salud.
[Laughter]
Cesar Rodas: So, yeah, I think that what you are saying is just right. Like if you can give a feedback, and why not? Even if you vote yes, you need to tell why. I mean that to be fair for both parties, whether you like or not.
Manuel Lemos: Yeah.
Cesar Rodas: I don't know how's the voting process, like who can vote but I can vote. I'm not sure. And I can vote because I submitted a PECL package, so I have the PHP account. But I don't know if anyone can vote or who can vote, I have no idea about that part.
Manuel Lemos: Yes, well, I think it is described. But I think, in your case, if you submitted a PECL package, you have a certain karma and I think you can vote. But you need to verify. That's an interesting question.
Cesar Rodas: OK, I will tell you that.
Manuel Lemos: I think it was Christopher Jones from Oracle that wrote an article regarding the whole process of proposing features and voting and stuff. Maybe, it would interesting for you to review, although he's not exactly a core developer.
Cesar Rodas: Yeah, I'll...
Manuel Lemos: But he's an important contributor because he's responsible now, not only for Oracle, but also for MySQL extension.
Cesar Rodas: OK, so, he's important, like PHP and MySQL, they always walk hand by hand.
[Laughter]
Manuel Lemos: Well, he's still an Oracle employee.
Cesar Rodas: Ah, yeah.
Manuel Lemos: And Oracle is not exactly the most popular company in the world. But that does not say anything about the person himself. That would be a different discussion.
Implementing new PHP features without requiring a new PHP version (21:39)
Manuel Lemos: Well, now moving on with the podcast, I would like to bring up an article that actually I wrote in the PHP Classes site.
Let me try to screen share it here. OK, let me go back, because... OK, I found the right page, just wanted to put it in the right... This sharing button is always a challenge to use. OK.
Well, this is an article that I wrote. Actually, I have been planning to write this article for quite a long time.
[Cough]
Manuel Lemos: Sorry, I've been swimming today and it's making cough a bit.
Well, the article talks about a set of classes that do something special. They were published in the PHP Classes site. I even presented here an interesting picture here of a man holding some weights. And because the weights are replaced by PHP logos.
And this article, basically, was meant to be a sort of tribute for talented PHP developers that developed some classes that are above the average. They submitted them to the PHP Classes site to get great exposure. And many of them were even nominated to the Innovation Award and they even got interesting prizes. They got great recognition for that.
But the reason why these classes were nominated is mainly because they do something different, which is basically to add features to PHP without having to upgrade your PHP version.
So they overcome limitations of PHP and add features that probably would make more sense to be implemented in the PHP core. But since they were not available... they require some additional development... they developed classes that implement those features and this was awesome.
I divided this into 26 categories for all sorts of purposes: Aspect Oriented Programming, Annotations, Protoypes... things that probably only exist on other languages but they tried to emulate them in PHP, things somehow that were surprising to me.
Many of them were published many years ago and I remember them because they did somewhat unexpected things to take PHP further to a level that probably nobody expected to be taken in using just pure PHP code.
And this is a sort of tribute to those developers that have developed those classes. The article explains what those classes do. I also mentioned the name and the country of authors of those classes because credit should be given.
And PHP Classes is mainly about that, to somehow give authors a space to expose their classes , to do something that goes far than what is expected, should even get even more exposure.
Cesar, did you look into this classes I mentioned in this article? What did you think about them?
Well, you are on mute. Are you on mute?
Cesar Rodas: Yeah, I'm sorry. Sorry.
I said that I implemented some similar classes because I wasn't aware of... Like two will be on... because this article, it didn't exist when I need them. So I wrote a annotation parser, something like the project which is described in the Class Generics. And so, I think those two classes are worth to mention. Everybody should know about them.
I used the annotations with my own library but anyone can use these libraries. And I'm particular, because I'm little bit obsessed with performance all the time. So I treat annotations in a special way like I would cache them and that's what everybody does. But I use them to some sort of inputs and I generate code, like equivalent code that does what I am describing.
Manuel Lemos: [Sneeze]
Cesar Rodas: Blessing.
Manuel Lemos: Sorry.
Cesar Rodas: No problem.
The thing with annotations and all these libraries is that they run into the user space and they use the CPU time to do something that was supposed to be done by the engine itself.
I don't fully understand why people love annotations. I love them because it lets me configure things and then, I can generate code out of that and do something efficiently.
But yes, so those classes are worth mention. And the Class Generics, if it does what I think it does, it let you define some sort of template and then, you can use that to generate code later. So that's fantastic!
You don't have to do complex things to generate codes. You treat your template as a Smarty template or Twig template or any template and you generate code. That's fantastic! That's why I do it. That's how I generate code.
Manuel Lemos: Yes.
There's even a category in the PHP Classes site for code generation classes. In this case of using generics, somehow what Java implements and in C++ they would be called templates.
There may be differences in implementation, but basically the concept of generating code from a template is there. It has its users. If you do not use it somehow you probably use some other solution.
Code generation solutions are very common and they address several problems. As you mentioned, it probably provide greater efficiency.
And other than that, one thing that I wanted to comment is that many of these classes were already mentioned in previous episodes of this podcast that we record every month.
And the idea is precisely to give additional recognition to authors that go further than what you could imagine and demonstrate that you can do more with the language, without being so dependent on the current version that you use. You can sometimes overcome limitations of the current version.
And another thing that I wanted to mention besides the fact that most of these classes were already nominated to the Innovation Award that we talk about every show here... we talked about the ones this month... is that I have a wish that one day, I could also write an article like this, but for JavaScript classes in the JS Classes site.
So this is also a sort of an invitation to all those that have developed interesting classes that probably exceed capabilities of the language in this case of JavaScript, then go ahead and submit them to the JS Classes site on which we also have a separate Innovation Award dedicated to JavaScript classes.
Cesar Rodas: And if I may say something?
Manuel Lemos: Yeah.
Cesar Rodas: If I may say something, I would say that actually in JavaScript, it is much easier to just play with the language itself because it's a much dynamic language.
You can create an object out of nothing. You don't need a class, you can put methods, you can do whatever you want. So there is a lot of room for innovation in JavaScript. I would even say that even more than in PHP.
Manuel Lemos: Yes, of course.
Cesar Rodas: I have to say that my primary language is PHP. I speak PHP fluently. I am just a JavaScript wanna-be developer and that's what I see.
Manuel Lemos: Yeah. That's true, that JavaScript is more powerful, I think, in terms of how far you can twist the language to do things like this. So I expect to have more classes like this appearing in the JSClasses site. So the message is given here to anybody that is listening to this show, to go to JS Classes site and submit interesting JavaScript classes that you have there.
Like yourself, I'm mainly a PHP programmer but I've developed other few JavaScript classes to do generic purposes. But so far, nothing that goes to exceed the capabilities of the language. But there already a few interesting classes there.
Winners of the JavaScript Innovation Award of January (32:22)
Manuel Lemos: And this ties precisely with the next topic which is to talk about the latest winners of the Innovation Award that happened in the JS Classes site. Let me just screen share here what are the latest winners.
Basically, first, we are going to talk about the winners that published their classes in January. They were voted on in February. Then, in March, there were the results of the votes.
So far, we don't have as many classes as in PHP Classes site but there are quite a few interesting nominated classes to talk about.
Cesar, which one of these five classes would you like to talk about?
Cesar Rodas: OK, I've chosen to talk about the GeoNames that was written by Tom... Schaefer.
Manuel Lemos: Schaefer, yes, I think.
Cesar Rodas: Yeah, I hope that I pronounced that close to how it should be pronounced. And he's from Germany. What it basically does, it...
Manuel Lemos: If you can share it, it would be interesting.
Cesar Rodas: OK, let me see how to do that. OK, let me, it might take a minute.
Manuel Lemos: It's always a challenge... screen sharing. Hitting the right window to share.
Cesar Rodas: Can you see something?
Manuel Lemos: Yes, if you can increase the font.
Cesar Rodas: Any better now?
Manuel Lemos: Yes, it's a bit better but it's blurred. Never mind, try to just continue.
Cesar Rodas: OK, I will open the sample page. It's loading. Basically, it let you define like you want to query a city, you put the coordinates and then, you get information all about what city it is. And that's a very interesting project. It relies in API which is open so that's an interesting property.
I was needing this kind of thing not a long time ago. It's from geonames.org. And the good thing about this class is that it provides me all that info and I can put it right into the front end so I don't need to bother my server to do a backend query. So it just works. That's fantastic.
Manuel Lemos: Yeah. That's true. That's a good point. There are, like in PHP, there are classes for accessing the Web service. But like you said, this one can access it directly without using an intermediate server to send the request. And it just send an AJAX request when it does.
Cesar Rodas: Yeah, I think.
Manuel Lemos: [Sneeze]
Cesar Rodas: Blessing.
Manuel Lemos: Sorry.
Cesar Rodas: What it does, it relies on the JSONP protocol. Like it creates some sort of a JavaScript and it will include it from what I saw, just a little bit, I know that much.
Manuel Lemos: Yes, that's true.
Well, on my part, I also would like to mention... Let me screenshare it here correctly and try to increase the font. But first, I need to hit the right button to share the screen.
Well, this class is basically a jQuery plugin by Jonathan Gotti from France. He has been a regular contributor of the site and he already sent several packages.
This one, what it does is basically to provide the thought of unified interface to handle touch events. So if you are using a device with a touch screen, it will handle those touch events. But if your device does not have a touch screen, you can emulate the same events, gestures and so on using mouse clicks.
So, this is an interesting solution by Jonathan Gotti. There were other classes nominated in that month, but unfortunately we do not have much time to talk about all of them.
If you are interested to learn more about these classes, we talk about them in Lately JavaScript podcast. We talk about all of them. And you can listen also to that podcast to learn about what we said about them.
Winners of the PHP Innovation Award of January (37:32)
Manuel Lemos: And now, we are going to move on to the next section which we comment on the Innovation Award winners of also January but in this case, it would be in PHP.
Cesar, which nominated classes woud you like to mention?
Cesar Rodas: OK, so I've selected two of them. They have something in common, I believe. This is the first one which is the Value Seek, which basically it implements some algorithm to perform the optimal search of values within binary search.
So you have, I guess, it will be some structure. I would guess that it's a sorted array of something and it will implement the binary search which basically just a tar of in the middle and just evaluate it if it should jump forward or backwards. And just keep doing that.
Manuel Lemos: Yes, that's a very interesting solution.
Cesar Rodas: Yeah, yeah. And the reason why I choose this, because this sort of algorithms, they are not very common in the PHP world. I haven't seen that many.
And the reason is because it has the primary as... They are categorized like academic things and I think they are quite useful and that's why I choose this.
And being implemented in PHP, that means PHP is not only for Web development and that's really cool.
Manuel Lemos: Yeah. Well, other than that, any other class you would like to mention?
Cesar Rodas: Yeah. I choose this one which is called bitvec, which basically it says that it manipulate arrays of bits with the SplFixedArray class which is part of the standard PHP library, which is a class or an object which looks like an regular hash in PHP but it has a fixed size.
So what is the advantage is that it will become and it will behave faster because it doesn't have to grow dynamically. And so, it is nice.
It was written by CPK Smithies, I believe. He's from the United Kingdom. So he uses these objects to manipulate bits. That is a common operation when you are doing some C low-level and you want to play with bits which are within a number.
So you can do shifting and all those operations, which can be done in PHP, by the way. But I believe, last time I checked, that was long time ago,it wasn't that efficient. So it was possible but wasn't that efficient. But that was long time ago. So I believe that this class should perform at some acceptable speed.
Manuel Lemos: Yeah.
Cesar Rodas: By the way, before I forgot, the first class that I selected, it was written by Chris Jeffries. I believe I'm pronouncing that right and he's from the United Kingdom.
Manuel Lemos: Oh, you have a sort of preference for developments from the United Kingdom developers.
Cesar Rodas: Yes. The thing is that I have to say that I'm a huge fan of Dr. Who, and that's why. So you can see here on my t-shirt.
Manuel Lemos: Ah!
Cesar Rodas: So that's probably why.
[Laughter]
Manuel Lemos: Oh, I thought you were going to say you were friend of Monty Python.
Cesar Rodas: That is true also but I can't say that.
Manuel Lemos: You don't like Python.
Cesar Rodas: Yeah, I can't say that in public because I dislike Python a little bit. Just a little.
[Laughter]
Manuel Lemos: Yeah. Well, I think it won't hurt if you like Python and PHP at the same time.
Cesar Rodas: Yeah, yeah. So when I was younger, I used Python to do a couple of GTK applications because that's also possible in PHP. That's true. But I always want to use the proper tool to solve a problem. So by that time, with Python, it was really simple. But if I want to write a Web site, I will automatically go for PHP. I will not go for Django or something else.
Manuel Lemos: Well, don't worry. It's not a sin. You would not go to hell if you have to develop in Python. I think.
Cesar Rodas: No.
[Laughter]
Manuel Lemos: I think. But I'm not the pope of PHP so I'm not the one to decide or if you're going to hell or not.
[Laughter]
Manuel Lemos: Maybe somebody from the PHP core will declare: if you like Python, I should go to hell.
Cesar Rodas: I don't believe so.
Manuel Lemos: Well, back to the actual podcast. Now, my turn to comment. I also would like to comment a couple of classes. Let me screen share here.
First, I would like to comment on the one that was actually the winner of January, right? It was from Majid Ramzani from Iran. I'm sure I'm not pronouncing the name properly. Majid, please excuse me for mispronunciation.
Anyway, what matters is that he did a class that makes it generic the problem that is called soft-deletion of the records.
That means that you can have records in a database table that you marked as deleted but you don't delete them. Because for some reason, you might want to keep the records forever, like to recover an eventual loss of information or to go back and figure something that may be duplicated. If you delete the records effectively, you would not be able to do those checks.
So one solution, and I admit I have a similar solution like this a lot which is to create a soft-deleted records which are basically record that have a special field in the table that tells whether the record was deleted or not.
And Majid implemented this class. And he also implemented the wrappers around basic INSERT, UPDATE, DELETE and SELECT functions considering that flag that mark the records as soft-deleted.
Cesar Rodas: Can I ask you something about a similar problem. But when you are done.
Manuel Lemos: No, no, you can't. You can't.
Cesar Rodas: OK. So...
Manuel Lemos: Just kidding.
[Laughter]
Cesar Rodas: So in the past, I had to solve the same problem and I was evaluating. And I realized and I decided I could be wrong, that's why I'm asking, that rather than having a different column and just adding a soft-delete there, that will require me to have an special index at query times. So wouldn't that be any better to move that record to a similar table? Wouldn't that be easier and faster?
Manuel Lemos: Well, eventually, it would probably be better. Actually, probably, the best solution is when you have tables that will eventually get many, many records. In that case, probably, that solution of moving to a separate table would be more efficient
But in the end, probably, if you need to look up, for instance, records that were marked as deleted by the application, but in reality, they were not deleted, you will need to do two queries to check the deleted records table and the other one. That's the only disadvantage that I see.
Cesar Rodas: But it varies. Another idea for a cool package, if someone can figure out how to fix that, I would definitely use that.
Manuel Lemos: Well, in this case, the solution was to, let's say, have this record marked, have this field that marks the record as deleted. And then, have wrappers that include additional clauses to the queries, mark them to consider records that were soft-deleted.
Cesar Rodas: OK, got it.
So, for instance, if you want to obtain the records that were not deleted, it would have to exclude those that were soft-deleted.
Cesar Rodas: OK, got it. Got it.
Manuel Lemos: Obviously, there may be some challenges, like for instance, if you want to, if you have like unique indexes and you cannot allow that a new record has the same fields for the unique index keys with the same values. Or else, you have that problem.
But in general, use this prevent that somebody adds a new record with some fields that have the same values. So in the end, that is not a problem.
Anyway, the other class that I wanted to mention. Let me screen share here. I left it for last for a specific reason, which is the fact that this class was actually mentioned in that article I talked about before about the classes that do better, then do things that PHP does not do.
Or at least this class does something that used to not be available at least in older PHP versions. But let me explain what this does.
Let's say that you are in a function and you need to do some cleanup. You can put all the code that does the cleanup at the end. For instance, you open an Internet connection, you want to close the Internet connection when the function exits.
So what this class does is to use destructor functions to run some cleanup code. For instance, in that case, if you want to close a connection that was opened with the function, you can register a sort of callback function that this class will call when the destructor is called.
And what is neat about this class by Ralf Mike Pretzlaw from Germany is that it will work regardless if you exited by a regular way, like every term statement but you reach the end of the function, or if there was some exception and the code was... it transported the control to some exception handler.
And this works because when you create a variable and assign it to an object inside a function, if that object was not written somehow to outside the function, the last reference to that object when that last reference is I would say eliminated, it will call the destructor of that function.
This is a bit abstract. I'm not sure if I'm explaining this in a way that is clear. But I think this is clever. And it somehow emulates what the final statement of the exceptions that I think it was introduced in PHP 5.4. Or was it 5.5? I think it's 5.5 now, that somehow, emulates the same behavior because the final statement makes the code that you put in the finally section of a try catch of an exception to always run regardless if there was an exception thrown or not.
So, it has some similarities and it was very nicely implemented. It's very simple class by Ralf. Kudos to him for this brilliant idea. Even if you can consider that it's somehow similar to what PHP 5.5 provides with the finally statement.
Cesar, do you think my explanation was clear? Or maybe not so much?
Cesar Rodas: Yes, your explanation was really clear. When you showed me that class, I couldn't believe how it was implemented in 20 lines of code. The code is deadly simple. So the code has values but what really has value is that idea.
Manuel Lemos: Yeah.
Cesar Rodas: So how he just put up together all these pieces. The thing is, the way how PHP works is that each variable has a counter. So when that counter reaches zero, it means that object can be deleted.
So when that happens, regardless if something fatal happened or anything, your destructor is always called. So you always have that callback. So you have the same behavior as what we have in PHP 5.5. So that's something amazing.
Manuel Lemos: Yeah.
Cesar Rodas: I have to say that class is just amazing. So kudos. Kudos.
Manuel Lemos: Yeah. And this is from Ralf Mike Pretzlaw that already contributed other good classes. Another one also emulates function overloading in PHP, which something that is also not quite trivial to implement in PHP. And it was somewhat inspired on what is done in other languages.
PHP is powerful language and some PHP developers can do wonders with it (53:21)
Manuel Lemos: Well, kudos to Ralf for his ideas. I hope he can continue to contribute awesome classes because these classes really demonstrate several things that I are important. One is that PHP as language is not that limited, as some people try to claim.
Cesar Rodas: No. Like if you start looking around, PHP could be even more dynamic than most programming languages out there. I believe that the magic functions are something amazing, like the __get or __set or __wakeup. Those are amazing. If you start looking around PHP, it's a very powerful language.
And you don't have to know C to do something cool. Like, if you know C, you can create extensions and you have no limits there. But from the PHP userland, you can build so many cool things.
Manuel Lemos: Right. And this speaks not only of the language but also the PHP developers. Because in many sites, forums like, for instance Quora, I mentioned it before, there are always people preaching that PHP is a bad language and PHP developers are not very qualified and this demonstrated that it is totally the opposite.
First, we are a lot. We are millions. And from those millions, there are less qualified developers but there are also brilliant developers that go far beyond what you could expect from a language.
Cesar Rodas: Exactly.
PHP Classes is a democratic site to get visibility and recognition to PHP developers (55:09)
Manuel Lemos: And other than that, I didn't want to put this explicitly, but once in a while, I see some people going on campaigns to criticize PHP Classes there is a code that is not very well-written and this and that.
But that's not a rule. That's a fact that derives from the circumstance that PHP Classes is a democratic site. So, people are free to contribute classes that probably not very sophisticated, are very simple, some of them are buggy, some of them even have security bugs or other issues.
But on the other side, there are classes that are extraordinary. And things like the Innovation Award that the PHP Classes organized in 2004 allows to highlight these classes.
Now that I mentioned that article about these 26 solutions that go far beyond what PHP can, I hope I can come back later and write other articles to talk about other solutions that go in the same lines that will exceed the capabilities of PHP.
Cesar Rodas: Excellent. And if I may say something, I started... We know each other from emails and chats for what... six, seven years? And when I started, I started to send simple classes to PHP Classes site.
And I was just learning, and if you look at the code that I write now and the code that I wrote seven years ago, there is a huge difference.
I didn't learn by magic. I didn't learn by going to college. I never finished my college. So I learned by open-source. And that what open-source is about. So you are free to contribute whatever you want as long you find them useful, it can even get one download, it doesn't matter. It's about sharing your knowledge and actually take somebody else's knowledge. And just do it and learn and improve yourself and share.
The fact that you published your code into GitHub or that you use Git or Subversion, that doesn't make you a better developer.
Manuel Lemos:Yeah.
Cesar Rodas: And even writing good program, like nice formatting using all the latest features that doesn't make a good developer. What makes you a good deliver is solving problems and that's it.
And many people, they've been just... I don't know too much about what you said earlier, but I'd been reading like you need to follow certain rules and certain things.
Manuel Lemos:Yeah.
I mean, you were born or we were born, we both we're born in free countries and we can do pretty much whatever we want. And if somebody reads what you do, if somebody downloads your package, that means that was useful, regardless of what other people may say.
And that's my kind of contribution. I use GitHub and that doesn't make me a super developer.
Manuel Lemos: Exactly.
Cesar Rodas: I'm not even close to it. I also use Gitorious, I use Subversion, I use PHP Classes. I put my code wherever I want and that's not going to make me a better or a worse developer. And those preconcepts, those are really, really annoying to me.
Manuel Lemos: Yeah.
Cesar Rodas: I don't know, what's the point of even doing such a thing? Why do you want attention? They should get attention providing software, just showing it wherever they want. That's my point. That's my...
Manuel Lemos: That's true. Just to put this in context. Many developers that submit their classes to PHPClasses, they import them from their repositories in GitHub because it's more practical. It's usually faster to import then publish those packages.
And what you are talking about was basically because there are some people that go and bother to make criticisms to PHP Classes, as if PHP Classes is responsible for the quality of the code that is submitted there.
This is a free site. This is yet another means to distribute your code. There is no way that any site that does not do any dictatorship-like moderation that can guarantee quality.
And even those that try to do that, they will leave out a lot of good contributions. Because it's a bit subjective. It's not easy to say this code is good, this code is bad. This code has bugs. This is the code that does it. No, nobody's perfect and your code may not be good but it can evolve and PHP Classes allows you to evolve.
And you don't have to host the development of your classes in PHP Classes. You can have those codes hosted in GitHub for instance or Google Code or even Microsoft CodePlex, why not? Well, you are free.
What matters is that you have freedom to express as a developer publishing the code the way you want. And only having that freedom is that you can be subject for instance of reviews of others, so you can evolve.
Some people do not like certain classes. Just go there and rate the class and say, "No, I didn't like this class." They are even allowed to justify their vote and say, "This code is not good for this and that." Or maybe do the opposite and say, "This code is good because of this and that". So the world evolves.
And what matters is that there is freedom for any developer to do that in PHP Classes. There is no dictator ruling this world.
Cesar Rodas: And if it's worth to mention, I've seen good codes in PHP Classes. I've seen bad codes in PHP Classes. I saw good code in GitHub, I saw horrible code in GitHub. I saw good code into, I don't know, into Composer, into PEAR, into PECL. So it doesn't matter...
Manuel Lemos: Everywhere, everywhere, because good and bad code is not an attribute of the repository where it is distributed.
Cesar Rodas: Exactly. Exactly.
Manuel Lemos: It is the characteristic of the developer. If the developer is not good, probably, he's not going to write good code. But if it is good, it doesn't matter where he publish this code.
And what we're talking about is that, once in a while, I hear some criticism from people that totally do not get the importance of freedom and the space that PHP Classes to the developers to publish their code here and to a wide audience.
If you want to publish your code and have a great exposure, the PHP Classes site offers not only the place to expose but also the audience. When you publish code in PHP Classes, that code is going to be visible right away to thousands of developers.
Cesar Rodas: Yeah.
Manuel Lemos: You do not have to on great lengths to do your own marketing because even if you can try to do that, it is not an easy thing to do. And PHP Classes exist exactly to give you that exposure.
I hope people will get the idea and the value there and continue to contribute great classes as the ones that we mentioned. All those that think PHP Classes is not good, well, they are always free to distribute their classes anywhere they want and the site will not be affected by any of the developer decisions.
After all, the site gives you all the freedom to publish the way you want. If you want to import your packages from Git repositories, you can. If you want to let people know about what are the URLs of the original repositories, you can. If you don't want to disclose that, you can.
If you want to allow people to download your package without requiring registration, you can. If you want to track the number of users that the package is asked by requiring the user to be registered to download, you can.
It's a place that provides authors freedom. And that is the main message that I wanted to pass with this comment.
Cesar Rodas: Great.
Conclusion (1:04:33)
Manuel Lemos: Well, with this comment, I think that is all for all this podcast. I would like to thank you, Cesar, for coming and helping to give your insights.
I hope you... And others, other developers, because everybody is invited to participate in this podcast. It's open. The site sends an invitation to those that want to participate.
You just need to follow the PHP Classes site on Google+ to get notifications when there will be a recording of the podcast. If you are to come on the show to give your opinion, give your suggestions as well as criticism, that would great. You'll be welcome to come here.
So on my behalf, that is all for now, Bye.
Cesar Rodas: Bye-bye.
[Music]
You need to be a registered user or login to post a comment
1,616,380 PHP developers registered to the PHP Classes site.
Be One of Us!
Login Immediately with your account on:
Comments:
No comments were submitted yet.