Archive for the ‘Coding on the go’ Category

Bad internet connections on the move or why web-only generally sucks

TL;DR Internet does still suck in most places, please make standalone apps for your products and services that work offline too.

An internet page through a bad connection

A web page view through a bad connection

A lot of software engineers seem to agree with the popular notion that all applications will be web based one day; I am one of them, but I am someone who thinks that won’t happen soon (not before 2020 anyway) for various reasons.

Going for full web based software vs native software (on phones, tablets but also on desktop OS’s) is less performant and, when you need to do a lot of productive work, just annoying. Even if the native software is not very well designed in all aspects; going from one task to another in a productivity optimised native app will just be faster to work with. From the app (mobile/desktop) design, development and user experience side, it is possible to really push the envelop when going native which is why almost all popular desktop and mobile phone applications are native. That is not why i’m writing this post however and (slightly) worse interaction is something I can live with. Although if I have to use something a lot, it starts to really get on my nerves (try the Elance app for instance…).

Most web sites/applications are written with using mostly server side code with a frontend in HTML, CSS & Javascript. Besides a bit of AJAX, sites and applications are generally not very resilient against bad internet connections. And why would they be; everyone has a great internet connection everywhere these days right?

I travel a lot these days; UK, NL, BE, PT, ES, US, DE and others and I always have a bunch of devices with me, including laptops, tablets and phones. People who adore and keep pushing web-only applications are usually living in dense regions like cities and many of the loudest proponents are in Silicon Valley or other tech areas. Obviously the internet  connection is good there. In the cities. A bit out of a lot of cities (Seattle, LA, London, NYC, Orlando, Madrid, Munchen, Faro…) the connection is (much) worse or does not work at all. Stepping a bit out of London, sometimes even the entire GSM signal is not enough to conduct phone calls on, let alone do any meaningful 3-4g work on. Around and even in Munchen I have a hard time finding a stable connection at all.  A top class business hotel in the center had paid internet wifi so bad that it wouldn’t even load Gmail properly. And this is not a one-off experience; it is common, very common in 2015 still. A normal web application would not really load, an AJAX web application would throw up all kinds of errors (Jira, Hipchat) while a modern web application, once loaded (or preloaded), will work fine. It amazes me that either people don’t travel at all or maybe do not use internet a lot when travelling and just shout ‘all can be web; it is fast enough!’ from their fiber glass internet connection equipped apartments… Not having access to internet is not even the biggest problem; a very unstable internet connection is as the latter is far more common.

When referring to a modern web application I mean applications which let you use all the functionality that could possibly be used offline, actually can be used offline. For instance, writing blog posts, commenting on something, rating something, registering worked hours, creating issues etc. Content that must be updated will have a warning that it is not up to date and you click / drag to try to refresh, or it refreshes when ‘enough’ internet connectivity has been detected.

When ‘the internet is back’, the data is synced with the backend and everyone can see what happened. This is a solution to resolve the bad or no internet issue and there are enough technologies to get this to work, like Meteor or PouchDB. They are quite new and that is something to be weary off, but client-server programming is not new (and has a lot of the same issues) so it’s definitely possible to get it working well offline.

It’s not only small companies who don’t have finances to create web applications like that either; the aforementioned Jira & Hipchat web applications have it and especially Jira should work offline. But they don’t even have an official native or otherwise mobile app.

Which brings me to the next point; you have to preload the web application to work when you are offline. That’s not very convenient; you probably thought ‘there will be connectivity everywhere! It’s JFK right?’ until the plane landed and you notice you couldn’t even download your cat’s homepage properly.

A solution which is web based is for instance the Chrome Web store which allows you to download a base packet of HTML5 code which runs when you click on it, even when offline. What happens after that depends on the creator of the application (as is always the case; unless you are using Meteor or something like that, it won’t automatically work offline).

