Literate Programming with Org Mode

Justin Worthe had a nice addition to the articles on literate programming and Org mode. It is, I think, a pretty balanced treatment of the benefits and disadvantages of literate programming. On the one hand you have the usual advantages of integrated documentation that goes beyond source code comments. That can yield large benefits for the programmers who end up maintaining the code and even for the original author 6 months later. There is also, as Worthe points out, the related field of reproducible research, which is I think, the premier application of the literate programming idea.

On the other hand there is the tricky matter of collaboration. It’s certainly the case that literate programming works best—or at least is easiest—for individual efforts but most work isn’t like that so it’s important to take collaboration into account. The problem is that engineers and scientists are fussy about their tools and it’s likely that the team members don’t agree on what those tools should be. That’s especially true when you’re talking about Emacs and Org mode.

Worthe has some suggestions about solving the collaboration problem but none of them are wholly satisfactory. The best suggestion is to use something like CWEB or NOWEB but they don’t have the same excellent tooling as Org mode and, of course, CWEB requires you to be working in C. For example, I could never warm up to CWEB but Org mode with code blocks seems natural to me and offers the same advantages.

For a large number of problems, literate programming can be a real win but it’s not without its challenges.

Posted in General | Tagged , , | Leave a comment

Things You Can Do With Regular Expressions in Emacs

Back in January, John D. Cook wrote an excellent post on the ways you can use regular expressions in Emacs. You’re probably familiar with most of them but there might be a couple of surprises in his list.

He looks at five main categories:

  • Searching and replacing
  • Purging line
  • Aligning code
  • Directory editing
  • Miscellaneous

but most of those consider several commands.

The use of regular expressions is endemic in Emacs. As Cook note, 15% of the pages in the Emacs manual mention them. Emacs regular expressions are often criticized for non-standard syntax and a lack of features but you certainly can’t complain that Emacs doesn’t make wide and appropriate use of them.

Posted in General | Tagged | Leave a comment

Setting the Line End Convention

Wilfred Hughes has tweeted another great Emacs Command of the Day:

You can follow the link in the tweet for a bit more information but the TL;DR is that unless you have special needs, you should be seeing U: as the first two characters of your mode line. The U means that the encoding is UTF-8 and the : means that lines are terminated in the Unix way with a newline character.

You can click on the : to cycle through the other possibilities but these days you probably want either : or DOS.

And who knew Ctrl+x Return was a valid command prefix? The completions all have to do with setting various encoding options.

Posted in General | Tagged | Leave a comment

Open Office Means Less Openness

My first draft of this post started with a righteous rant about the attempts of management to justify open offices with talk of increased communication and collaboration. It was gratifying to write but probably wouldn’t be as amusing to read. Nevertheless, I had a point. There’s no longer any excuse for that excuse: many studies have debunked it.

Now Cal Newport posts about a study that shows that open offices actually decrease collaboration and employee interaction. Some are expressing surprise but it’s really obvious when you think about it. Imagine you’re an engineer or some other type of “thought worker” working in an open office. You have to concentrate on the task at hand but there’s all this noise and disruption going on. What do you do? You put on your earphones, crank up the volume, and retreat into your private place. You’re not communicating, you’re not collaborating, you’re doing your best to block out those around you.

The study reveals that workers in an open office spend an astounding 72% less time interacting face-to-face after shifting from a conventional office configuration. In the study, face-to-face interaction dropped from 5.8 hours to 1.7 hours per day. At the same time, digital communication increased: more emails and more IMs. Revealingly, the management of the group studied reported that their own metrics for employee effectiveness had decreased too.

As Newport says, this is just one study of 52 employees but the results are so much what you’d expect that it would have been surprising if they had found otherwise.

If you’re a manager, please stop the madness. Your employees and bottom line will thank you.

Posted in General | Tagged | Leave a comment

Helpful Revisited

About a year ago, Wilfred Hughes introduced the Helpful package. The idea was to enhance the Emacs built-in help function with context and additional information. Now Hughes revisits Helpful and talks about its new features.

You can checkout Hughes’ post for the details but a couple of features are worth mentioning. He’s evolved Helpful into a sort of interface console from which you can set variables and trace or debug functions. He’s also improved the formatting and added additional useful information.

