Possible PHP 5.6 Features

6 Sep

I originally wanted to write a quick round-up of all the discussions from the internals mailing list regarding PHP 5.6. That post was turning out to be rather long, so instead I’m going to focus in on a group of RFCs that are related to how PHP handles function parameters. It’s important to remember that these features have not been accepted into the language yet, so it’s entirely possible that they will not make the actual release of PHP 5.6.

Skipping Parameters

This is a straightforward feature that makes working with optional parameters a little easier. It allows passing the keyword “default”, when you aren’t going to specify your own value for the parameter. For example, if you have a function signature like this:

function foo($param, $param2=’a’, $param3=0, $param4=”) {…}

You can call it like this:

foo(‘value’, default, default, ‘another value’)

This essentially saves you from having to check the function signature and make sure that you are passing the correct default parameters, when you aren’t specifying them your self.  Discussion about this feature is ongoing, so there has been no vote on the RFC yet.

Named Parameters

Named parameters are a better approach to solving the same problems that the Skipping Parameters RFC addresses. It’s been discusses a number of times in the past, but was usually considered too difficult to implement, so the skipping parameters idea was a middle ground between implementation and functionality. However, Nikita Popov announced to the internals mailing list that he has a partial implementation of this feature and has posted an RFC for further discussion.

Named parameters work by letting you pass params to a function by their name, rather than by position. So given the function signature from my previous example:

function foo($param, $param2=’a’, $param3=0, $param4=”) {…}

You could call it like this:

foo(param => ‘value’, param4 => ‘another value’)

This has the advantage of looking a lot cleaner, you also don’t have to worry about the function signature changing later and then adding or removing default params so that your function call still works. Another great benefit is that the code is self documenting and easy to understand at a glance.

The final syntax for this is still up in the air, the RFC proposes several variations and there is also a discussion about this on the mailing list. I’m partial to foo(:param => ‘value’, :param2 => ‘value2′), which I think looks clean and consistent with the PHP language as a whole. That being said, the final syntax is not a huge concern to me, I’ll just be happy if this RFC is accepted into the language.

Variadic Functions

Variadic functions are functions that accept a variable number of arguments, this is a feature that is actually already supported by PHP via the func_get_args() function. This implementation is a little clunky and it’s also not always clear that a function is expecting a variable number of parameters, since the func_get_args() call can happen at any point in a function body.

This RFC would introduce a new syntax that makes it clear that the function is a variadic function:

function foo($param1, …$params) {}

If this function is called with more than one param, all the additionally parameters are stored in an array called $params. You can easily see that this function is variadic by the presence of the …$params syntax.

This RFC has not yet been voted on, you can follow the discussion of this feature on the mailing list.

Argument Unpacking

This feature is commonly referred to as a ‘splat operator’, it allows for passing a list of parameters as an array. The syntax proposed by this RFC looks like this:

$params = array(1,2,3,4);

foo(‘value1′, …$params);

This would be equivalent to calling the function like this:

foo(‘value1′, 1, 2, 3, 4);

As you can see, this feature is essentially a compliment to the variadics feature. This RFC has also not been voted on, you can follow the discussion on the mailing list.

Wrap Up

So that’s a quick round-up of RFCs related to parameter handling in PHP 5.6. In the future I may write a more detailed post about some of these features, but for now I mainly wanted to point people in the direction of the mailing list discussions that are currently ongoing.

If you’re a PHP developer, I highly recommend that you subscribe to the internals mailing list and keep up to date with where the language is going in the future. If you’re unfamiliar with the RFC process that is used to develop the language, then I recommend reading this great overview of how the process works.

Run Like a Geek

11 Sep

I wrote a post about Runkeeper and Fitocracy for a friends blog, check it out!

More races!

27 Jun

I’ve been neglecting my poor new blog, let’s see if I can get this back on track! I’ve done several races since my last blog post and have been generally happy with how each of them went.

Warrior Dash

I was really nervous about the obstacles in this race, particularly ones like “Horizontal Hike” which looked like they would trigger my fear of heights. As it turns out, the obstacles are not nearly as tough as they look on the website, the majority of them are actually really easy in fact. There was one or two that was somewhat challenging, but really, the obstacles were not an issue.

