Writing A Programming Book

Juan Manuel Tirado is a programmer who decided to write a book on Go. I’m not a Go programmer so I can’t comment intelligently on the book other than to bring it to your attention. What I can comment on is his post Writing a Programming Book in 2021.

If you’re thinking about writing a book, Tirado’s post is mostly good advice. I don’t agree with everything he says but, of course, every writer is different and it would be surprising if we agreed on every aspect of the writing process. To me, the oddest thing about his post is that he thinks writing a programming book in 2021 could be considered weird and feels the need to justify his writing it. As far as I’m concerned, a good book needs no justification. Those who are interested will read it. Those who aren’t are free to ignore it.

Tirado chose to self publish with Amazon. That’s a reasonable solution but puts a heavy burden on the author. It’s hard to overstate how much work a traditional publisher does to get your book into print. There’s copy editing, cover design, marketing and a host of other services they perform. On the other hand, self publishing puts you in charge. You make all the decisions.

His My recommendations section will probably be the most useful. Tirado found that spending a lot of time of the Table of Contents and then following it when writing was important. I’m more inclined to write the chapters out of order and settle on the ToC when the book is complete. Do whatever feels right for you.

All in all, his advice is worth reading and considering. If you’re interested in writing a book, take a look.

Posted in General | Tagged | Leave a comment

Distraction Free Writing

Phil Newton does a lot of writing. He’s written a book and has a blog and does all his writing in Org mode. That sounds pretty much like me but unlike me, Newton likes to write in what he calls a distraction free writing environment. I’m perfectly happy to write in a normal Org-mode buffer but I appreciate that others prefer a more uncluttered work area.

Newton prefers his text a little bigger, and likes it centered in the buffer. All that’s easy to do and Newton has a .dir-locals.el file in his writing directories to enforce his preferences. That’s nice because other buffer types—such as source code buffers—are unaffected and display as usual.

Almost everything he does, with the exception of Olivetti mode, is stock Emacs so you don’t need a lot of packages. He mentions that his inspiration for this environment is WriteRoom. Someone in the comments notes that Emacs has writeroom-mode that replicates most of the features in Newton’s environment and a few more.

If you’re one of those people who wants to see as close a possible to a blank page while writing, take a look at Newton’s post and checkout writeroom-mode. Newton’s setup, in particular, is so simple that it will be easy to adapt it to your ideal writing environment.

Posted in General | Tagged | Leave a comment

A Year With Emacs

Jakub Kadlčík just finished a year with Emacs. Before that, he was a Vim user for 10 years. He felt that he had reached “peak learning” with Vim except for writing plugins, which VimL made unattractive to him. Emacs’ extension language, on the other hand, is a Lisp, which Kadlčík was interested in trying.

His post, A year with Emacs, is the story of what he’s learned in that year. It resonated with me because most of his reactions were the same as mine. I didn’t opt for Evil and I hadn’t refined my workflow enough to keep a single Vim instance running all the time but otherwise his reactions were the same as mine.

It starts with keeping Emacs running all the time. If you’re used to almost any other editor it seems like a strange way to operate but with Emacs it’s the natural thing to do. It also explains why I get a bit grumpy with people who complain about the long Emacs startup time. It’s certainly longer than Vim but those few seconds are amortized over the often months-long running time of each invocation so if you’re using Emacs correctly the startup time doesn’t matter.

The other thing that really resonated with me is what Kadlčík described as Emacs giving him more Vim than he had before. By that he meant he was able to subsume many of the tasks that used to require separate apps into Emacs. That meant that he had a single unified interface (Evil/Vim in his case) for dealing with those tasks. In other words, Emacs is the ultimate IDE.

Like me, Kadlčík discovered that his system was effectively reduced to Emacs and a browser. Sure, he occasionally needs to fire up some other app but most of his work is done in Emacs or the Browser.

He also mentions:

  • A literate configuration file with Org-mode
  • Mu4e for email
  • Circe for IRC
  • Magit for dealing with Git
  • Edit with Emacs to edit browser text objects with Emacs

Except for Circe and Edit with Emacs, I use all those packages. I don’t use IRC and, sadly, Safari doesn’t support Edit with Emacs or anything like it.

This post is a splendid list of what you can expect when you move to Emacs. If you’re coming to Emacs from Vim, Emacs can help ease the transition with Evil. Either way, Emacs offers a different, better workflow.

