DEV Community

Cover image for Coding for fun on a smartphone
Graham Trott
Graham Trott

Posted on • Updated on

Coding for fun on a smartphone

A smartphone, as well as being able to make telephone calls, is also a device for absorbing small units of spare time. Anywhere, any time people have nothing to do, out come the smartphones, which we then peck away at en masse, heads down and generally oblivious to whatever else is going on around us.

A smartphone has all the features of its bigger brother the personal computer, and then some. After all, few computers can make phone calls, act as a torch or show you where you are on the planet down to a few meters. The power of a smartphone is equivalent to that of a laptop computer of maybe 5 years earlier, so it's no slouch in the processing department, but its most notable feature is also its main weakness compared to a computer. Although the screen resolution is frequently better than that of a laptop, using it for text at that resolution is impossible without a magnifying glass.

So one of the hardest things to do on your smartphone is to write and test code. Which is a shame, because programmers also have time to fill; on buses, waiting for the dentist or in the usual social environments where everyone else is peering at Facebook, WhatsApp or Instagram.

I'm not talking about carrying our work wherever we go or cramming essential skills for that interview coming up. Worthy as this may be, we all need a break from time to time, and for some of us that can still be coding, just a coding activity that's a bit less demanding; more fun, even.

What we need at times like this is a coding playground. JSFiddle and CodePen are probably the best-known of these, though the former is rather cumbersome on a phone. However, the problem is not really with the tools; it's with the language. To get anything significant to run in your browser you need to juggle 3 scripts; HTML, CSS and JavaScript, the last of which can get pretty lengthy, especially if you have to keep source lines short to prevent them wrapping on your small screen. (I rule out using landscape as the keyboard ends up taking most of the space.) Your results appear in a fourth window so you're switching back and forth all the time, and you have to be pretty determined (or marooned on a desert island) to continue with the experiment for very long.

At this point, spare a thought for young coders in some less well-endowed parts of the world, where smartphones outnumber PCs many times over. (As a matter of fact, there are plenty of disadvantaged communities in the so-called 'developed West' where this is just as true; it's not a problem that's confined to African and other post-colonial countries.) There's a wealth of potential talent we pay too little attention to encouraging.

It was an attempt to 'scratch my own itch' that originally led me to write a completely browser-based high-level language. I wanted something higher-level than JavaScript, that would let me code an entire web page in a single script, one whose vocabulary and syntax would be rich enough to deal with not just the code but all the markup and styling too, and to me "higher level" means "closer to English". My own native language is the Gold Standard in this respect; I regard it as the pinnacle of human communication and have a mission to train computers to understand at least some dialect where man and machine can meet.

Of course when you write your own programming language no IDE will understand it, so you have to forego the niceties of color-coded editors, autocompletion and so on unless you can do it yourself. This started to look like a deal-breaker, so I went hunting and quickly discovered CodeMirror. After some head-scratching I figured out how to customize it to color-code my scripts and I was back on track again.

So I was now set up to write code for the browser in an expressive language that required no external compiler or build tools and could do everything from basic arithmetic to graphic animation. It goes without saying that I wanted to be able to play with this in my spare time too, writing simple games and simulations or just trying out ideas that would be useful elsewhere.

Somewhere around this point came the idea of building a scripting playground combined with a tutorial and reference manual, and naturally it would have to run on a mobile browser too. Equally naturally, it had to be all written in the same scripting language; if it couldn't handle that then what kind of a pathetic excuse for a language would it be?

Well it didn't take that long really. Maybe it's just the way my brain is wired, but I find I'm most productive when I can take the thoughts that are in my head (I think in English, not JavaScript) and type them with the minimum of translation needed along the way. For me it's the quickest way to get things done. The scripting language allows the job to be shared out among multiple scripts, each of which does its own bit. Typically each one handles a different screen panel so all the main script has to do is call them when they're needed. In fact, it took longer to write the customized ShowDown reference pages that describe every feature of the language than to write the code that drives the IDE.

The project is still ongoing but it's now at the point I feel confident enough to offer it to others, the hope being that feedback will point the way for future enhancements. Maybe some would like to use a mobile-friendly scripting playground, as I do, to soak up some of those tedious minutes after Facebook begins to pall. If you do, let me know what you thought; what you liked (if anything) and what you didn't, and where it should go next.

Thank you for reading. The scripting playground can be found on the Codex button at EasyCoder.

Photo by LinkedIn Sales Navigator on Unsplash

Top comments (6)

Collapse
 
edo9k profile image
Eduardo França

The idea of "being as close to English as possible" reminds me a lot of some of the ideas behind COBOL, which ended up with the language having an absurd number of reserved words (more than 300 if I remember correctly). Was COBOL an inspiration to you in any way?

Also, there a programming language called Plain English. You should check it out, maybe there are some lessons to be learned there.

Collapse
 
besong141 profile image
Besong141

How do I go about coding with my phone

Collapse
 
gtanyware profile image
Graham Trott

The main reason to code on a phone is to run the code on the phone, and the only programming language available for that is JavaScript.

You can try the usual coding playgrounds, e.g. CodePen or JSFiddle but you may find them hard going on a phone. I tried both and gave up as I couldn't manage 3 sets of information (HTML, CSS and JS) on the small screen.

Since I write computer languages as a hobby I decided to build my own coding playground, which you are welcome to use. It lets you write code and run it directly. However, it doesn't implement a standard language; it's designed specially to make it easy to write code that runs in the browser so it operates at a much higher level than mainstream computer languages; much closer to English in fact. I don't regard this as a disadvantage because core programming skills are independent of the chosen language. Once you have them you can use them anywhere.

The coding playground is the EasyCoder Codex. It's optimized for both PC and small-screen mobile, though the latter will never really compare in ease of use. I use it to test ideas quickly, without the need to build a web page each time. If you need help you'll find me via the About us / Contacts page at EasyCoder Software.

Collapse
 
besong141 profile image
Besong141

Thanks for everything I appreciate

Collapse
 
edo9k profile image
Eduardo França

You also use a website like Try It Online, it let's you run hundreds of programming languages, no need installing anything, or even making an account. tio.run

Codepad.org is good too. And the editor is a just an input box, which works great on a phone.

Finally, there are a lot of apps that teach you some programming basics. Codecademy is one of them, but there's are lots of others.

Collapse
 
anwar_nairi profile image
Anwar

Wonderful, I just overviewed the Codex, great idea to let people understand your technology! Also, very nice that you separated East Coder to be used independently, I think this is definitively going in the sense of opening this alternative for the most people possible that would work only in front end.