Some Technical Details on AWK

Many of you know that I’m a big fan of AWK. After Lisp and C, it’s my go to language, especially for scripts that involve reading a bunch of lines and performing some sort of regex-mediated action on them. Its language is basically C-like but there are some anomalies that can seem mysterious.

Volodymyr Gubarkov has a project to provide an InteliJ plug in for AWK and part of that requires parsing AWK syntax so he has a good handle on those anomalies and why they exist. He discusses those peculiarities in his post, AWK technical notes.

It’s an interesting post that explains many things that you probably didn’t know about AWK. In a way, it’s getting into the weeds but it also increases your understanding of the way things work and allows you to write better AWK.

For example, one thing I didn’t know was that although it’s illegal to have a space between a user defined function and its argument list, it is legal to have a space between a built in function and its argument list. The reason for that involves string concatenation. Take a look at Gubarkov’s post for the details.

The post mentions some other interesting anomalies in the AWK syntax and the reasons for them. If you use AWK, it’s definitely worth reading the post if only to be aware of the gotchas waiting for the unwary.

Posted in General | Tagged | Leave a comment

Stacks, Heaps, and Recursion

Even before I learned Lisp, I really loved coding with recursive algorithms. When I decided to learn Lisp, I did so through Paul Graham’s ANSI Common Lisp, which meant, of course, that recursive programming became part of my programming DNA.

A significant part of my Lisp journey involved Scheme where recursion is the go to mechanism for most looping constructs. That’s because the Scheme standard mandates tail call optimization so that recursion is no more expensive in time or memory than any other looping mechanism. Not all languages or even all compilers for a given language support tail call optimization so a prejudice against recursion has emerged. The problem, according to this prejudice, is that recursion can lead to stack space exhaustion.

Tim Bradshaw examines this prejudice and dismisses it for the silliness it is. According to Bradshaw, there’s a deep-seated belief among programmers that stack space is a scarce, valuable resource while heap space is essentially free and unlimited. This leads to a preference for implementing inherently recursive procedures in an interactive way that involves managing the stack explicitly in the heap rather than using recursion and managing the stack implicitly.

As Bradshaw points out, the stack and the heap are both just memory and neither is more expensive or scarce than the other. There’s no reason to restrict stack space while allowing large heap spaces other than convention and it’s time for us to reexamine this prejudice. It’s hard to argue; Bradshaw has a point.

Posted in General | Tagged | Leave a comment

Let Them Eat Cake

Grrr. I had my blood pressure taken today and it was perfectly normal. Then I read this Slate article and it shot through the roof. Or so I imagine. I know for sure that it infuriated me. In the article, Ben Mathis-Lilley discusses the views of Steve Rattner on remote work.

Rattner, an “investment asset manager” and on-again/off-again politico, is complaining about all those remote work riffraff who simply don’t want to work as hard anymore and would rather goof off at home. He quotes Marc Benioff, CEO of Salesforce, Meta’s Mark Zuckerberg, and JPMorgan’s Jamie Dimon to support his thesis that remote workers have grown soft, and no longer want to hustle. The reason they feel comfortable with this, Rattner says, is the remarkable growing prosperity “we’ve” experienced in the last few years.

Mathis-Lilley puts the lie to this nonsense and then burns it to the ground. It’s fine, he says, to talk about this remarkable growth in prosperity as long as you are in the top 1% or, better, top 0.1% of earners. If you’re anyone else, not so much: your earnings have been essentially flat.

In order for the great unwashed to commute to work it costs about \$6,000 a year and if they have 2 or 3 children another \$40,000 a year in child care. That’s a lot of money for someone with no real increase in income. Rattner, on the other hand, lives 10 minutes away from work (in Manhattan) and could easily walk to work if he liked.

As the title suggests, Rattner and his ilk really are like Marie Antoinette in their inability to comprehend the problems that commuting to the office imposes on the average employee. If you have a nasty, suspicious mind like mine, you’ll also suspect that the main driver of their back-to-the-office crusade is really about wanting to control every second of their employee’s life, or at least of their workday. But probably life.

Posted in General | Tagged | Leave a comment

Eli Zaretskii Wins FSF Award

