Image: Alok Menghrajani
A few weeks ago, Alok Menghrajani, a security engineer at Square, set out to challenge himself. He wanted to fit a bootable CD-ROM, and a retro video game inside it, into a tweet.The results are pretty cool. Within 280 characters, Menghrajani crafted code that creates a CD-ROM disk image, which can either be booted up in a virtual machine or burned to a physical disc. Inside that is the video game, which he described as a mixture of Tron and Snake. It took Menghrajani two weekends–between 50 and 100 hours–to complete, he estimated.
“I find it relaxing,” he said over the phone. “It’s a way to meditate for me.”
The process of fitting this all into something the size of a Tweet, Menghrajani says, is known as “code golfing.” Just like in golf, it’s a game of reaching your objective in as few steps as possible–in this case, writing code efficiently enough to do something with the least number of characters.Menghrajani makes a hobby out of it. About five years ago, he code-golfed his way into embedding a QR code within a QR code. And a few years after that, he managed to fit a bootable floppy disk and a video game into a Tweet. Since then, Twitter has doubled the character limit for Tweets, which gave Menghrajani the space to try to do it with again a CD-ROM.“It’s a fun activity,” Menghrajani said. “Once in a while I’ll come across as challenge that’s like, ‘Hey, this is a fun thing.’ I used to every month try to come up with something. Then I had a kid, so I haven't been writing as much.”Menghrajani said that the CD-ROM idea was originally inspired by a conundrum he was facing at work. He started delving into research about how the CD format functions, and once he did, “I was like, ‘I can probably fit this is a tweet,’” he said.For Menghrajani, whose day job involves doing a lot of code maintenance and upkeep, code golfing provides a different sort of satisfaction.“It’s pure hacker spirit,” he said. “You just write the code and see what it does.”