PHP Classes

How your PHP Programming Style Can Hurt Your Code Performance - Lately in PHP podcast episode 54

Recommend this page to a friend!
  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog How your PHP Programm...   Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  

Author:

Viewers: 65

Last month viewers: 15

Categories: Lately in PHP Podcast, PHP opinions, Sponsored

The recent article of Anthony Ferrara explaining how disabling garbage collection improved the performance of Composer exposed how certain programming styles can hurt PHP code performance. That was one of the main topics discussed by Manuel Lemos and Cesar Rodas in the episode 54 of the Lately in PHP podcast.

They also discussed proposed features for PHP 7 like built-in annotation support, Unicode character escaping, the removal of PHP 4 constructor style, among other related topics.

Now listen to the podcast, or watch the hangout video, or read the transcript to learn about the details of these interesting PHP discussions.




Loaded Article

Mandrill by MailchimpThis podcast episode is sponsored by Mandrill. Mandrill is a scalable, reliable, and secure email infrastructure service from the folks at MailChimp.

Thanks to Mandrill PHP Classes users can send 50.000 emails for free during the first 6 months using Mandrill. Just sign-up to Mandrill service and enter the promo code phpclasses to benefit from this promotion for PHP Classes users.

This post is sponsored via Syndicate Ads. If your company wants to sponsor a blog article or podcast on the PHP Classes site, please go to Syndicate Ads site to learn more about the sponsorship opportunities

Contents

Introduction (0:20)

Mandrill by Mailchimp promotion for PHP Classes users (1:03)

Why Mailchimp uses PHP? (6:25)

PHP Classes Newsletters Saves Lives: Just Jeremy testified (11:06)

PHP 5.4.35 and 5.5.19, PHP 5.6.3 released (13:32)

RFC: Removing PHP 4 constructors in PHP 7 (15:44)

RFC: Default Constructors (19:30)

RFC: Unicode Escape Syntax (20:36)

PHP 7 to be built on Zend Engine 3 (23:44)

Vote: Return type hinting in PHP 7 Approved but canceled... (26:09)

Vote: PHP 7 Timeline Approved (31:40)

Annotations Strike Back in PHP 7 (34:19)

How Garbage Collection Can Kill PHP Performance (39:25)

Javascript Innovation Award Winners of September of 2014 (54:23)

JavaScript Innovation Award Rankings of 2014 (38:35)

PHP Innovation Award Winners of September 2014 (1:01:07)

PHP Innovation Award Rankings of 2014 (1:06:35)

Conclusion (1:09:14)


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


Click on the Play button to listen now.


Download Size: 58MB Listeners: 1703

Introduction music Harbour used with explicit permission from the author Danilo Ercole, from Curitiba, Brazil

View Podcast in iTunes

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

  • Mandrill by Mailchimp promotion for PHP Classes users, use promo code phpclasses

Introduction (0:20)

[Music]

Manuel Lemos: Hello. Welcome to the Lately in PHP podcast. This is episode 54. This time, I have here with me the great Cesar Rodas that returned from a long journey to somewhere. He was making money, I guess. Hello, Cesar, how are you doing?

Cesar Rodas: Hello. It's good to be back.

Manuel Lemos: Yeah, that's great because you always have good insights about the PHP Internals. Today, we have lots of PHP Internals matters to talk about, as usual.

Mandrill by Mailchimp promotion for PHP Classes users (1:03)

Manuel Lemos: But first, let me start to mention, this month, our hangout podcast is being sponsored by MailChimp, specifically by their product, Mandrill.

Let me share the screen here, so people can know more about this great product. OK, sharing the screen here.

Well, for those that are not familiar, Mandrill is a great product that was developed by MailChimp. I supposed a great part of PHP developers already know MailChimp that is being used to send messages to mailing lists and newsletters, manage the registrations and do all things without great complication.

Since some time ago, they have new product more targeted to developers which is called Mandrill. They have this product that is targeted for something... I don't know if everybody's familiar... which is called transaction emails.

For instance, if you need to send messages to your site users, for instance, password recovery messages, registration confirmation messages and reports and so, those are what are called the transaction emails.

MailChimp actually has this product called Mandrill that it targets, specifically, to help businesses to send transaction emails with great deliverability.

Deliverability is a concept that defines the chances that the users actually get the messages that are sent to, because you don't know some filtering is so heavy that many message sometimes do not get to the users.

MailChimp has this infrastructure around the world on which they can send emails very quickly, and they have a structure that can guarantee a high deliverability of your messages.