The Free Software Foundation has announced that Eli Zaretskii, the de facto lead Emacs developer, is the winner of the Award for the Advancement of Free Software. It’s well deserved and I offer him my wholehearted congratulations.

Zaretskii has provided exactly the quiet, steady leadership that the project needs. He devotes huge amounts of time to Emacs for free and we should all be extraordinarily grateful. The award is the least the community can do for him and I’m glad he received it.

Congratulations, Eli; the award is well deserved.

Posted in General | Tagged | Leave a comment

Adding A Thesaurus To Emacs

Marcin Borkowski (mbork) has been doing more writing lately and has felt the need for a thesaurus. I very seldom use a thesaurus for reasons that I’ve written about previously but it’s sometimes convenient to have one. My typical use case is to avoid reusing the same word too often in close proximity. A thesaurus is good in that situation because I’m just interested in finding an alternative word, not shades of meaning.

Borkowski is trying to decide between two thesauruses, le-thesaurus and mw-thesaurus. Le-thesaurus provides a simple list of synonyms from which you can choose and it will automatically replace the word at point. Mw-thesaurus presents a nicely formatted buffer that gives synonyms and information about shades of meaning. It’s much more comprehensive than le-thesaurus but doesn’t automatically replace the word at point.

I have two thesauruses installed: mw-thesaurus and power thesaurus. Power thesaurus operates much like le-thesaurus but uses a community sourced thesaurus. I almost always use power thesaurus because it best fits my default use case and because when I want shades of meaning and context I turn to Websters 1913, most recently through the newly built-in dictionary-search.

Another problem with mw-thesaurus that I didn’t know about until I read Borkowski’s post is that it globally sets org-hide-emphasis-markers to t, which hides all Org emphasis markers in all buffers. That’s not something I want, and I’ve occasionally noticed it happening in the past but I didn’t know why. Borkowski solved that by editing the source code but perhaps there’s a better way.

Regardless of which one(s) you install, it’s often handy to have a thesaurus available without having to leave the comfort of Emacs. Any of those discussed here are fine and there are doubtless other good ones.

Posted in General | Tagged , | Leave a comment

Emacs and LLMs

It seems as if every second technical article or tweet that I read is about Large Language Models (LLMs) and, in particular, the various iterations of ChatGPT. In response to this, there are already several Emacs packages providing an interface to ChatGPT.

Over at the Emacs subreddit, ahyatt argues that Emacs is the best platform for LLMs. The main reason for this, he says, is that the primary thing you want ChatGPT to do is integrate with your writing environment and Emacs excels at this. Furthermore, with Emacs, this integration is universal: You can use it with code, documentation, technical papers, emails, and just about any other type of writing.

Ahyatt also mentions that it’s often useful to provide context with a ChatGPT prompt and Emacs makes this easy to do. He goes on to speculate on other advanced use of ChatGPT and how they can be easily enabled with Emacs. Take a look at his post for the details.

Whether or not ChatGPT is the long awaited—or dreaded—revival of serious AI, those who want to experiment with or work on LLMs need a platform from which to do so and as ahyatt argues, Emacs is an excellent choice for that.

Posted in General | Tagged | Leave a comment

Org Novelist

As many of you know, I’m fascinated by those who use Emacs for projects that don’t involve science or engineering. One such aspect that I always enjoy reading about is using Emacs for creative writing, by which I mean novels, short stories, poetry, and the like.

That may seem like an edge case but there are plenty of writers who write their novels with Emacs, including such A-list writers as Vernor Vinge and Neal Stephenson. There’s little reason to wonder why. Emacs has superb editing and linking capabilities that makes writing and organizing a piece of prose easier than it would be with most other writing platforms.

John Urquhart Ferguson is another writer who uses Emacs and he’s written a package, Org Novelist, to make the note taking and story organization easier. A full-blown novel can have several minor characters and locales that are hard for the author to keep track of. Similarly, ideas may occur to the author that don’t involve whatever part of the story is currently being worked on and a way of capturing those notes is needed. Ferguson’s package is intended to help with that. Best of all, the package let’s you write your prose in Org mode.

