Announcing hack-mvc

hack-mvc, a simple MVC Framework for the hack lang 


Back in 2010, while GROU.PS was a free service pushing 1PB data with 8 million monthly unique visitors, we were bleeding $100K/month on server related costs. The platform was running on ~ 70 beefy servers on SoftLayer and we were using certain AWS products such as S3 and Cloudfront. It was a pretty painful time for a startup that had only raised $2mm with no monetization plans in the horizon. But it was also a big lesson to squeeze every dollar you can out of your CPUs, especially if you’re offering a B2C product that’s free to use.

That’s why I think Facebook’s recent announcement of hack lang (and hhvm itself) are big wins for the consumer internet startup community. PHP is great for getting started, but it is not the most CPU friendly language and runtime out there. And at some point, you’ll need to think about those too.

Fast-forward today, GROU.PS itself is a subscription based business which can finance itself but right ahead of a new (free) consumer product we’ll launch, we wanted to code the frontend in the hack lang, in an obsessive attempt to make the product as scalable as possible at the lowest cost.

So without further ado, here comes the hack-mvc. The MVC framework that we’ll use for the frontend of our upcoming app, and hopefully others will follow and benefit from it.

hack-mvc is far from being a complete MVC framework but it’ll do the work for us, and it’s been very instructional. hack-mvc is a fork of pip so I should also give a huge credit to Craig Russell for his work.

My original goal was to write a fully strict hack framework with dynamodb support in the Model layer and a rich View with mustache.php but it didn’t take long for me to discover the following limitations that rendered the job impossible.

  • The fact that the only top-level statements that can be present in the strict mode are requires, it is just impossible to launch the whole thing in strict mode. I think this is just an after-thought and the hack lang team will loosen this restriction by allowing at least a static class method to be run by default similarly to Java.
  • The strict doesn’t allow one to use the eval function (eval is evil) or statements like “$helper = new $name;” and that makes the life of a strictly hack MVC framework coder a hell. The reasoning can’t be type checking because as a programmer, I could have specified an abstract class name as the type of $helper and only assign the descendants of that class dynamically using the $name variable.
  • Not a big deal, but the need for hhi implementations is just confusing.

These limitations made it impossible to write a fully hack-strict MVC framework. That’s why while most of the framework is written hack-strict, there are parts that are hack-partial but I’m proud to say at least there’s no use of decl.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.