The Grumpy Little Book Of Hack
The Grumpy Little Book Of Hack
A pocket guide for using HHVM and Hack on legacy PHP code bases
About the Book
You 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 it
Facebook'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 help
My 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
- Hack modes
- Error handling
- Return value typing
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.
- Working With Legacy Applications is Hard
- Proper Application Environments
- What If You Can’t Refactor Everything?
- Hack and HHVM Can Help Make Your Legacy Code Consistent
- Type Systems
- +1 and -1
- Configuring HHVM
Getting Your Code Ready For HHVM
- Starting Tags
- Dropping In and Out of PHP
- Hack Modes
- Most Importanly, Don’t Stress Out Over Modes
- Error Handling
- Return Value Typing
- Normal Arrays
- Immutable Collections
- Fluid Collections
- Tying it All Together
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
C++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
The book is almost daily updated. These incremental updates ease my interaction with the proofreaders.
A Guide to Artificial Intelligence in HealthcareDr. Bertalan Mesko
Can we stay human in the age of A.I.? To go even further, can we grow in humanity, can we shape a more humane, more equitable and sustainable healthcare? This e-book aims to prepare healthcare and medical professionals for the era of human-machine collaboration. Read our guide to understanding, anticipating and controlling artificial intelligence.
C++ Best PracticesJason Turner
Level up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
Atomic KotlinBruce Eckel and Svetlana Isakova
For both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
Sockets and PipesType Classes
Sockets and Pipes is not an introduction to Haskell; it is an introduction to writing software in Haskell. Using a handful of everyday Haskell libraries, this book walks through reading the HTTP specification and implementing it to create a web server.
Introducing EventStormingAlberto Brandolini
The deepest tutorial and explanation about EventStorming, straight from the inventor.
node-opcua by exampleEtienne Rossignon
Get the best out of node-opcua through a set of documented examples by the author himself that will allow you to create stunning OPCUA Servers or Clients.
Ansible for DevOpsJeff Geerling
Ansible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Functional Design and ArchitectureAlexander Granin
Software Design in Functional Programming, Design Patterns and Practices, Methodologies and Application Architectures. How to build real software in Haskell with less efforts and low risks. The first complete source of knowledge.
Composing SoftwareEric Elliott
All software design is composition: the act of breaking complex problems down into smaller problems and composing those solutions. Most developers have a limited understanding of compositional techniques. It's time for that to change.
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before...
All the Books of The Medical Futurist
6 BooksWe put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy, digital health investments and how technology giants such as Amazon...
3 BooksBuy every PowerShell book from Adam Bertram at a 20% discount!
Cisco CCNA 200-301 Complet
4 BooksCe lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301.
Linux Administration Complet
4 BooksCe lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité...
Modern C++ by Nicolai Josuttis
Django for Beginners/APIs/Professionals
Learn Git, Bash, and Terraform the Hard Way
3 BooksLearn Git, Bash and Terraform using the Hard Way method.These technologies are essential tools in the DevOps armoury. These books walk you through their features and subtleties in a simple, gradual way that reinforces learning rather than baffling you with theory.
Software Architecture and Beautiful APIs
2 BooksThere is no better way to learn how to design good APIs than to look at many existing examples, complementing the Software Architecture theory on API design.
Digital Future of Healthcare and Pharma
3 BooksThese three popular e-books from The Medical Futurist describes how digital health technologies will shape the future of health, healthcare, medicine and pharma with exciting infographics in a digestible format.