Posted in General | Tagged | Leave a comment

Nick Higham’s Blogging Workflow

Nick Higham is a working mathematician so his blog has a heavy mathematical content and that means that he’s very concerned with integrating LaTeX into his workflow. Fortunately, that’s pretty easy because he writes his posts in org-mode and publishes them on a WordPress blog. That means he can embed the LaTeX in an Org file and when it get exported, it gets turned into the proper mathematical representation.

Higham has a short post on his blogging workflow. He uses org2blog as I used to do before the XML-RPC protocol stopped working with my hosting provider. Org2blog makes it really easy to write posts in Org and export them to WordPress in a single operation but he sometimes still needs to adjust the HTML to get the final result he wants.

His post is mainly useful for those who have a lot of mathematical content but anyone thinking of starting a blog could profitably take a look.

Posted in General | Tagged , | Leave a comment

Being More Productive with Emacs

Peter Prevos has an excellent series of beginner articles on being more productive with Emacs. The series comprises the following posts:

  1. Getting Started with Emacs
  2. Configure Emacs
  3. Distraction-Free Writing with Emacs
  4. Getting Things Done with Emacs
  5. Taking Notes with Emacs
  6. Create Websites with Emacs
  7. Writing Articles and Books with Org Mode
  8. Manage your literature with Emacs BibTeX Mode
  9. Manage files with Emacs
  10. Viewing Images with Emacs
  11. Read RSS feeds with Emacs and Elfeed
  12. Configure EMMS
  13. Using Emacs on a Chromebook
  14. Export WordPress to Hugo Markdown or Org Mode with R

There’s also a link to the configuration files discussed in the posts.

If you’ve got a bit of experience with Emacs, you probably won’t learn a lot from these posts but if you’re a beginner or know someone who is this series may be just the thing to get you started.

Posted in General | Tagged | Leave a comment

Getting a List of Open PRs from Github

Geoffrey Lessel is an Elisp n00b. Really a n00b. He’s not sure what the car and cdr of a list are and he doesn’t understand backquotes. But he’s not afraid to dig in and discover things as he goes along. He proves that by taking on a project that many would consider too difficult for a beginner: he wants to retrieve a list of open pull requests from Github so that he can select one and display it in his browser.

There are a lot of moving parts in that exercise. For example, you’ve got to connect to Github, deal with authentication, parse the returned JSON, extract the relevant information as a list, pass the list to a chooser function, and call your browser of choice with the URL for the chosen PR. All that might be a challenge for even an intermediate Elisper but Lessel shows how to approach the problem even if you’re not sure where you’re going at every step.

He does that by leveraging Emacs’ discoverability and exploratory programming. First he writes some code just to retrieve a bit of JSON from a site that doesn’t require authentication. He experiments with ways of parsing the JSON into a more convenient form and then extracting one of the values. Next he uses some of the auth-* functions to login into Github and retrieve the data he needs. Finally, he extracts a list of the PRs from the JSON that Github returned. He leaves the building of the choice list and calling of the browser to his next video.

This is a long video—almost an hour and 23 minutes—and a lot of time is spent just figuring things out. More experienced Elispers might get exasperated as he feels his way along but everyone can learn a lot from how he does figure those things out. You might even learn something new. For example, I learned about seq-doseq, a very useful generalization of dolist to arbitrary sequences. The next time you hear someone whine that Elisp is too hard to learn and use, point them to this video.

Posted in General | Tagged , | Leave a comment

Correcting Text Messages

A few years ago I used to joke that I was getting in touch with my inner teenager when I texted with SMS. These days, I text more often than I send email and Apple’s iMessage makes it easy to text from any of my devices.

One way that email is superior to texting is that it’s easier to send messages without typos or mistakes. My texts often have mistakes. About half the time that’s because autocorrection thought it knew what I meant better than I did. The other times it’s because it’s harder to type accurately on an iPhone or even an iPad.

Whatever the cause of the errors, I’ve often wished that I could edit a text after it was sent. People have evolved a number of ways of dealing with this. One popular method sends the corrected word with a * prepended. That’s too ambiguous for me so I use the ed substitution notation s/xxx/yyy/. That’s pretty much a standard notation in the programming world—Sed, Vim, and Perl all use it—so it’s well understood by all my technical interlocutors but, oddly, even my non-technical friends and relatives have no problem understanding it.