The actual trail turned out to be the problem, which is the part that I was not at all worried about, since it was only 5K. It was extremely hilly, rocky, and I found it difficult to keep my footing much of the time. I did actually roll my ankle once, but was able to walk it off and get going again.

All in all, the event was a blast and I’m looking forward to doing it again next year!

Riley’s Run 5K

This was my first 5K race since Blaze through the Zoo, I finished that one in 29:55, which I was quite disappointed with at the time. This race went much better, I finished it in 25:54, which was a new PR and a huge improvement over the zoo run! This race had a very steep hill toward the end, so that made me even happier with my time on this race. It was also a very fun, well-organized event that was for a great cause, I’m really happy I was there to participate!

Blaze the Night 5K

This race was a week after Riley’s Run and my first evening race. Even though the race started out at 8:30, it was still really hot, which made the run more difficult. Thankfully this one was fairly flat, a heat and hill combination would have been really rough! I made a mistake by not taking any water from the water stops, I don’t normally need any water on a 5K, but with the heat, I really should have this time. The last mile was really difficult, I was super thirsty and more than once thought I might actually throw up, which was a horrifying thought at the time! That didn’t happen though, I made it across the finish line and downed a couple of bottles of water and then felt great!

Despite my hydration issue, I finished this one in 25:34, beating my time from the last race by 21 seconds and setting another PR for myself! I was tired before the race started and had to stop and walk a couple of times in the final mile, so this was a huge surprise to me! Although it makes me wonder how much better I could have done had I grabbed some water, which I think would have prevented the walking in the final mile.

All in all, another great event that I’m glad I didn’t miss!

Route 66 Marathon

I’ve decided that the Route 66 Marathon in November is going to be my first marathon! I’ve already signed up and found a training schedule that I think will work well for me. It doesn’t start for a few weeks, so in the meantime I’m just doing my normal weekly miles, but I’m really excited to get started with the marathon training!

Race Reports: Body Shop, Blaze Through the Zoo, and Red Mud Run!

25 May

I’ve ran several races in that last couple weeks, so this seems like a good time for a few race reports!

Body Shop 10K

This was my first time running a 10K race and it went pretty well. I finished with a gun time of 57:27 and a pace of 9:15, which is not too bad for me. It took me close to a minute to reach the start line and run, so my actual time is slightly better. I think I could have done this one faster, I held back in the first 5K to save up energy, but toward the end of the race I wasn’t particularly tired and sped up quite a bit. I still don’t really have a handle on how to pace myself in these races, but I learn a little every time!

The weather was also great for this one, nice and cool and slightly overcast. The race itself was at Wheeler Park, which isn’t very hilly, no doubt that helped me out a fair amount. This is also where I ran my first race, a 5K back in February. I ran that race at a 9:39 pace, which I was happy with at the time. It makes a nice way of measuring my progress, on the same course I increased from 5K to 10K, while dropping my pace from 9:39 to 9:15! I’m not sure if that’s good for four months of work, but I’m happy with it!

Blaze Through the Zoo 5K

I signed up for this race thinking that the whole thing was going to be in the OKC Zoo, but it turns out only half of it was in the zoo. I had quite a few problems with bottlenecks early on in this race. I didn’t make it to the zoo as early as I would have liked, so I started toward the back of the pack and it took me well over a minute to reach the starting line. The problems continued after that, the pathways in the zoo are narrow and there were several times I had to completely stop and wait for traffic to thin out, hardly ideal. There was also a weird loop in the route that caused another bottleneck, as people exiting the loop were meeting people entering the loop.

After about 2.5K the route left the Zoo and entered the Remington parking lot, running in a parking lot is not very interesting! This part of the course was dull and extremely hilly, not a good combination for me. I’ve not really done hill training yet, so this was definitely challenging for me. It was also hot and windy, which was giving me problems. So now that my excuses are done, I finished in 29:55, which should be roughly a 9:37 pace. So this one wasn’t great, but I still had fun!

Red Mud Run

This was my first mud run and I really wasn’t sure what to expect, but I had an absolute blast! It rained all morning, it actually only stopped maybe 20 minutes before the race started, so everything was super muddy. This was also my first time duct taping my shoes, never really thought I would do that!