For instance, they have this possibility to setup SPF and DKIM DNS records, so when the messages are sent by MailChimp... actually Mandrill... they will be recognized as valid from being sent from your domain, not be confused with spam. This is when one of the several features that is very important to ensure the so called deliverability.

The good news for PHPClasses users... actually the Lately in PHP podcast hangout listeners... is that they are giving away a special discount, a promotion code. If they go on the Mandrill site, that I'm showing here, they can sign up and use the promo code phpclasses. Then, they can get 50,000 free transaction emails for the first six months. That's a lot, at least for sites that are not using huge volumes of email, which I think are the majority of the sites.

Cesar, did you know about this Mandrill service by MailChimp?

Cesar Rodas: I know about the company, mainly because our emails a long time ago... I don't remember why but I need it, and I was looking at the prices and they are way, way cheaper. I think the only cheaper way is if you do it yourself through Amazon, but that's a lot of time. I think, back then, I used MailChimp, so that was the best alternative by far. If I remember correctly, the time was 10%... No, ten times cheaper than Amazon. You said that was a lot.

Why Mailchimp uses PHP? (6:25)

Cesar Rodas: Their blog post, they wrote a very interesting post that why people think... Because it was built in PHP...

Manuel Lemos: Again, so this is the post right? It's already from 2010, but you told me about this. It's quite interesting. What were you going to say about it?

Cesar Rodas: It got mainstream in Twitter a couple of days ago, so I read it a couple of days ago, and I was fascinated because it's a huge service and it's built in PHP.

It mentioned that they got some interviews to hire people, and people they were saying that they cannot believe that it was built in PHP. So just to mention that fact that is written in... At least their web site is built with PHP. So just that fact.

[Laughter]

Manuel Lemos: The web site link from Google. Article says also do the mail deliveries and the mail bounces handling and tracking of message opening and... all the process is done in PHP, and they said actually they developed their own framework optimized for their purposes, and it's great.

Personally, I also have developed a mass mailing system that I needed to send the newsletter for PHPClasses nowadays. The site has reached practically 1.3 million registered users, but those that get the newsletters are over 400,000, and all that is done in PHP.

What they say here, and I totally agree, that the language does not matter so much because it's not the bottleneck. The bottleneck of these high performance, high volume operations is often the network because messages have to travel the network, but if you just view the messages in your local mail server, the actual mail server is what will take the lot of the task that there is more time.

Actually, the main message to many thousands of users... they actually mentioned 30 million users and it's already 2010... it's actually a lot, and it doesn't really matter if it's running through PHP or not, because, as I said, it's not the bottleneck.

It's great that they shared that with the world because as I mentioned there's a certain prejudice from people that do not like so much the PHP language because they prefer some other language from Ruby or Python or Java or .NET or something else.

They just try to badmouth PHP just because it's not their favorite language, but it's a language that has built many more sites and they are making lots of money using PHP. So what exactly are they complaining about, just because it's not their favorite language?

It was great that you mentioned it. I don't know if you want to compliment it with some other comments.

Cesar Rodas: Yeah.

Manuel Lemos: Well, if you don't have any other comments, that's fine. I just want to reinforce again, if you want to use Mandrill, you just use the PHPClasses promo code when you sign up to Mandrill, and you then can benefit from this promotion. So, I would like to thank Mandrill for their sponsorship.

PHP Classes Newsletters Saves Lives: Just Jeremy testified (11:06)

Manuel Lemos: Now, we are going to move on with our regular topics. First, I would like to mention something that is somewhat unusual, which is a message that I got from a user of PHPClasses site that calls himself just Jeremy.

He's actually from the United States, town in Buxton, North Dakota. He told me just a few weeks ago, telling me that the PHPClasses newsletters saved his life. And, "What? How come PHPClasses newsletters can save lives now?"

I thought actually it's probably a joke. Maybe somebody was struggling to unsubscribe from the newsletters, and that happens once in awhile. Sometimes, perhaps it's going to an address and they're not able to unsubscribe because they send emails with a different address. Maybe he was having some difficulty unsubscribing. "No, that was actually true." He even sent me some pictures of his heart condition.

I'm not sure if I got it right. That when he got newsletters from the PHPClasses site, his mobile phone just ring with different sound, and that's sort of kept him awake. I didn't fully got what happened, but it seems that it helped him to... He got over a heart attack or some heart condition that he had.

Well, OK, I'm glad that PHPClasses newsletter saved his life, and at least, in letter, that he is well now. That's one unexpected purpose of PHPClasses newsletters. That's great that, now, we are able to recognize a better purpose for the newsletter other than providing information that...

PHP 5.4.35 and 5.5.19, PHP 5.6.3 released (13:32)