I meant to give Helpful a try when it was first introduced but I never got around to it. Hughes’ new post has encouraged me, again, to give it a go. If you use Emacs help a lot, you should definitely read Hughes’ two posts and perhaps give Helpful a spin. It’s on MELPA and MELPA stable so installation—if only on a trial basis—is easy.

Posted in General | Tagged | Leave a comment

The Genesis of Grep’s Name

Virtually everyone in our profession knows about grep and how to use it. But do you know where the name came from? If you’re old enough to remember the pre-Linux days you probably do. If you’ve never worked on a Unix (as opposed to Linux) system you may never have heard the story and even if you did, you probably didn’t have the context to understand the answer.

The excellent <computerphile> series has a great short video in which Brian Kernighan explains the genesis of the grep name. When you watch the video, you’ll see what I mean about “context.” To really understand the name you have to have at least a passing familiarity with the ed editor.

In a way, the most interesting aspect of the video—at least for the greybeard contingent—is the comments. I would have thought, before reading them, that virtually everyone in our field knew, at least generally, where the name came from. That is decidedly not the case. Many of the commenters expressed delighted surprise to find out the answer. One even admitted that he’d always assumed the ‘g’ stood for GNU. That’s not an unreasonable assumption if you grew up with Linux but grep comes from the early 1970’s (it first appeared in Version 6) so it was born and named long before the GNU project was conceived.

Everyone will enjoy the video—it’s only 10 minutes—but if you’re a younger developer and don’t know this stuff, it’s especially important to watch it. This is part of our heritage and it’s important that you help keep the knowledge of it alive.

Posted in General | Tagged , | Leave a comment

Org Unfolding Tip

From Thierry Stoehr we have this excellent tip on unhiding all the data in an Org file:

Posted in General | Tagged , | Leave a comment

Learn a Little AWK

It used to be that almost every programmer was proficient with AWK. When Perl came along, that became less true and now many programmers have never used—or even heard of—AWK. That’s too bad because it’s a tremendously useful tool and, in my opinion, much easier to learn and use than Perl. Although it’s possible to write reasonably complex applications in AWK it really excels in short, simple text manipulation.

Greg Grothaus (via Wilfred Hughes) has a nice post, Why you should learn just a little Awk, that demonstrates some simple AWK manipulations. His examples are very elementary and don’t begin to exercise the full power of AWK. Still, they give you the flavor and should encourage you to learn a bit more.

The definitive source is, of course, Aho, Kernighan, and Weinberger’s The AWK Programming Language. If you’re serious about learning AWK, that should be your go-to source. There’s also Eric Pement’s HANDY ONE-LINERS FOR AWK and Jonathan Palardy’s four-part AWK tutorial. The latter two resources build on Grothaus’ tutorial and will likely give you everything you need to know for everything but the most serious AWK applications.

Posted in General | Tagged | Leave a comment

ESC ESC ESC

Emacs Command of the Day offers a tip that, oddly, a lot of people don’t seem to know about:

I usually use it after trying Ctrl+g and right before sending a SIGUSR2 signal.

I didn’t realize the part about closing the minibuffer but that’s probably why it often works for me.

Posted in General | Tagged | Leave a comment

Apple’s New Maps

Way back in 2012, I wrote about Apple venturing into maps and the problems they were having. As I said at the time, getting good map data is extraordinarily hard—Google at the time had over 7,000 people working on their data—and it was going to be some time before Apple could catch up with Google.

That time, it appears, has come. Tech Crunch has a fairly long article reporting that Apple is rebuilding Maps from the ground up. Like Google, they have built new tools and assembled a large team to gather the data needed for a world class mapping application. After 4 years work, Apple is expecting to release their new maps for the San Francisco and Bay Area with iOS 12. Other areas will roll out over the next year.

Being Apple, the company has built in privacy from the beginning. No person ever sees the unsanitized data containing license plate numbers and faces: The data is encrypted as it’s gathered and the key is held by software that scrubs the privacy violating objects from it.

The other Apple-like feature is the attention to detail. Maps in Japan show more detail at an intermediate zoom level than a corresponding map in the U.S. would because that’s what the two cultures expect. Apple even licensed the fonts used by, say, the NY subway system so the signs on the maps would look the same to users. There are other examples as well. Read the article for the details. Even if you aren’t an Apple user, the article is an interesting discussion of the technical problems Apple has had to solve in building their new maps.

Posted in General | Tagged , | Leave a comment