The race started with a dash through muddy water, trying to run through water is certainly an interesting, and cold, experience! Next up was walking across a small muddy bridge, which was easy, that led into a mud slide that was a lot of fun to go down. Next up was the first wall climb, it was a small wall and easy to get over. A steep muddy hill was next, you had to pull yourself up with a rope and try not to slip, this wasn’t too bad, just had to be careful.

After that point, most of the obstacles became wall climbs and cargo net climbs. None of them were very tall, but the last few were kind of challenging because my shoes were caked in mud and the walls were caked in mud, made it much more difficult to climb. There were also some muddy water puts that we had to dive through, those were a lot of fun!

I’m not sure how long the course was, it definitely didn’t feel like 5K, I would guess it was somewhere around two miles. I also don’t know how long it took me to finish, I lost my timer chip somewhere along the course. However, my friend I was running with finished in 29:55 and I was probably 30 seconds behind him.

I wasn’t concerned about time on this one though, just wanted to finish and have a good time, which I did! I stopped trying to run fast early on, wasn’t worth risking breaking my ankle over! Most of the obstacles also had lines to wait in, so there was really no point in worrying about time.

Coming soon

I’m going to be running the Warrior Dash on June 2nd, while I’m really excited for it, I’m also very nervous about this one! The obstacles look far more challenging than the Red Mud Run ones, and it’s also a full 5K course. I’ve looked over the course map and identified the obstacle that will certainly be my nemesis, it’s called the “Horizontal Hike”. It’s essentially a big arch that you have to walk up and over, I have a fear of heights and I’m feeling dizzy thinking about this one!

There’s also a few 5Ks and 10Ks coming up over the next month or two that I will be signing up for. I feel like I learn something new at every race, so I’m excited to keep them up!

Dragon Launch

22 May

I’ve fallen way behind on my goal of writing at least two blog posts per week, but I’m going to try to catch up. This mornings launch of the Dragon capsule gives me an excellent opportunity to talk about one of my favorite subjects: space!

The Dragon capsule will be the first commercial mission to attempt to visit and dock with the International Space Station. The Dragon capsule will have to pass a lot of tests in the next couple days, before it will be allowed to attempt to approach the ISS on Friday. Assuming all of those tests go well, SpaceX will be the first non government agency to successfully reach and dock with the ISS. That will be a remarkable achievement for SpaceX and a watershed moment for commercial space travel in general.

Some of the cargo being delivered includes student science projects, from the Students Spaceflight Experiment Program, a great program to help get kids interested in science. I think this is a fantastic program and it’s great that Dragon capsule will be able to help continue it! It’s poetic in a way, while the Dragon is ushering in a new era of space flight, it’s also helping the next generation of scientists and explorers who will hopefully push the boundaries even further!

This launch is important for many reasons, it’s the first step in private companies being able to resupply the ISS, and eventually send astronauts back and forth. SpaceX actually plans to begin sending astronauts into orbit as early as 2015, another ambitious goal! It’s also a very important step in significantly driving down the costs of low earth orbit launches, a vital step in establishing a more permanent presence in space.

It will also eventually free NASA from the “routine” duties of low earth orbit space travel, allowing them to focus on pushing the space frontier with bigger and more ambitious missions. Speaking of NASA, I think it’s important to point out just how critical they were in the success of SpaceX. There has been some talk of how much better SpaceX is, because they can do what NASA has been doing for so long at a much, much cheaper price. This issue is not as simple as that, SpaceX is able to do what they do because NASA has already done it, assumed the risks, and solved these problems. SpaceX is building on the foundation that NASA has put in place, not to mention receiving tremendous support from NASA over the years.

As a quick aside, it is so important for the government to continue to invest in science, it makes success like this possible! The economy of the future will be driven by science and technology, and we can’t invest enough money in these areas. Government agencies like NASA, NSF, NOAA, etc are woefully underfunded, this only hurts us in the future. However, that is the subject of another blog post.

