Jan 2
In Project Review: Video Channel
posted by: Player0 in javascript, php, projects on 01 2nd, 2009 | | No Comments »

I got talking about video in my last post and I couldn’t help but to start thinking about my endeavors with a previous employer.  In fact, it was some of the most interesting work I’ve done for any company.  In 2006, I was working for Synacor out of Buffalo, NY.  They provide web portals for major ISPs so their cable modem customers have an AOL-like experience.  Internet video was already very big with YouTube’s success and AOL’s video channel right around the corner.  Cable companies have access to all sorts of great digital media but don’t really have an avenue for delivering that to internet customers.  I was brought on to the video project to take the existing product and bring it in to modern times.

The resulting product can be seen here.  As of this writing, not much has changed from my original designs even though they are several years old.  Like all my internet creations I’m sure it will morph in to something unrecognizable soon enough.  And like most of my internet creations, management stepped in to make several surface level decisions about layout and advertising.

I should be clear about what I did on this project because I want to give credit where credit is due.  I didn’t write the framework from the ground up.  I built around what was originally there.  I made many changes to the database schema apart from the word search index which I wasn’t scheduled to get to just yet.  I beleive I rewrote most of the PHP and created all the APIs and JS from scratch.  I had nothing to do with the design of the page since we had a design team but I did do the HTML and CSS.  I did a little AS programming for the Flash Media Player but left much of that up to their talented flash developer.  And I left the company before totally completing the new version of the video product.  Integration with the flash player was not complete and there were a couple other minor features that didn’t work yet.  Mostly this revolved around tying the video product in to the Synacor’s various incomplete CMS products.

With that said, and although the credit was stolen from me, I architechted the overall product.  From getting videos on digibeta tapes for from FTP uploads, transcoding them, and feeding them in to our front end database, to ajax-ifyign the user interface with an event listener model so the page layout was modular to speccing out exactly how the flash media player should integrate with the XML for a content rich experience.  And the neat feature of having the video player pop off of the page and allow you to drag it around and change aspec ratios… that was my idea too.  I designed it to function like a stand alone media player application.  The player window would load a Flash or a Windows Media player object and make this as transparent as possible to the user.  And you’d have all the basic controls you’d expect from a standalone media player.  It’s not amazing but it’s a pretty neat user experience and not one I’ve really seen anywhere else.

The modular aspect of this page is the most underrated part.  This video product is meant to be used for a variety of customers and each wanting customizable features.  If you want a horizontal and/or a verticle channel bar, you can.  If you want multiple video indexes or just one, you can.  If you want to spotlight 10 videos or 1 video you can.  Templates control the whole thing and you simply enable modules from the CMS system.  Each module on the page, the channel bar, the video listing index, the spotlights, the channel specific ads, etc all listen to the states of the other objects that happened to be published on the page and DTRT accordingly.  The page still uses the sheep.js event handler I wrote.  And I’m singularly impressed with how fast all the ajax is on the page.  There is a lot of background preloading and caching and pagination happens on the client side.  A weird arrangement and potentially risky but the datasets are constrained and seem to be lightweight.  Perhaps they are cached and/or gzipped at this point.  The ajax is serving raw HTML as well which is a bit strange.

And I’d do things very differently these days.  I’m glad to say I’ve come a long way in the past few years.  If I could do things differently I’d have fought harder for Prototype/jQuery/YUI or some other JS standard.  I would have used JS’s event model instead of using my own.  I would have used libary JS effects from script.aculo.us or something.  I certainly would have used JSON with the ajax requests.  I certainly would have tried to get memcached working and I certainly would have tried to get them on Akamai or some other decent static content delivery system.  I still would have suffered trying to integrate this thing in to the custom CMS products though :)  Most importantly, I probably could have done this project in a quarter of the time by applying those techniques.

It was really fun work and I miss doing it.  The company just wasn’t a great fit for me at the time though.  They were waterfall method which meant I was writing a lot of useless documentation, releases were months apart and I dealt with more red tape than programming.  I could have gone at 10x the pace.  I did not get along well with my product manager who was hired as a ‘hotshot’ from AOL.  She played the game well.  She rested on the laurels of others and functioned solely as funnel for information.  A one way funnel.  My ideas became her ideas.  My timelines became hers.  My specs became hers.  My success became hers.  And when the video product was launched and there was a party, kudos were given to several management types by name.  And I, having done at least 80% of the projects work, received his thanks in the way of ‘…and everyone else who made this possible’.  An architecht who did nothing more than review my spec for about 5 minutes was thanked by name for his incredible help on the project.