Wil Shipley has an interesting idea: build a text correction protocol on top of the ed/Perl/Sed commands. His idea is that email clients supporting the protocol would allow the sender to edit the erroneous text, which would, in turn, send the appropriate Sed command to the receiver’s client. The receiver’s client would redisplay the text in its corrected form along with an indication that it’s been corrected. The old, erroneous, text would be viewable by clicking on the corrected indicator.

The beauty of this solution is that it has a soft fallback for nonconformant email clients. On the receiver’s end it would simply keep displaying the original message followed by the Sed command. In other words, just what I and many others are doing now. If the sender doesn’t have a conformant client, they can simply send the Sed command manually—again, what many us are already doing—and the user of a conformant receiver will see it displayed as a corrected message.

This is a great idea and should be fairly easy to implement without unduly impacting current clients. I hope one of the big players picks it up and runs with it. As Shipley says, once one vendor implements it, the others will follow.

Posted in General | Tagged | Leave a comment

Whence COVID-19

Public health officials have seriously damaged their credibility with COVID-19 messaging. Many of the things they’ve told us have turned out not to be true. Some, such as their early advice on mask wearing, was a transparent lie that didn’t make sense even on its own terms. If you lie to me once, why should I believe anything else you tell me?

Now that we have a vaccine and the end of the epidemic seems in sight, it seems like a good time to ask where the virus came from. The received wisdom is that it came from bats via the Wuhan wet market. According to this theory, the virus made the jump from bats to an intermediate species, and then to humans. That’s how the SARS1 and MERS viruses did it. This theory is the one championed by the virologist community and some other public officials. And who should know better? Unfortunately, there are several problems with this theory.

The other major contending theory is that the virus escaped from the Wuhan Institute of Virology that was doing gain of function experiments on coronaviruses. That theory was immediately and emphatically disparaged by the virology community, most public heath authorities, and the press even though such leaks are frighteningly common. No evidence was adduced to justify this dismissal. Instead, they authorities simply said it was ridiculous and a conspiracy theory.

If you have a scientific or even a skeptical bent, these denials should be raising a red flag. They don’t sound scientific, they sound political. Irreal doesn’t take any position on the matter because, like most of you, I don’t have the domain knowledge to make an informed decision. Fortunately, Nicholas Wade has a careful and exhaustive article that considers the evidence. The TL;DR is that there’s no definitive evidence either way but that what there is argues heavily for a leak from Wuhan labs.

Wade’s articles seems to me an honest recitation of the facts. It doesn’t reach a firm conclusion but provides sufficient evidence for you to draw your own.

Posted in General | Tagged | Leave a comment

Red Meat Friday: Y2K Redux

It’s been a while but many of us still remember the problems, hype, and really bad movie centered around the Y2K bug. For you kids, that was a problem caused by the common practice of storing the year of dates as YY instead of YYYY. It saved a couple bytes (or characters) per date and not that long ago storage was hideously expensive so it seemed like a good tradeoff. Until the year 2000 loomed bringing the threat of financial system shutdown due to failing software.

In the end, it turned out to be pretty much a nonevent due, in part, to heroic efforts to get all that software fixed before the new millennium. Everyone gave a huge sigh of relief and software engineers promised themselves that they’d never make that mistake again. Except.

To be fair, this problem was a little less predictable than Y2K but notice that once again there was a lack of concern until disaster was imminent. Maybe we didn’t learn the Y2K lesson as well as we thought.

Posted in General | Tagged | Leave a comment

Git With Solo Projects

Over at Fosslife, V.M. Brasseur considers the question of why you should use Git, or some other version control system, for your solo projects. Brasseur was shocked when one of her coworkers expressed surprise that she used Git even for personal, one-developer projects. I do the same thing. I check virtually all my work into Git and have for many years.

But why would you do that? Brasseur gives seven reasons to use Git on solo projects. The TL;DR of her reasons are:

  1. Syncing between computers so you can work on the project from any of your computers.
  2. Backup (especially with an offsite repository).
  3. Being able to backtrack to previous versions for debugging.
  4. Organizing your data by putting it in known places.
  5. Code reuse.
  6. Issue tracking.
  7. No project is really solo. Future-you will appreciate the project history.

Those are all good reasons but the real question is: why wouldn’t you version control your work? It doesn’t really cost anything other than a little extra, increasingly cheap disk space, and can really save the day when you need to dig into the project’s history.

Posted in General | Tagged , | Leave a comment