Manuel Lemos: Given that, now, let's actually talk about PHP topics, starting from what is the latest versions here. So, as usual, we have several releases of PHP 5.4, 5.5 and 5.6. They are just mostly maintenance bug fixes. It's not a big deal. It's something that we always mention, that as usual, there were some bugs that were fixed. I do not see anything special. Cesar, did you noticed anything special on this latest release?

Cesar Rodas: I see mainly bug fixes like memory, like two internal, at least in 5.4 or 6, a few bugs...

Manuel Lemos: Yeah, I don't think they are really, really important.

Cesar Rodas: Yeah, it was having always the latest PHP branch you are using. I see particularly, I'm not using like... in the Postgres driver, I don't use Postgres, so that bug doesn't affect me. But it's always nice to have the latest version of PHP.

Manuel Lemos: Well, what I meant is not that bug fixes are not important, it's just that bug fixes are nothing unusual. Of course, bug fixes are important, that is... these features.

Cesar Rodas: Yeah. My point is that you shouldn't problems with those. Either you can fix it by just upgrading your PHP.

RFC: Removing PHP 4 constructors in PHP 7 (15:44)

Manuel Lemos: Yeah. OK, so given that let's move on to the next topic. We want to start talking about some of the latest proposals.

There was one proposal to remove PHP 4 constructors, at least the way they were expressed PHP 4. Then in PHP 5, there is a new alternative way to implement them. And say, they want to remove them. I'm not sure if this is really, really important to remove them, but I think they just want people to use just a single style of constructors. That's what I get from this.

Cesar Rodas: Yeah. Technically, they should implement it because it's really, really old stuff. But I'm looking at the description, and they say they want to do it because some developer has some mental, some unusual method that some people got used to this kind of constructors. They want to force them to re-learn something else. If there is any benefits, it will run fully fine, but change it just because they wanted to change it, I don't see any benefit.

However, they mentioned a few things, I don't remember if it was in this post or in other. If you are inside a namespace, which namespace will only run in PHP 5.3 and newer versions, of course, that it treats like methods with the same name as the class that it should be treated just like another method.

That could make sense, but I like things that work, always just things that work differently under some circumstances. That will make bug hunting a little bit more difficult, in my opinion.

Manuel Lemos: Yeah, but, well, this is just to force people that are using code that used to be comfortable with PHP 4 to move on. Anyway, if they were using namespaces, they're certainly using the PHP 5 style of constructors. I guess it won't be a big deal except for very old code that it would be incompatible with PHP 4.

OK, moving on...

Cesar Rodas: Yeah, particularly, I do have problems, and I create a method that has the same class name and that's a constructor, and I caught random behavior. That's my problem. You see this as harmless, but I don't know why somebody would like to do it, but it's harmless the more I see it.

Manuel Lemos: Well, in the worst case, some people will not bother to upgrade to PHP 7. They have too many classes to change the constructors and don't want to go through the trouble. But that's probably not the worst type of method that you need to do in your code to deal with this change. There are plans to make it deprecated for PHP 5.7, and then they'll remove it for PHP 7.

RFC: Default Constructors (19:30)

Manuel Lemos: So moving on, the next proposal they have here is about having default constructors. The idea is to, for instance, for parent classes that don't have constructors, if the parent::__construct(), it will do nothing. As before, it would probably throw an exception, right?

Cesar Rodas: It's a fatal error as you attempt to call in method that does not exist.

Manuel Lemos: Yeah, exactly. Well, this probably will silence some warnings, but I don't see much code that probably would benefit from this change. Maybe the proponent has a lot more code that would be affected by this directly.

RFC: Unicode Escape Syntax (20:36)

Manuel Lemos: So, moving on, the next topic is about another proposal to implement Unicode Codepoint Escape Syntax to represent Unicode characters in strings. The idea would be \u, then curly braces defining that code of the Unicode character that you want to insert there.

Well, I 'm not sure if this is meant for all PHP strings, or maybe strings for the Ustring class that they are planning to implement to support Unicode in PHP 7.

Cesar, did you follow this proposal? Do you think it is interesting or maybe it will find some issues?

Cesar Rodas: I don't... Practically, it will allow it to just use within any string and it will compile to... and so. That's the way I see it, so I'm reading really quick now.

Manuel Lemos: Actually, we mentioned in the last podcast...

Cesar Rodas: It doesn't say anything.

Manuel Lemos: Yeah, I think it is for arbitrary strings. I don't know, when you start to use sequences, it will insert the chars people entered the equivalent UTF-8 encoding of that character. I think that's the plan.

Cesar Rodas: It seems so. It seems so, but...