Which brings me to the conclusion; if you want me (and many people I know with me) as long term client, you need to have a mobile app, preferably native, next to your web application(s) which can work both online and offline. I happen to pick airlines based on this, I don’t work with Elance anymore because of this, I pick products for internal company use but also personal use based on the quality of the web applications and availability, at least for key productivity tasks, of a solid mobile or desktop app, preferably natively written. I wish companies would look around more and notice that the largest landmasses of this earth do not have (stable) internet and that it is quite lame to not account for the large group of (travelling) people in those parts.

You want your clients to use your products as much as possible; you can make that happen by making sure there is a top notch experience on every device, under every circumstance. Take a lesson out of the Whatsapp book.

Trying out ACE as simple touch display (iPad) editor

ACE

ACE web editor

When I go coding on the go, I currently have a very basic text field on my mobile devices to code in. There is no code highlighting or code completion or anything like that; just a boring text field like Notepad. Now there are (apparently) hordes of people who like to write code in Notepad, but I am not one of them.

The first step to get productive on iOS or Android devices when writing code  is to download a better keyboard. With the standard keyboard, it is really not possible to do much of anything on either device as far as coding is concerned. For iOS I selected ProType ; despite the bad reviews (which are mostly about the condensed style of the keyboard), I found that after a bit of getting used to, it works really well and much faster than the default keyboard for mostly anything, including chat, but definitely for coding.

For Android I use the Hacker’s keyboard which is great; on tablets it’s brilliant, but on phones it does the trick as well.

With that out of the way i’m capable of writing code relatively ok in a ‘notepad’ like TextView, but it’s of course not optimal. So then you have the options to buy some component which does highlighting and possibly code completion for you; there are a few of those but they are not very complete nor very well done. Writing something myself is an option but it will take too much time and it won’t be very robust for months or even years probably. So I opted to try integrating something open source. While it is not a native solution, ACE is a very complete code editor written in Javascript, which seems to run relatively well on mobile browsers. A native solution would have been a lot better, but I cannot find any which are advanced enough to use; Scintilla definitely is, but it does not work on Android and it would take me quite a bit of time to integrate it properly in iOS.

To properly use ACE I would need to integrate it into a WebView to integrate it into my IDE. And that is where it gets hairy. I used ACE before on the iPad on a site which uses a few tricks to make it work properly on a tablet and it was quite ok to work with. At least more than enough to like this as a solution for my IDE. In theory.

Wrapped in a WebView in Xamarin Forms (Github link) for iOS and Android, I believed I had something ok to work with. Then the issues started; obviously the scrolling in the editor is not related to the scrolling in the WebView and as such didn’t actually work at all.

Things like this should make it possible to get that to work on a touch screen, but you won’t get it to work very well unfortunately. I experimented a bit with connecting the native UIScrollView coordinates to the scrollBy() of the ACE editor but that didn’t help either.

The most stable result I got was using;

  1. public AceWebViewRenderer() {
  2. ((UIWebView)this.NativeView).ScrollView.Bounces = false;
  3. ((UIWebView)this.NativeView).ScrollView.ScrollEnabled = false;
  4.  
  5. }

However that was very far from perfect as well. Things that are broken and hard to fix (as far as I know):

  • scrolling
  • double cursor when you have text far to the right (CodeMirror always has this)
  • second delay when moving the cursor by tapping
  • completions like () {} [] are very annoying to work with on a touch screen

Because I lack time in experimenting further and the current results are not very positive, I think I will try to find something else to resolve this. The perfect solution, to me, would be an editor (and keyboard additions) like the one used in Codea; it works well and is robust. I believe it to be fully custom made though which, unfortunately, seems the most satisfying route at this moment…

Still hoping for a better solution…

Writing a game without sleep, power or internet at JFK

Desolate JFK

Desolate JFK

I have a small (…) obsession with programming on the go. With that I mean that I want to be able to write software where ever I am and no matter what I might be doing. Or under what circumstances. So if I don’t have any power or internet for 20 hours I still need to be able to code. This has been one of the things I have been trying to achieve over the past 20 years. My biggest issues have been battery life and portability.

