Tuesday, March 26, 2024

Programming on an iPad

I am launching a Java web app. It is 14k lines large. 45% of that I wrote using a 2024 12-inch iPad Pro.

You can't compile Java code on an iPad. You don't even have direct access to a hard drive. One of the first realizations I had when I decided to go down this road was that I would have to rent a server in the cloud just to do development on it. I could install openjdk on it and compile my source code there.

The next big decision you have to make is how to inform your remote cloud machine of the latest keystrokes you've typed to move around characters in a source code file. I read a guide that said that typing in things using an iOS text editor was fundementally too frustrating, and that one should use a web-based text editor that sits in front of your cloud machine. I did not reach this conclusion in my research and approach.

What I did was go ahead and choose Textastic as my text editor. As its accomplice, I chose ShellFish. What ShellFish does is allow you to enter SSH information into it, and it'll sync files via SFTP from your remote cloud filesystem into the Files iPad OS app. Textastic integrates with ShellFish, so you can open files that ShellFish knows about with the Textastic open file dialog. ShellFish was like $30 for a lifetime license. With it and Textastic, you can edit files on your remote cloud machine. Every time you save, your changes get pushed into your cloud machine.

ShellFish also provides support for moving files you download in Chrome directly into your cloud machine. It does this through the "Share" generic function that shows up when you're looking at different things on iOS. This was very handy when it came time to download my SSL certificate and key.

I think Textastic was $10 for a lifetime license.

There is a Git file manager called Working Copy. It's a feature-rich app but I haven't found any reason to use it. ShellFish and Textastic combine to give me all the Git happiness I need (Git is of course installed on my cloud dev machine). But of course to use Git and do a host of other things, you need real ssh access to your cloud machine. This brings us to terminal apps.

Textastic has terminal support but it's not very good. Fortunately there is another (free!) app called Termius. I say free - you can pay a monthly fee for additional features like agent forwarding but I've been living at the free level. Termius is really good. One thing it has to do is use the Location services on iOS to do its work when it's not in the foreground. Which I find fine.

Termius provides an additional need which is port forwarding. When I run my app in the cloud, I need to be able to tunnel in to see it from my iPad. Termius supports such tunneling. So you can open the Chrome browser on your iPad and point it to http://localhost:3000 and as long as you've configured and turned on a Termius mapping from port 3000 on your local machine (127.0.0.1) to whatever port you want to connect to on your cloud machine, you're off to the races. As an aside, I had to use iptables to block public access to the port I listened to on the server. This way no one can see my dev server even though it's on a publicly reachable cloud server.

So with ShellFish, Textastic, and Termius I am up and running. My cloud dev machine I rented from Linode. I use a 4GB dedicated machine. It costs $36/month.

One thing I am pleased to discover that I don't miss is Emacs. People who know me might be surprised that I can do without Emacs. Textastic has a find feature, but it does not have a find-and-replace feature. To alleviate this, I found myself learning to use GNU Sed. You can do a lot with sed at the command line. I had to rename a package name on my app and sed, xargs, and find were able to make that not-so-difficult for me. I had to rename a model and sed came in handy there, too. Just be careful. Sed is powerful and I had to spend 20-30 minutes debugging a problem I introduced with it on one of my renames.

There are problems.

  1. Textastic and ShellFish don't work sometimes. Sometimes when opening and editing a file, especially one very recently generated outside of Textastic, one of these two apps starts creating collision-avoidance files. For a file like MyApp.java, the files I'm referring to get names like MyApp-2024-03-26.java, MyApp-2024-03-26-2.java, etc. I wrote a Ruby script that scans my source files and deletes files that look like this. I have to use it about once every 5 hours.
  2. Textastic and ShellFish sometimes take a moment to upload a file. This can be really confusing, because you'll see an error that you think you've already fixed. You trust the compiler and feel stupid, when really the problem is that the compiler just has out-of-date source code and your changes haven't propagated up to the cloud yet.
  3. The Chrome dev tools are not available on iOS. Neither are the Firefox ones. Goodbye JavaScript console. Goodbye hot-editing of CSS. Goodbye view source (yes, really). I had to write a custom logging feature to give me some feedback on JavaScript print statements I would add to my code. This was somewhat helpful but nowhere near what I would call a solution. Who knows when we'll get the dev tools on iOS.
  4. A 4GB RAM $32/month dev machine is not nearly as powerful as a recent MacBook Pro. I feel the pain on every compile and test suite run. Of all of the problems I've mentioned so far, this one is the most onerous. I tested an 8GB Linode, and it went faster, but it didn't feel worth the money to me. The 4GB dedicated CPU machine was an upgrade from where I started - a 2GB shared CPU machine.
  5. Sometimes Textastic is so lost that I have to reboot my iPad. I've even had to hard-reboot it once. This hasn't happened to me for about 2 weeks so maybe patches have helped?

I use a fullsize bluetooth keyboard.

The last thing I'll mention is that I am using an iPad with cellular service. I pay for a plan with Verizon. They say they throttle me down after 30GB of network transfer. I regularly exceed that monthly allowance within a week, but the throttled speed is still plenty fast. I've noticed no hardship from throttling.

I love programming on an iPad very much. One of the other things I've been using my iPad for is studying, using Kindle. I like that the act of doing tech stuff has been rendered relatively simple. Do we really need powerful PCs? If and when I work at a normal job, I would be pleased to use a "real" computer on-site. But if I'm doing stuff from a satellite location like my home, I like where development on an iPad is at.

No comments:

Post a Comment