Manuel Lemos: It doesn't matter if you are using the extension on the code, the Ustring class, which is still a proposal by the way, and not really something that is approved, I think. This is to make the code more probably readable.

Even if you are viewing it in an editor that does not really support insertion of characters in UTF, you just use the escape sequence and it will be added in there, the character. I think it is probably useful for those that if you have a lot of ASCII strings, it will make the code as portable as possible.

PHP 7 to be built on Zend Engine 3 (23:44)

Manuel Lemos: OK, so moving on to the next proposal, which is not really a big proposal, just a major... I mean, a bug in the version of the Zend engine that is being used in PHP.

Actually PHP 7 branch profiling it and calling it Zend Engine 2 but there are many changes that are being proposed, so it would be interesting to just bump the version. It's not really a feature, just version numbe bumping. I don't know if it's that important.

Cesar, did you looked into this topic? Do you think it is... or there are somehow issues that are missing?

Cesar Rodas: I'm not following what is here on the version, however once Facebook announced the HHVM 3, their Facebook version will run as PHP does, like there is no pre-compilation process to generate C++, Zend, they made improvements on their virtual machine, I don't know which one are included, I even saw one experiment that they included, some JIT support which will generate internal code that will be executed directly over your CPU, thus improving the runtime of the language. I don't which improvements are there, but probably some of those, which is very exciting because having competition will lead PHP.

Manuel Lemos: Yeah. Well, for PHP 7, we have lots of great improvements that this is just a thing internal to the PHP implementation that is based on the Zend Engine. I guess it won't affect in any form the HHVM implementation of PHP, because it's not on top of Zend Engine, of course.

Vote: Return type hinting in PHP 7 Approved but canceled... (26:09)

Manuel Lemos: So the next topic, just a brief mention about a new proposal that was finally approved. I think there is nothing really surprising, but they were approved. But some people that expect it to, I'm sure they will be happy that it's finally affirmed that it will be part of PHP 7.

In this case, we are looking at the Return Type Declarations. It is like typehinting for declaring types of values that will be returned by the functions. So if your function return value that are not of the specified type, you can correct those errors and fix your code because you are probably having a bug. So, this will help certainly people to make more robust code, at least the way I think. What do you think, Cesar?

I think the idea is good, the same with the parameters. I heard once one conversation with the Internals on one of the conferences, and the reason why we have types in the parameter is because if you expect one object and send a string, then you would have an error at some point. They wanted to prevent that ahead of time.

If you expect an object foo that has certain methods, and you sent another type, then when you attempt to call those methods, you would end up having a fatal error. So they wanted to follow in the same principle, then type, say a certain object user of a type user, and if it return a animal, you would have problems outside. Those are problems that could be detected at compile time. So they are following that approach.

In my opinion, it should be optional. Say, as Perl has the mode strict, and JavaScript does have, so if you say I want to run this piece of code in mode strict, it should check all those things. And if you don't care, then you don't add it.

Manuel Lemos: Yeah, exactly. The point here...

Cesar Rodas: It should be optional.

Manuel Lemos: Right. I think people have many function calls that probably think, "Oh, checking the return type of how you make calls a certain overhead. So using that hurts your performance, you just can disable it because it's optional and that's the purpose of having this proposal the way it is done, not mandatory like we have in things like Java and strong typed languages.

Another proposal that was also approved was about...

Cesar Rodas: Yeah, sorry, the thing about this proposal seems that they voted because everything was working. The thing is you need to send a proposal with working code, and apparently it was working and then, they found a bug and they cancel it. So it does seem something that they did wrong, and then they fixed it and they will re-open for votes.

Manuel Lemos: Right. I was wondering if it is something that you could disable at runtime, or the typehinting... I mean, typechecking is always done as long as we have.

Cesar Rodas: Yeah, I think the checking is there if you define it. If you don't define it, it shouldn't check for anything. So at the end, it's optional.

Manuel Lemos: Right, what I was thinking maybe we could have enabled in development. I don't think then disable it in production, but in that phase, there has been option to implement that.

I don't know, I see people that want to do typechecking also do not want to have all the code running in error in production. Probably, expect it to throw an exception or whatever, then just have it running without affecting performance with the type declaration.

Vote: PHP 7 Timeline Approved (31:40)

Manuel Lemos: OK, as I was saying, now moving on to another proposal that was also approved. We mentioned it last month. It's the PHP 7 timeline. Basically, it states that the final release of PHP 7 to happen in mid-October.

Just there is a comment here, "Subject to Quality!" which means that they have to squeeze as much bugs as possible, that they know that exist. They probably are studying the past, but that's something that always happen. What they meant here is that they will probably delay this release if they find that there are so many bugs, I guess, by the time they reach this date.