Finally, I love seeing the vision and passion that the people behind SpaceX have, it’s refreshing to see people thinking big and accomplishing so much. This is just the first step though, SpaceX has many ambitious goals, from taking astronauts into orbit, to building a rocket capable of both vertical take offs and landing, to eventual missions to Mars! This is all coming from a private company, led by people who aren’t afraid to think big and continue to push the frontiers of space! You can feel the excitement of the people working there in everything they do, here’s a video of mission control during the launch:

Another great moment is the deployment of the solar arrays, listen to the reaction from the crew at SpaceX! Congratulations to NASA and SpaceX, and thanks for helping bring is all a little closer to the future!

My Running Plan

7 May

Deciding that I want to run a marathon by the end of the year left me with me with the question, “how do I prepare for this?”. Aside from the obvious answer of, “run more miles”, I don’t know what to do to start preparing for a marathon. This is one reason that I’ve given myself around seven months before running a marathon, so that I can be sure to learn what I need to learn and ramp up slowly enough to avoid injury.

I’ve scheduled my weekly runs for the next couple months, gradually increasing miles from week to week. I’m starting this week at 26 miles, spread across five days, which is close to where I left on from my half marathon training. I’m going to add-on two miles each week until I reach 35 miles, staying with a five day a week plan. After I make it to 35 miles a week, I plan to hold that distance until August, and work on improving at that weekly mileage as much as possible.

In August I will start an actual marathon training program, most of the ones I’ve seen so far are about 16 weeks. I think after having run 35 miles a week for close two months, I should be in a good position to start training for a marathon in November. I haven’t yet picked a specific training program for this, I’m going to wait until closer to August to see what I feel like I can handle. One obvious downside to this schedule is starting the marathon training in August, which will no doubt be a crazy hot month, so that will mean a lot of early morning runs.

I also need to start working in cross training, but I haven’t figured that part out yet. I don’t yet know what I should be doing or how much I should be doing. I’m researching this though and hoping to start hitting the gym soon. This is probably one of the bigger questions I have right now, hopefully I’ll get it right!

Beyond my normal training runs, I’m signed up for several races in the next few weeks. I have a 10K this saturday, a 5K next saturday, and then the Warrior Dash in early June. I’m sure I’ll also sign up for some more races in June and then some in July. I’m hoping these races will be a good measurement of how I’m progressing.

That’s what I have now, I imagine a lot of this will change over the months, since I really don’t know if I’m doing too much, too little, or if I’m in the right range. Of course schedules are easily broken by life, so the schedule will have to be flexible over the next few months. I’m excited to get started and see where this takes me!

Oklahoma City Memorial Marathon

1 May

The OKC Memorial Marathon was an amazing experiences for me, it was my first big race, my first half marathon, and the end of a long journey of training and self discovery. I had spent the last three months physically preparing myself to run the half marathon, but I wasn’t prepared for everything else about the event. There was a power and emotion that I had not expected, but was as rewarding as finishing the race itself! I wish I had the writing skills to properly convey all of this, but I’m going to do the best I can!

The day started very early, I was up at 4:00am, and several cups of coffee later, I was even alert! Thankfully, I had prepared most of my gear the night before, even still I almost left without my bib, and did leave without eating. I made the mistake of parking well over a mile from the finish line, which was not so bad in the morning, but the walk back to the car later hurt worse than any part of the race!

I was really impressed with how well-organized the race was, it was very easy to find the gear check and then find my corral. I didn’t actually know what a corral was prior to that morning, one of the many things I learned that day. I lined up just behind the 10:30 pace section, which ended up matching my actual finish pace of 10:25 pretty closely. I couldn’t see where the pack of runners started or ended from where I was standing, being in a group of 27,000 runners is really amazing!

One of the most memorable moments of the day, was the 168 second moment of silence that took place before the race start. I’m usually a little jaded about that sort of thing, but being in downtown Oklahoma City with 30,000+ people and only being able to hear birds chirping, was a truly moving experience. The entire event is a great tribute to the 168 people who lost their lives in the OKC bombing, that memory really does fill the race and give it a real sense of purpose.

A few minutes later the race started, it was one of the most exciting and adrenaline filled moments that I can remember, I felt like I could run a whole marathon in record speed! It’s probably for the best that I was caught in a huge pack of runners for the first few miles, and could not run very fast, otherwise I may have really over done it in the beginning.