This product manager left not too long after I left.  She wasn’t going to deliver much without me.  Always end on a high note I guess.  I’ve never had such a problem with a company before or since.  I honestly think I was cursed at Synacor for some reason.  I always felt so underestimated.  I always succeed very well with other companies but I just couldn’t make it work there.  I think first impressions are everything and I didn’t give a very good first impression there when I started I guess.  It had been a while since I worked for a larger company and I was a bit intimidated and I had problems communicating with the others because I was behind on the jargon.  That was rectified 6 months in but I think the stigmata stayed with me for the rest of my two years there.  And beleive me I tried.  I *always* try.  My complete and utter lack of energy to move in the AM makes it looks sometimes like I don’t try but I really do try to prove and better myself every single day.  As long as companies don’t mind me coming in at 10:15am, and staying later of course, I’ll continue to do just fine :)

Nov 7
Monkey Hate PHP
posted by: Player0 in php on 11 7th, 2008 | | No Comments »

Ugh, I’m really starting to lament my choice to be a PHP developer.  Sure, it *is* better than Perl and who knows if I should learn Python, Ruby or Java.  I found a little nugget of joy today when using PDO and ip2long().  If you simply do a $sth->bindParam(’:iplong’, $iplong); the query my receive something like -42452 which won’t work.  This issue is complicated by the fact that, as far as I can tell, PDO provides absolutely no method for viewing any query with the parameters replaced before or after you exec() it.  Also take note that without a 3rd parameter, bindParam is supposed to work in PARAM_STR mode.

But, due to the mysteries of type conversion and PHP’s utter inability to deal correctly with any number much larger than 2 billion, you must do:

$sth->bindParam(’:iplong’, sprintf(’%u’, $iplong), PDO::PARAM_STR));

More issues arise in PHP land when you try to take advantage of the fact that MySQL developers aren’t necessarily inbred.  Take, for example, a BIGINT(20) column type.  There’s no real reason why this 64bit integer isn’t a commonly used data type.  If you have a table with auto_increment IDs and you delete from it regularly than BIGINT is a must.  Or suppose you want 64 enable/disable bits for some reason.  Well you can treat them as strings in PHP as long as you don’t EVER try to use them in something which is going to assume they’re numeric.  And forget adding, subtracting, bitshifting, etc without BCMath or some equivilent extension you’ll be lucky if is ever compiled in to your PHP install.

This is ignoring the glaring problem of platform specific architecture and PHP’s retardation in abstracting that.  Your (int)s on x64 might be 64 bit or they might not be.  Nothing is guaranteed.

I heard that PHP6 fixes a lot of UTF8 stuff.  I suppose it’s too much to ask for it to add a 64bit integer type.

Dec 8
Philosophy of PHP
posted by: Player0 in php on 12 8th, 2007 | | No Comments »

Computer languages are flexible beasts.  PHP is no exception and it’s because of this fact that I have a real problem developing a real coding style in PHP.  I believe that PHP was developed to speed web development.  To make web development easier.  It succeeded in spades.  PHP has become the joke language in place of JavaScript.  Anyone’s mother can create a site and add some PHP elements.  You don’t have to understand PHP to add a <?php date(’Y'); ?> on to your site.

PHP, thanks to it’s success as well as Zend, has grown in to larger beast with OO and all sorts of modules and CLI.  And immediately we run in to a problem: PHP is slow.

It all comes down to how enterprisey you think you need to be.  Sure, abstract classes and design patterns and throwing errors is all nice and good and flexible.  But they all make for slower applications.  They also make for slower development processes.

Then ask yourself WHY are you using PHP?  If you want security and speed and UTF-8 and enterprisey, isn’t Java a better choice?  It’s not that much harder to compile code people.

I may be a PHP purist.  I want to keep PHP quick to develop and simple to maintain.  I do like classes because they add name spacing and organization.  But we don’t NEED to be fancy and more than one function call per function is a bad thing.  I don’t want to give up foreach loops for performance reasons.

Yet so many companies build these massive frameworks and OO models which are meant to reduce programming needs down the line but ultimately become these huge elephants that are shot in the chest after it’s discovered that PHP can’t actually manage firm business requirements such as internationalization or code security.

If you let the programmers just build something that works and is at least fairly well done even in a simple way then let feature creep happen you’d be better off.  If you can develop PHP fast then it doesn’t matter if you have to reinvent the wheel a couple times.

PHP shouldn’t be called a joke language but it certainly doesn’t deserve to be treated enterprisey either.  Please stop abstracting your database layers three times just in case you decide that MySQL really does suck and MIGHT go to Postgres or Oracle someday.  If you didn’t wrap every DB call with insanity it might not be so slow.

On that note, does anyone know when PDO will start using the native MySQL drivers?