At least that's the way I see it. Cesar, did you follow this discussion of the timeline?

Cesar Rodas: No, I did not. I was busy. I usually follow them. More importantly, when they release something, I fetch it, I run the tests on my computer, so I send reports if something is not working as expected. But I'm not following those discussions.

Manuel Lemos: No, there's not really much to say here. Just to confirm that there was a vote, and the proposal was approved for this timeline. It's always something that they will try to actually match that... proposal time. But I think it's feasible, actually.

Cesar Rodas: I hope so. It's for the benefit of the community. If they can keep at that pace, that would be amazing, indeed.

Manuel Lemos: Exactly. It's not something that... If there will be a delay, probably it's not a big deal.

Annotations Strike Back in PHP 7 (34:19)

Manuel Lemos: But OK, let's move on with the next topic. In this case, it's something that is not settled actually. They restarted a discussion about having built-in support for annotations in PHP 7.

There were several proposals before, several proposals for implementing annotations like... Well, there are many projects that are using their annotation support implemented in their own PHP code.

I'm not sure if it is that important to have it as a built-in feature in the language. But it seems something that those who are a big fan of annotations, they want to push it, they are trying to have it their way. I don't know if it is going to pass.

Cesar Rodas: Yeah.

Manuel Lemos: I don't know if it is even a feature that you need to have at runtime, I mean production code.

Cesar Rodas: I have a bunch of projects and I'm using a lot of annotations. I use pretty much whatever I can. But I have a different usage basically, because I wrote my compiler, so I have full control of how it does.

I don't use annotations at runtime, but rather I work through a set of files, I read annotations. I use annotations to generate some PHP code.

For instance, I have a class which will discover what methods should be treated as an action for some URL pattern, but I don't do that at runtime because all the benefits that I get is that I could read easily annotations. I say, "Hey, this is a method. OK, I will record this method. OK, in this path, I need to load it and call it when this URL happens."

But I don't see what is going to be the benefit if that class or method is not loaded into memory because the increment is not really a problem, from my point of view. It's a benefit is that PHP lets as you request. It's not a Web server.

One request comes in, that request is out and everything's gone, so it's a blessing actually because you don't have memory leaks or anything like that. If you do things wrong, that's where it would cleaned up, when your request is gone.

So I don't see any benefit really of having it at runtime. I know some people who claim there will be a lot of benefits for dependency injection. I don't know really, but more changes into the languages, it could be. But there are things that people propose things, but somebody has to do it.

Manuel Lemos: Right. Somebody has to do it, while it is not a big deal because people that are sending these proposals are so persistent that they probably would come up with the necessary code if one of these proposals would be approved.

Well, there is still a discussion going on. I'm not sure if it is implemented. Well, I think they discussed it for a while in beginning of November and then they stopped. Well, if there will be an implementation of annotations in PHP 7 or not, we don't know yet. Maybe they will come back to this subject later. We have to wait and see.

I think whoever is using annotations already built their own parsers, so there won't be a great benefit to have the feature built in. Probably to be faster but it's not the kind of thing that you would use at runtime, so it probably will make a difference in terms of the performance of real applications in production.

So let's wait and see if there will be yet another episode about the annotations in PHP soap opera.

How Garbage Collection Can Kill PHP Performance (39:25)

Manuel Lemos: Moving on to another topic, now, I would like to comment a very interesting article by Anthony Ferrara. Actually, he has been sending a quite interesting number of very good articles, very technical, very in depth, and thus it is relevant on how PHP works and how it could be better somehow.

This time, he commented about speed improvement that was implemented in the Composer tool. It's to install packages. I heard about this improvement, but I did not fully get what was the improvement. But in practice, it was that simple fix was basically to disable garbage collection.

For those that are not familiar with garbage collection, garbage collection is a process of freeing memory that is no longer used, probably because it was used by certain variables, and those variables are no longer used because they probably used this item for function and the function erased so the variables are no longer used.

The values that were stored in the variables were taking some memory, and it uses a process of reference counting to return a certain value used and no longer being used by any part of the code. The respective memory can be freed.

I am trying to interpret it. I hope I'm being accurate. I'm not fully sure because it... matter, but what I understood, what they mentioned here is that Composer tool has a lot of classes with objects, or references to other objects, or have variables that point to other objects of other classes.

It eventually would cause what is called circular references... reference objects that then reference back to original object. When this happens, there is a cyclical reference that prevents the memory of those objects to be freed, unless more...

The garbage collection process that is implemented in the package is circular references, so you don't get there in an infinite loop trying to figure circular references if they are already checked or not.

