Programming Sans Internet
Software development is tightly coupled to the internet. Some programs refuse to run or fail catastrophically without an internet connection. For most people a computer becomes a useless pile of metal without an internet connection.
Lately, my circumstances have required the dreaded skill of programming without the internet. The This blog post was completed just before the power company tripped over itself. and Here's to hoping that the Starlink project becomes successful and affordable. infrastructure in my country royally sucks. Keeping in a state of “flow” when the internet goes down is extremely difficult. Let’s take a look at my basic approach to remedying the difficulty of programming without an internet connection when its absolutely needed.
There are many kind people in the world. Some of them write manuals that no one really reads. Linux based distributions have first class support for
POSIX style programming. One could simply run the command
man to bring up any function or program instruction in the
POSIX programmer’s manual. If we wanted to know how to use
mmap we could simply run
“Knowledge is of two kinds. We know a subject ourselves, or we know where we can find information upon it. When we enquire into any subject, the first thing we have to do is to know what books have treated of it. This leads us to look at catalogues, and at the backs of books in libraries.”
Manpages are faster than a search engine lookup — but only if you know what you are looking for. Search engine lookups can be expensive Multitasking. There is a mental cost to every context switch. switching actions, but you often get what you’re looking for quickly.
Good manuals contain a synopsis of a program or function, an example of its usage pattern, return value references, and most important of them all — error handling instructions.
Ensure you have manpages for all tools and target languages that you are working with if available. Check your local distribution’s repository to see if there are any extra manuals available.
man -Tpdf mmap | zathura -
is a very well known and respected documentation source. If you find a wiki that you visit more than once —
it immediately. Relegate any downloaded wiki to a directory where you can
grep through the files quickly and easily.
This applies doubly for any
wiki. Extract markdown copies of a repository’s wiki by using the
git clone command.
git clone https://github.com/koalaman/shellcheck.wiki.git
GitHub’s pull requests and issues contain critical information. Grab all pull requests and issues from any
It goes without saying that there should be an offline copy of any repository you work with.
using the Github
API (Application Programming Interface).
REPL stands for read, evaluate, print, and loop. It’s basically the equivalent of a command line shell for a specified language. Get comfortable using a
REPL just like any other familiar shell to reduce internet lookups and context switching.
Most of us use our heads as rudimentary
REPLs. Basically, we write a piece of code with the general expectation of its action and return state.
Eventually you’ll reach a point where you’re doing that weird
Unpacking a tricky error state is often much quicker in a
REPL than with an internet search or using a crude crash and burn method. This saves time and having to context switch to a search lookup for some common or obscure error message. Make sure to have all
REPLs offline for any language or tool you use regularly if available.
Static code analysis offers refactoring advice, sniffing out high level coding errors, and correcting naive approaches to a problem. Static code analysis tools can hold your hand and carry you a good distance.
In fact, there are some static analysis tools that are so
hlint as well as Shell's
that if you have good cursory knowledge of a language, you can learn the ins and outs quicker than reading a book.
The authors of static code analysis tools know more than you — it’s as simple as that. Static analysis coalesces a collection of common questions, answers, and pitfalls that many experienced people have encountered time and time again.
Even programs that are configured with
How many of us are familiar with vulnerabilities such as
HTTP request and response splitting?
have their own static analysis code tools like
Ensure you have all static analysis tools for any language or program that you work with regularly offline.
Most people use integrated development environments (
IDE) nowadays which probably handles most or all of the above (with or without internet probably), but in a situation without an internet connection having an editor that is flexible is paramount.
This means an editor like
emacs. In the jungle, you don’t have the luxury of downloading a plugin or extra feature to assist you. Flexible editors have configuration that is dynamic enough to code your own plugins trivially on the fly.
Emacs is written in Emacs Lisp, and Vim uses Vimscript. Vim itself has one of the most thorough manuals in existence, so implementing an ad hoc plugin for an odd workflow is not too difficult as long as you know how to read.
Updated 30 July 2020