As a programmer/sys admin I often find myself in need of having to check or debug some code on the go. As dramatic as it sounds, I don’t owe a laptop, so my phone is my only option. So I figured out some ways on how to go about writing and making small changes and running code on the go. This is specially helpful for server scripts and monitoring.
I wouldn’t recommend it for learning a programming language because the font size on the phone may affect your eyes, but if you are okay with that you certainly can write, learn, compile and run full blown programs from your phone without an issue.
The way I prefer works both on the iOS and Android devices. So doesn’t matter if you owe a iPhone 7 or Nexus 6p you’ll be able to write code with no issues.
Entry of SSH
So, if you want full set of features of a language or you want to do what you are able to do in a desktop or laptop you need to have that sort of OS compatibility and Android and iOS OS’s are not made for that sort of task. There are ways you can install Linux on your Android phone and run code as you would, but that kills the purpose of the phone and I think it’s a pretty stupid thing to do if running code is your only purpose.The way I prefer is uing SSH (Secure Shell), for those who don’t know SSH allows you to access another computer from another computer. The catch is that you only get the terminal that too of a Linux system, if you are a hardcore GUI user it’s time to switch gears. By switching gears, I mean you need to know basic bash shell commands, know how to use the VI text editor ( You can use nano but nano sucks specially on phone).
Basically what you do is get a App( That is the SSH client, Juice SSH is my favorite) and configure a Linux System on the cloud to be a SSH server and then use the SSH client on your phone to access that system on the cloud. So you’re accessing that Linux System from your phone and running, writing code on that Linux system using the terminal you get. I edit files using the Vi text editor, if you don’t know VI time to take this primer. Yes, you’re not running any code on your phone actually. But it works. Next Up, are the steps on you how you go about doing it.
On a side note, I am a Linux user and I’ve been using full time shell for a year now and I highly recommend try living the life in the shell, you’ll love it. Keep the GUI ofcourse you need it now and then, bu for code related work, try using the shell.
How to run Code on your phone using SSH
You need a server on the internet, I will recommend getting a server ( or droplet as they call it) on DigitalOcean , they are cheap and the service is so far amazing. Starting from 5$ per month.
Once you got a Linux computer on the cloud, does not really matter which distro you choose. DigitalOcean will give you the server with an IP address. See my screenshot below, I have two servers with 512MB of ram.
Once you have the IP Address of your droplet, you can access it through a SSH client on your window/osx/linux copmputer. Here’s a guide on how to setup SSH with digital ocean on your computer.
In fact, SSH is one of the most convenient and most used way to access a server. So, as we all know we have a app for everything. Why not a SSH client on your phone. I highly recommend JuiceSSH for an SSH client on your android phone.
The process of connecting to the cloud computer from your phone is pretty simple. You need to provide the IP address of the server and JuiceSSH will attempt an ssh session then you need to provide the username and password of the cloud server and then you can run any command you’d run in a normal linux computer’s actual terminal or terminal emulator.
Running and writhing code on your Phone
As running code needs all the build tools and compiler and dependencies you need to install them. Digital ocean does come with the gcc and python installed. Still you would want to install the build tool for c++ and c compilation using sudo apt-get update && sudo apt-get install build-essential
Once you have that installed, it’s just using a terminal based text editor and using normal commands to compile and run. So that’ it.
If you have any question or suggestion me know in the comments section, I’ll be fast at the replies. 🙂