The problem is that all these processes takes time. You are checking certain reference if freed, and they were not freed every time you miss that garbage collection process, it will take some time. This will eventually start hurting the performance of your PHP code, because the garbage collection process runs periodically.

So, usually you run Composer, get some packages and exit. Freeing a memory of this object reference is probably will not be a great benefit to delete previous memory, because it released memory they used for other variables in the future.

But it seems that just disabling garbage collection it would cause great speed improvement. Actually, it was not great improvement. It is the reduction of something that was probably not necessary.

I don't know, this is my interpretation. Cesar, what is your interpretation of it?

Cesar Rodas: You gain performance, true, but you disable the garbage collection. That means that if you process it, it will consume more RAM. What the circular reference issue all about is that to release the memory of an object, they have to have the reference count to zero.

And they are not going to have two zero because they have one reference to one object that has just one reference, which is my object back. So they are both like they stay dependent on each other, but not in any external object.

So you should really design better software for starters, and then do not create a billion objects if you do not have to. That's a way better approach.

Manuel Lemos: Exactly.

Cesar Rodas: Yeah, because if you look at the blog post, they say the short answer is don't do it. You shouldn't do it. It makes sense, it makes a lot of sense.

Manuel Lemos: I think this so called speed improvement was more a shortcut to avoid spending time changing the programming style. Actually, I looked once at the Composer code and I can see there are reference to objects in variables, lots of them, and pass objects as parameters to functions. Then do something to tie them, to create more references to them.

The question is, is this really necessary? Or is it just a programming style that probably people got... maybe, maybe people are inspired by what they learn in college, probably Java. Java programming's type to show objects to everything. Everything's an object. Sometimes you do not need to have everything in object.

There is those principles they call SOLID. One of them is single responsibility, which means that one class is supposed to do one thing and one thing only. That leads to lots of lots of classes just to do one thing, one thing only.

Just because the Martin Fowler or whoever finds the SOLID principle said so does not mean you should follow that as a religion. It has consequences, and if you do not need as many classes as you have because you follow this single responsibility principle...

Cesar Rodas: Yeah, there is university and there's real life kind of thing.

Manuel Lemos: Go ahead.

Cesar Rodas: Yeah, I just said that there is the university and there is the real life. In real life, performance matters and matters a lot.

Manuel Lemos: Yes, well, sometimes, people to go to college... and it's great to go to college to learn programming or whatever... but sometimes they learn certain principles, but they do not have a good overview of the consequences. All these consequences of making objects for every little thing that... project has consequences.

In this case, it was not really, really the problem. The problem is not having many objects. The problem is having objects that references object. Many of those objects are inside of your application. There are consequences of... So this solution of the problem as Anthony mentioned was not really the one to disable garbage collection. It's just a shortcut for now. The solution is to rethink your programming style.

Personally, I apply to my PHP classes because I would be separating responsibilities and also using less classes, which you'll be creating less objects. It is to avoid the garbage collection process to go through many object references to check their reference counting. I think that is the main lesson that you're going to learn from it. The solution is not to disable garbage collection, it's to rethink your programming style.

At least that's my conclusion. I don't know if you agreed.

Cesar Rodas: Yeah, I think a shifting of how to think, how to solve problems, because a garbage collector is really good... everyone has it. I follow one simple rule, if Google does it, it's probably good. So Node.js. So it's really good. All the wise, you shouldn't never free memory and just wait until your program dies. That's probably what this whole optimization is all about. The most important thing is, in the Composer case, most of the slowness comes from the network.

I believe that they behave like Subversion, that they need a central server and they need to shift that thinking and start operating locally and just see the changes like deltas. I have these versions what this server have and things like that.

It should really improve to do less network operations, and that will be much faster than any improvement that you can do in terms of the language. Because PHP is fast, it just execute codes in the CPU, it'll be fast. But the network, that is slow always because it depends on many things.

Manuel Lemos: Yeah, right. Regarding this article, it mentions Composer, and I would like to mention something related. I guess, I already got that question a couple of times. Since PHPClasses supports installing packages from its own Composer repository, so it acts as a Composer repository, you can install packages and classes as the Composer repository, you can use Composer. And for people that do not know how to setup Composer configuration... shows how to implement the initial configuration.

All of it should be there, rather than just downloading the code... any package here that works. Practically, all packages can be installed, but it practically it would go to the download page and... and it is here.

It shows here a sample composer.json that you can use to use in your project. And there is this option, you can see at the end see these packagist: false.

What this means is that, since you are downloading just this package from this repository, it's different repository, you won't need any other packages. So you don't need to download packages from packagist, because if you download packages from packagist, you will need to download the whole repository definition. That takes a lot of time.