Ferguson has a short announcement on reddit but to really get a feeling for what the package is about and what it can do, take a look at the README on his GitHub repository. The package is not on MELPA or any of the other package repositories so you’ll have to download it from GitHub.

Ferguson stresses that the package was written for his own use with his particular workflow but he’s releasing it in case others find it useful. From the README, that seems likely to me so if you’re interested in a package to help you with your creative writing, take a look.

Posted in General | Tagged , | Leave a comment

Curl and Its Developer

This is the twentyfifth anniversary of Curl, one of those quiet utilities that everyone uses but that never makes a big splash. Along with wget, Curl is one of the two premier standalone applications for downloading content from the Web.

Its 25th anniversary is reason enough to give Curl and its developer, Daniel Stenberg, a shout out but there’s an even better reason: hardware setup porn. The Hackers Stations site has a page on Stenberg’s home office and the kit he uses. He’s a full time open source developer who works from home so it’s obviously important that he has a comfortable and efficient setup. Another reason Stenberg deserves an Irreal shout out is that he’s an Emacs user.

There’s no real point here, of course, but if you’re like me, you take voyeuristic pleasure in seeing other people’s setups. Working on a cross platform application, as he does, Stenberg has machines running Linux, Windows, and macOS so his setup is pretty complete. The page even describes all the knickknacks on his desk.

Definitely worth a couple minutes of your time if you enjoy seeing how other developers work.

Posted in General | Tagged , | Leave a comment

State of Doom Emacs

There’s a JUXT Safari video featuring Ellis Kenyo on the state of Doom Emacs. It’s not really an introduction to Doom but, rather, a status report on where Doom is now and what new things are being worked on.

I’m a complete innocent as far as Doom is concerned. I’ve never tried it and the main thing I know about it is that it has a large and dedicated userbase. Even so, the video was informative and gave a reasonable summary of what the project is about and how things works. One sort of un-Emacsy thing about the package is that certain administrative functions are performed outside Emacs. That, of course, is an anathema to us hardcore “everything in Emacs” fanatics but, again, I have no experience with it so I don’t know what it’s really like.

As a side issue, the Minions are insisting that I point out Kenyo’s Emacs theme is a prime example of everything that’s wrong with dark themes. It features the horrible and unreadable dark gray and dark blue on black that I described in a recent Red Meat Friday post. It’s too bad because, at least for my aging eyes, it makes it impossible to read the examples and configuration that Kenyo offered.

Regardless, the video is interesting and useful. It runs for 31 minutes, 25 seconds so you’ll need to set aside some time.

Posted in General | Tagged | Leave a comment

Ritchie’s Thesis

There’s a substantial body of lore associated with Dennis Ritchie and his work. One of the minor stories involves his PhD or lack of it. The most common story is that Harvard refused to award Ritchie his degree because Ritchie objected to paying a thesis binding fee. I’ve always accepted that story but it never made sense to me. Having gone through the process and pain of writing a PhD thesis myself, I can’t imagine giving up the prize over a triviality. But, of course, Ritchie was unique in many ways.

That story—right or wrong—is the least of the mysteries around his thesis. A recent paper by Brailsford, Kernighan, and William A. Ritchie examines the mystery of how Ritchie “typeset” his thesis. The scare quotes on typeset are because this was in 1968 and the only realistic way producing hard copy for a thesis was with a typewriter. But the extant copies of the thesis, which was highly mathematical, has aspects which seem impossible to produce with a typewriter. It is in any event a tribute to Ritchie’s attention to detail.

Brailsford, of course, has a video about the mystery but to really understand what an astounding feat accomplishing the typesetting was, you need to read the paper. Note, especially, how Ritchie centered the Roman numerals on his lists. Brailsford and Kernighan are experts on this sort of thing and even they can’t figure it out.

William Ritchie is Dennis’s brother and has a website on the mysteries of his brother’s thesis. It’s also worth looking at.

To really understand what’s going on and why the physical presentation of the thesis is so astounding, you definitely should read the paper. It’s 10 pages but very interesting. The paper and the mysteries it examines tickles the intersection of several of my interests and I really enjoyed it. If you’re interested in this sort of thing, perhaps you will too.

Posted in General | Tagged | Leave a comment