The are kind of related in the end, but to start with the former; batteries came a long way since I touched my first laptop somewhere end 80s. I was slightly spoiled mind you; I had a PC-1211 for years already by then which had seemingly infinite battery life. (Not to mention that I still have it and it still works well) That machine was obviously limited in power, but it allowed me to try out some algorithms on the go. Battery life has been somewhat of an issue though; tablets/phones/laptops all have abysmal battery life. I need days, not hours. And ‘day long’ which has been promised for years now, is definitely not for my days nor the work I do. My new Macbook seldom makes 4 hours while coding.

Laptops aren’t very portable either besides the Macbook Air 11 inch that is (and possible the new ‘Macbook’?), so it is also quite annoying to lug them around especially when I’m off for a 2 day hike in the mountains (and yes, I would like to code while walking). That brings us to portability and that has also been getting better (faster than battery life) but I must say my favorite portable devices are, in order: iPad Air 2 because it’s big enough to do ‘real’ work on, but weighs very little and is fast, Samsung s5 for the same reasons but different work and the OpenPandora 1 ghz version. The last one because it’s just ‘complete’; it has Linux, Android and runs everything I need (sometimes with some effort but we decided to find that fun).

The OpenPandora and the S5 allow me to swap batteries, giving me around 25 hours on the Pandora without any power outlet and around 20 hours on the S5. All that fits easily in a light bag still. For the iPad I bring an external battery which makes everything a lot heavier which is the reason the iPad only comes when I know I need to work on spreadsheets or documents a lot.

Last year around this time I went to the US on vacation; to Orlando to see if Disney World was still fun (it was) and, to get cheaper tickets we had a stopover at JFK from 11 PM to 8 AM. We were a bit naive being from Europe in thinking that JFK is a big airport so there must be stuff open all night and 11 to 8 is not enough time to go into NYC.

After landing we got into a little food court where we thought we would browse the web a bit and have some snacks and coffee until the morning. Unfortunately that was not going to happen. Everything closed at midnight. I still am flabbergasted by that fact and don’t really understand it, but it happened and there was nothing we could do about it. A bit worse; internet wasn’t working on our devices for some reason. So we had no internet, no power and after a while, no lights(!).

I brought my iPhone 5s, OpenPandora and my Macbook Air 11 (I did not have an iPad yet) to watch movies in the hotel or something. As there were no public power outlets, I knew I could not work on my Macbook too much because it would shut down after 2-3 hours (I opened it in the airplane…). Without internet I was a bit lost as I didn’t feel like reading at that time and we started to get tired (different timezone).

By then (around 00:30) I remembered some swiping game a friend told me to try. I did not download it yet, but I played it. Looking it up in the Appstore now I think it was Dots. And because I don’t actually like playing games (I only like making them; I don’t nearly make enough of them though), I decided to recreate that game from just my short interaction with it.

Squares

Squares screenshot

On my Macbook I only had Corona for games and because that is LUA I knew on the OpenPandora I could only use Load81 (as I had nothing else for LUA but a basic installation, and, still, no internet). Load81 is a great tool for teaching people to code as it has no no setup times; you just start it and start programming. Antirez of Redis fame wrote it so it’s like a C=64 from the 80s so people can, again, jump straight in as they could back then, without all the dll hell and compiling, linking etc. Just something to play around. I wrote the basic generators and game algorithms on the OpenPandora; aka, most of the code you see in this file was written in Load81.

After I was happy with how all of that worked in Load81, I used an USB stick to move the code to my Macbook and created the working version in Corona from the demo project. That took only a very short amount of time luckily. My wife and I played it in the Disney World queues most of the time. It’s addictive 🙂

Things that this experience taught me are:

  1. Train your brain; without internet you’d be surprised how much you don’t remember; I was anyway
  2. Downloading and setting up/updating development dependencies is actually far more annoying and time consuming than previously I realized; this was actually one of the smoothest dev experiences in years, despite the constraints
  3. You can finish something nice and addictive in a few hours, so don’t let lack of time stop you; just start coding already
  4. Battery life is indeed great on the OpenPandora
  5. Pulling an all nighter once in a while will focus you
  6. I should (and have been) pursue on-the-go coding like never before (I can code now without internet on the iPad & 5S & S5; more about that soon)

Link to the project in Github. Requires Corona.