The process depends in... I mean, Composer is slow, and there are some people that say, "Oh, why, oh why, this is just including the old packagist?" Well, nothing against packagist as it is. ...so you can then disable and it will be faster.

So, I'll just have to make clear that nothing against packagist because some people say "Oh, packagist is a competitor repository... By all means, I'm not discouraging people to use packagist. If you need only one package, so no packages would be used from packagist...

Javascript Innovation Award Winners of September of 2014 (54:23)

Manuel Lemos: Now, it's time to talk about the Innovation Award of the JavaScript of 2014. We are going to start talking about the winners of September. Actually, this month, there are not many nominees as before. There were just three and all got tied with the same votes, so all of them won.

OK, let's talk about them. Arturs, please go ahead and talk about what you thought were the most interesting.

Arturs Sosins: Let me try to share it first.

The first one is Format.js class, developed by Pierre from France. What it does, it returns the date, format it according to your country's specifics. I'm interested in how he actually do it, because there is no general rule how he could generate it, and he just stores the formats for different countries and sites, so he has this information. If you need it, it's a handy class that extends the date object, then you can format the date to any specific country that you need.

Pierre got one downloadable e-book of choice by O'Reilly for this class.

The second one, is JS Webcam class... let me load it here... developed by Elger van Boxtel. What it does, it uses the API to retrieve pictures or video from your computer's webcam. Basically, it can retrieve binary data and then, display it for example in the Web site data URLs. It's also a really neat package.

Elger got one book of choice by Packt for this class.

Manuel Lemos: On my behalf, I would like to talk about the remaining one which is a package for a somewhat unusual purpose. I mean, unusual for most types of applications that you would find on the Web... JavaScript BIC Validator.

This BIC standard is a format for defining codes for containers that are transported with products around the world in ships or maybe trucks. This one is a package developed by Sameer Semna from India.

What it does, it validates the code because a BIC code has certain conventions. It can take the code, compute the check digit and verify if it was correctly formatted. It is an interesting package for people that, for some reason, need to deal with containers that are transported around the world.

For this award, Sameer picked a prize, which in this case was one year of Codenvy Developer hosted cloud IDE premium plan. I hope he's enjoying this cloud IDE.

For the Innovation Award of this month, we have talked about all winners.

JavaScript Innovation Award Rankings of 2014 (38:35)

Manuel Lemos: Now, let us see how is the ranking of the Innovation Award winners of 2014. Individually, Thomas Bjork from Sweden continues to lead with 4 packages and 15 points, followed by David Castillo 2 packages and 13 points, and now followed by Pierre FAUQUE with 3 packages and 12 points, then, Andoitz Jordan Marmolejo from Spain with 2 packages and 10 points, then, several others with one or more packages but less points.

By country, so far, France is leading now with 5 packages and 21 points, followed by Sweden 4 packages and 15 points, then Mexico 2 packages and 13 points, Spain 3 packages and 12 points, Italy with 3 packages and 9 points, Canada 3 packages and 7 points, India with 2 packages and 6 points. Then, there are several other countries with only one package and less points.

Unfortunately, this month, we have less nominees, so there are not so many people sending packages to participate in the award. Previously, I mentioned that JSClasses had a boost in traffic from Google because there are some recovery of some Google algorithms. But then, it dropped again for some reason that I am not sure what happened.

What happens is that, unfortunately, many new packages are sent by new users, and if the site gets less new users, it also gets less new packages. So let's see if in the future things recover.

Many sites are being affected by Google algorithm fluctuation, not just JSClasses and others. To a certain point, also PHPClasses, but PHPClasses is much more popular. Let's see if things improve in the future. Anyway, for now, I hope the current users keep sending great packages, so we can keep talking about them.

PHP Innovation Award Winners of September 2014 (1:01:07)

Manuel Lemos: Now, for the Innovation Award of the PHPClasses site, we have much more nominees for September. They were voted in October, and then in November, the results come out. So we are in December, so we can now already talk about them. So there are 12 nominees. It's a lot of packages.

Arturs, which ones would you like to comment?

Arturs Sosins: OK, let me share the screen again. There, it's shared. The first class I would like to comment is the PHP Multi Profiler Class by Jacob Fogg from the United States. Well, we've all done testing which function works better, which approach is faster. This class does exactly that. It can code the function multiple times and record the time how each class spent or how long it was creating object. So yeah, that's very useful.

Jacob got one subscription to the PDF edition of the PHP Architect magazine.

