Email the Author
You can use this page to email Chris Hartjes about The Grumpy Little Book Of Hack.
About the Book
Your co-workers simply refer to it as The AppYou can hear the capital letters when they talk about it. It's an old PHP application that has been around as long as the company has. It does the job, makes good money for the company...and people are terrified to touch it or change anything. You have bravely offered to join the maintenance team because you enjoy a challenge, but the code base is intimidating and uses a version of PHP older than your older sister's daughter. She just turned 8. However, you seem to have attracted the sympathy of the systems people and some of the most senior members of the team. "If you can offer some suggestions on how we can squeeze some more performance out of this application and clean up some of the parts we know are confusing, we're behind you and on-board. Upgrading the version of PHP is possible, we just need to make sure it's the right thing to do. We believe in you!"
Wouldn't it be awesome if there were something that is pretty much a drop-in replacement for PHP and ran faster? Also, while a lot of the code in there does what it's supposed to you find yourself constantly wishing you didn't have to spend so much time reading code "inside-out" to trace what is going on. You start looking online for something that can help you. Surely there are tools that companies that run large PHP applications are using that they are happy to share.
You find itFacebook's HHVM and Hack. It's exactly what you want and exactly what this code base needs -- a performance boost from HHVM and Hack's features to refactor your existing code to make the intent clearer. Time to send that email asking systems to create a server for you with HHVM installed, create an experimental branch in your version control system, and start making this code base easier to understand.
I'm here to helpMy name is Chris Hartjes, and I have been working with PHP since 1998. When not evangelizing testing practices for PHP and doing performance art on Twitter, I am usually working with Other Peoples' Code. Over the years, I have noticed some common patterns in what might be called "bad code." It's usually running on very old versions of PHP and is wildly inconsistent in coding style and choice of solutions. Lack of consistency is, in my opinion, the number one obstacle to overcome when dealing with legacy code bases. Constantly having to figure out programming choices and the mental stress of remembering PHP's API's ("Is it needle then haystack, or haystack then needle?) can cause mental fatigue and allow refactoring efforts to fail miserably. I am always looking for ways to help the applications I work on perform better and have a code base that is consistent in it's approach to solving problems. I wrote this pocket guide to share what I've learned about how HHVM and Hack can be used to improve the quality of your PHP code base, making it more readable and applying some often-needed discipline to the development process. Hack's implementation of "gradual typing" is something I believe in very strongly and can see how it can be used to prevent weird edge-cases from happening in your code. The Grumpy Little Book Of Hack is designed to provide you with practical advice, not be an exhaustive reference guide. Solid advice, crufty code samples, and the reasoning behind the choices make for something you can use right away. Some of the topics covered include:
- HHVM configuration
- Extensions
- Hack modes
- Error handling
- Return value typing
- Collections
Get your legacy code base under control! HHVM and Hack offer a rare combination of extra performance and language features that help protect Future You from Present You by giving you tools to enforce typing and consistency. The Grumpy Little Book of Hack gives you everything you need to get started using Facebook's secret weapon for making PHP better.
About the Author
Chris Hartjes has been helping teams try and produce fewer bugs in production since 1998 with a recent focus on tools and test automation in PHP and Python.
He lives in the snowy wilds of Lucan, Ontario, Canada,