Programming On The Go When You Only Have A Phone
Published: 2020-10-02 00:39:43

<figcaption><span>Cover Photo by <a href="https://unsplash.com/@mbaumi?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Mika Baumeister</a> on <a href="https://unsplash.com/s/photos/android-phone-mockup?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span></figcaption>

*This is a follow-up / extension of my other post, [Using the Cloud As Your Mobile Workstation](https://dev.to/justinhodev/using-the-cloud-as-your-mobile-workstation-2p91), check it out if you haven't!*

{% link https://dev.to/justinhodev/using-the-cloud-as-your-mobile-workstation-2p91 %}

# What This Post Is About
> No this is not a tutorial to code an Android app

Last week I happened to be away from home all day and only left with an ultra-thin laptop to work on. The laptop's battery would not have lasted me the whole day if I ran my virtual machines. As I pointed out in my post above, my solution was using a cloud virtual machine as a workstation, because it was inexpensive for the amount of compute power you get running it for one day and it preserved my laptop's battery.

Today's post however, goes one step further, and details how you can work on your programming projects using an Android device.

# Why Would You Want To Do This?
> *"...your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should."*

In the current COVID-19 pandemic of 2020, many businesses and establishments do not offer their regular sit-in / walk-in spaces. So imagine my surprise when I went to drop off my car for a check-up only to find out it would take 2 hours instead of 20 minutes. And there was nowhere to sit. **And** I only had my phone on me.

*"Why don't you go to the (fast-food place with a clown) down the road?"*

![Unrelated Coffeshop Image](https://source.unsplash.com/1iTKoFJvJ6E)
<figcaption><span>Photo by <a href="https://unsplash.com/@jonasjacobsson?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jonas Jacobsson</a> on <a href="https://unsplash.com/s/photos/table-and-chair?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span></figcaption>

So there I was, sitting on the counter, sipping on my iced coffee and scrolling through social media all by myself, when a thought hit me: *"why don't I work on my project?"*

# The How I Did It

The process is actually easier than you might think, and there are even software as a service platforms such as [GitPod](https://www.gitpod.io/) which offers a VSCode instance in a chrome browser. However, I was more comfortable using a command line and using short-cuts for VIM on a touch keyboard felt more natural than on VSCode. But how do I get a terminal on my phone?

# Enter Termux

[Termux](https://termux.com/) is an open source terminal emulator for Android, providing a sand-boxed Linux-like environment for you to access using a console interface. It doesn't require me to root my phone (which I couldn't have without another machine) and it was available on F-Droid. It's a truly wonderful project, and perfect for what I wanted to do.

Now, I wasn't about to install all my project dependencies on my phone. The bandwidth of public Wifi combined with my phone's battery would make sure I never finish setting up the project before my car was ready.

Instead, I just reused what I had in my last post: a cloud-based virtual machine to work on, but this time, with my phone as a [thin client](https://en.wikipedia.org/wiki/Thin_client).

# The Cloud, Round 2

Last time, I created a snapshot (a copy in time) of both the virtual machine with my development environment and the block storage with my project. The benefit of these snapshots is that I can just bring it back online and it will be the same as when I shut it down.

So after I [generated my SSH key](https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-2) in Termux and uploaded it to my cloud provider, I recreated the virtual machine and SSH-ed in, and viola, a perfectly usable, and powerful, development machine.

![Termux SSH Views of Cloud Virtual Machine](https://dev-to-uploads.s3.amazonaws.com/i/3zzps5j91mgrva7mlo6a.png)
<figcaption>How My Cloud Development Machine Looks In Termux On My Android Device</figcaption>

*or is it?*

# There Is Always A But

I'm not going to lie to you and say that this was a perfect experience and that everyone should be coding on their phones. No no no, this was by far the worst experience short of using [punched cards](https://en.wikipedia.org/wiki/Punched_card) and [a single-key keyboard to type in Morse code](https://www.reddit.com/r/MechanicalKeyboards/comments/arx42u/so_you_like_minimalist_keyboards_next_level/), plus at least those would be kind of fun.

Between the small screen real estate (without an external keyboard) and constant context-switching, it can be insufferable to work on for most people, me included. If I were to do it again though, a wireless keyboard would definitely help here.

# Takeaways

If it's such a bad experience, why am I recommending it? 

I would not say recommending but more so showing readers who have not explored the capabilities of their everyday devices that programming is possible on a wide array of electronics and not just a powerful desktop machine. In addition, I want this to be a motivation that you can, in fact, program on the go if you put your mind to it.

# Afterwords
> Next time I'll program on top of Everest or something

That's it!

Follow or reach out to me on Twitter [@justinhodev](https://twitter.com/justinhodev) for my daily coding titbits!

If you're interested in the project I'm working on, here is the repository:

{% github justinhodev/hype-tracker %}