The second class I wanted to mention is the PHP Euler Circuit for Hamiltonian path. They differ only if you want to work through the graph either by unique nodes or unique edges. This class exactly does that. It works through it as far as that put only once and returns back to the same position.

This class was developed by Chi Hoang from France. As I remember, I think Chi submits lots of classes with geographical approaches. He got PhpStorm IDE for this class.

Manuel Lemos: On my behalf, I would like to also mention the other classes starting from this one... PHP Coins Change from Michele Andreoli from Italy. He's one of the Italian developers that has been helping Italy to move ahead, but we'll get there in a moment.

For now, talking about this class. It is interesting. It has sort of an unexpected purpose, but probably there are applications that would make good use of this. Imagine if you have a certain amount of coins of different values and you need to give change to a customer. So this class computes the number of coins that you should give to the customer to match the necessary change that you bring. It is an interesting package.

Michele so far did not pick his prize yet, because there are many packages this month to pick prizes, and the prize-picking took longer than usual, but eventually he will get to his turn.

Let me move on to the next package, which is this PHP i... It should be PHP i18n which means PHP internationalization.

This package is interesting because sometimes when you want to prepare your package, your application to... You need internalization, if you want to set it for users of different countries, you need to have the application text translated to different languages.

Sometimes, we did not plan it from the beginning so you have to extract the strings that are using your application from your existing code. This package just does that for you. You can't reverse your PHP code files and just extract the strings that need to be translated to internationalize your applications.

For this, Everton da Rosa from Brazil was nominated. He did not yet pick his prize. Probably, he just checked one thing because I think he was not sure if it was this month... not this month... but it will come his turn to pick his prize.

PHP Innovation Award Rankings of 2014 (1:06:35)

So in terms of Innovation Award nominees, that's all. Let's see how are the rankings of the Innovation Award of 2014, first by author. Chi Hoang is still leading with a great advance, with 8 packages and 42 points.

He is followed by Orazio Principe from Italy with 3 packages and 24 points, then Andoitz Jordan Marmolejo with 3 packages and 16 points, Rochak Chauhan from India with 2 packages and 14 points and tied with Everton da Rosa from Brazil with 2 packages and 14 points, and then followed by several other authors with one or two packages but less points.

By country, things are heating up. As I mentioned, before there was a certain adjustment because Patrick JL Laso is now representing Spain, as he was originally, while Chi Hoang keeps representing France as he has chosen to.

So far, Italy is ahead with 8 packages and 56 points, followed very closely by Iran with 6 packages with 54 points, France with 11 packages and 52 points, Brazil with 7 packages and 39 points, Spain with 7 packages and 38 points, and Unites States with 5 packages and 35 points, Russia with 3 packages and 23 points, India with 4 packages and 22 points, Germany with 3 packages and 16 points, and the United Kingdom with 14 points.

Things are heating up because, so far, we don't know which country is more likely to win because there are several countries that are very closed to each other, and things can change quite a bit. So far, this is considering the nominees of October, so we still have to see the nominees of November and December. The final results, we will know in February, but so far, the things are very, very interesting. We don't know yet who's going to win.

Conclusion (1:09:14)

Manuel Lemos: Anyway, we have practically reached the end of this podcast. Before I would like to thank MailChimp for their sponsorship. They have been nice to sponsor this podcast. I would also like to mention that if other companies would like to sponsor this podcast, posting blog and articles... that other companies that needs a sponsorship.

I'll put it in the Show Notes. I'm going to order... For instance, when you post an article to the PHPClasses blog over 400,000 users are notified of a new article, yeah. That's with somewhat...

Once again, thank you MailChimp for the sponsorship. I'm sure PHPClasses site users will appreciate promo code discount they are offering...

Other than that, I also would like to thank you again, Cesar for coming. I know you are very, very busy. It's kind of a miracle to get you here on the hangout. It's always good to have your insights, always about PHP.

And to all PHP developers, here we have Cesar Rodas, the one and only. The winner of the Innovation Award of the Year, a couple of years right?

Cesar Rodas: Yeah, it was couple of years. That means that next year, I need to submit more packages. I guess that we'll see each other next year, I guess, in the next podcast.

Manuel Lemos: Yeah, I hope you can come again. I'll certainly try to be there about one month. I'll be in Portugal. I'm going to spend New Year over there, and probably, I don't know if we'd make recording from there or not, but...

So thank you again for coming.

Cesar Rodas: OK. Anytime, you know, just let me know and I'll be here.

Manuel Lemos: OK, thank you again. Bye.

Cesar Rodas: Bye.

[Music]




You need to be a registered user or login to post a comment

Login Immediately with your account on:



Comments:

No comments were submitted yet.




  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog How your PHP Programm...   Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)