The first few miles may have been slow, but the excitement from my fellow runners and the crowd made it feel like it was so much faster. There was a palpable sense of energy that permeated the course, it’s really hard to describe just how that felt, but I won’t forget it!

Miles three through six went smoothly, the time flew by, time has never passed so quickly for me during a run, and I was actually going slower than usual! A little after mile six, I started to feel really hungry, mercifully the aid stations had gels and pretzels, they were a life saver!

Speaking of aid stations, this is a good time to mention the absolutely amazing volunteers that were part of the race. The volunteers working the aid stations were all great, helpful, and encouraging people! They spent hours standing out in the cold and sporadic rain, at least we were able to keep warm by running!

The crowds were also great, from signs, to cheers, to costumes, to re-enactments of Pac-Man, to simple words of encouragement, I really appreciated it all! It’s amazing how much motivation that you can draw from the cheers and simple things like someone telling you that there “is less than a 5K to go”, or “it’s all downhill after the turn”, or even just “looking strong!”.  I wish I had pictures of some of the great costumes and signs I saw, but there wasn’t time to stop for that!

Miles seven through nine also went really well, I wasn’t feeling tired or ready to give out.  Somewhere around mile 8 the fork for half and full marathon came up, at that point I felt great and really wished I could do the full, I call that my 8 mile hubris! Luckily I didn’t do anything as dumb as trying to take on the full, I just looked at the fork and told myself “next time”.

That was obviously the right thing to do, because while I may have been feeling like I could do anything at mile 8, the reality of mile 11 was right around the corner! This is where the run started to be difficult for me, which makes sense, 11 miles was the farthest I had run in training. Making it from mile 11.5 to mile 12.5 was tough, encouragement from the crowds and fellow runners was incredibly helpful here. Just being able to talk with other runners around me was a hugely helpful distraction that went a long way toward keeping me going. It’s nice having a shared sense of purpose with the people around you, we were going through the same thing, and we were helping each other find the strength to finish.

Somewhere around mile 12 to 12.5 there were some fairly cruel hills that almost took it out of me, I started to think that I was going to have to walk the rest of the race. I did actually stop here and walk for the first time. I counted to 20 in my head, and then took off running. This was around mile 12.5, and not long later I turned a corner and could see the finish line!

I’m not sure exactly how far it was from that turn to the finish line, maybe a quarter of a mile, it was hard to judge at that point. However, seeing the finish line and hearing the roar of the crowd brought back all of my energy, suddenly I felt like the race had just started! I ran faster in that final stretch than I had at any point during the race, it felt great! I also had the good fortune to be finishing around the same time that the full marathon winner was finishing, I saw him go by me a minutes or so before I finished! He was getting huge cheers from the crowd, it was great to be there at that time, sharing in the moment!

Crossing the finish line was overwhelming, it was one of the most proud moments of my life, a huge milestone on my personal ongoing journey of fitness. I have been very out of shape and overweight most of my life, just over two years ago I was around 270 lbs, which is well past the point of obesity on the BMI scale. In 2010 I started to take my health seriously, I worked at eating well and doing light exercises, by the end of the year I weighed around 195 lbs. In 2011 I decided to take up running, to continue to lose weight, but also to work on being a more fit and active person. I didn’t really take it too seriously that year, but I did make some progress. I went from not being able to run a quarter-mile without getting winded, to being able to run almost 3 miles.

In February, I started to think about running in a more serious way and made the decision to start training for this half marathon. I made more progress in those three months than I would have ever thought possible. Six months ago I would have laughed at the idea of completing a half marathon, it’s amazing how fast you can change your own perspective! Today I weigh around 175 lbs, nearly 100 less than when I started, and I couldn’t be happier with the progress.  I couldn’t have done it alone though, I’m very thankful for the support and encouragement from my family and friends over the years!

My final chip time for the race was 2 hours and 20 minutes, five minutes slower than my actual goal time. Despite not quite making my goal, I still feel great about it overall and it’s left me determined to improve and run a full marathon at the end of the year! I have a long way to go and a lot of work to make that happen, but now I know that I can do it!

Follow

Get every new post delivered to your Inbox.

Join 352 other followers