More and more often, these days, I see the opinion expressed that C is a dead, dangerous, stupid language and no one uses it anymore. For me, that's like having someone start a discussion by saying ”As everyone knows the earth is flat…” I stop paying attention because I'm pretty sure that this person doesn't know what they're talking about.

Of course, it could be just another example of “Kids, today” and a longing for the way things were. I was therefore very happy to see this post by Ozan Onay on why it's still important for young engineers to learn and be fluent in C. He gives four reasons for this:

  1. If you get away from the Web App startup culture, C is one of the most commonly used languages.
  2. C influences the design of most modern languages.
  3. C helps you think like a computer.
  4. Most tools for writing software are written in C (or perhaps C++).

Onay looks at each of these reasons and gives some possible objections to them. In the end, he settles on number 4 as the most compelling of them. I disagree with that last assessment. To me the most important thing—and reason enough to learn C—is that it helps you think like the computer.

Assembly language is even better for that but that ship sailed long ago. When I code in any language I find that I always mentally translate what's going to happen into C. C is close enough to machine language that you can get a good idea of how fast something is going to run and how much memory it's going to require. It takes a while to develop that facility, of course, but I don't see how you can be a first rate software engineer without it. Otherwise, all you're doing is reciting magic spells that you don't understand except to the extent you know the result they'll produce.

Or I could be just an old fool babbling on and on about the old days. But I don't think so.

Posted in Programming | Tagged | Leave a comment

A Video Tutorial for undo-tree

The other day I wrote about undo-tree and wished for a video on how to use it. Mike Zamansky came to the rescue with a very nice video expanation of undo-tree. Really, this package is extraordinarily useful and it's nice to have an easy way to get started.

For me, at least, seeing the video helped illuminate some of the dark corners. Others, I know, would rather read an explanation and for them the nice commentary that I mentioned in the original blog post is the place to go. If you like to see things actually happening, you should definitely take a look at Zamansky's video. It's the 16th in a series of useful Emacs tutorials that he's done. They're all worth watching so take a look when you get a chance.

One interesting thing that Zamansky mentioned that I hadn't considered is that you really don't need redo—although that is much improved with undo-tree—because you can simply use undo-tree-visualize (bound to Ctrl+x u) to move down the undo tree to redo as much as you like. That's a subtle but very useful point.

My advice is to watch Zamansky's video and then read the commentary (or vice versa if that makes more sense for you) and you should be able to start using undo-tree efficiently. It's definitely a package you want.

Posted in General | Tagged | Leave a comment

Stop Emacs from Writing package-selected-packages into init.el

A new minor annoyance in Emacs 25.1 is that Emacs maintains a variable called package-selected-packages that maintains a list of packages that you have specifically specified. This is used to handle dependencies on package deletion as well as making it possible to port your package configuration to multiple machines.

Here's the problem: Emacs writes that variable into the custom section of your init.el (or .emacs). That means that configurations on different machines can diverge making syncing (say through Git) harder. Also, I don't like anything in the configure section. I want everything my init.el does specified by me not by configure.

Happily, there are a bunch of solutions to this. One of the easiest—and what I've chosen to do—is to specify a separate file for the configure data. You can load this file or not but at least it stops Emacs from messing with your init.el. There are some other solutions as well, so be sure to follow the link.

Posted in General | Tagged | Leave a comment

The Wages of Sin

Posted in General | Tagged | Leave a comment

Hide Files in Dired Listing

I like to see all files in my Dired listings but lots of folks have a more minimalist mindset and would prefer not to see certain files. Things like backup files, .DS_STORE (on MacOS), or even all dot files are examples of files you might find uninteresting.

If you're in the latter class of Emacs users and you're using Dired-x (which you really should be) you can easily prevent certain files from appearing. You can specify files to omit by either regexp or by extensions. Check out this reddit Emacs post for the details.

Posted in General | Tagged | Leave a comment

Visualizing Your Undo Tree

I've been using undo-tree for a long time but mostly I just take advantage of it's (very much improved) redo functionality. The other day, I saw this tweet

which inspired me to try to learn a bit more about undo-tree's features. The first thing, as suggested by the tweet is that you can step through the undo tree and your buffer will reflect the buffer state at that point in the undo tree. Once you get the buffer to the desired state, you can make that the current buffer or you can save that state to a register for later retrieval.

The main problem with undo-tree is that it's feature rich and a bit hard to figure out how things work. Fortunately, there's a long commentary at the head of the source file that serves as a tutorial. If you read through that once or twice you'll have a good idea of what it can do.

What undo-tree really needs, I think, is a good video tutorial. Emacs Gifs has a short video on undo-tree-visualize but it doesn't really show the power. I vaguely remember Magnar Sveen discussing it but I don't think it was one of the Emacs Rocks videos. Mike Zamansky sometimes stops by Irreal; perhaps he'll put it on his list of future Emacs videos. Sadly, I'm neither set up nor temperamentally suited to do the video so consider this a shameless attempt to get someone else to do the heavy lifting.

UPDATE [2016-10-06 Thu 19:42]: Fixed link to Emacs Gifs.

Posted in General | Tagged | 5 Comments

Some Helpful Reminders and Advice

If you're running a tech company, Christopher Soghoian has a helpful reminder for you:

I'd just add that you can be sure that it will leak eventually and your company will take the hit. The government will continue as before hardly noticing the bump as it runs you over.

If you're a Yahoo user, Edward Snowden has some useful advice for you:

Just as you should have stopped using Microsoft products when it became clear they couldn't be trusted, you should dump Yahoo immediately. If you want an idea of how badly Yahoo betrayed your trust, take a look at this Ars Technica article. Say what you will about Google and Apple, both said they would have unequivocally refused such a request. Here's Apple's statement:

Posted in General | Tagged | Leave a comment

Problem Applications in eshell

If you're like me and try to stay in Emacs as much as you can, you have probably tried eshell. It's a nice Emacsy shell (Mickey has an excellent eshell tutorial you should check out) but can sometimes have problems with applications that do direct cursor addressing.

It turns out that it's easy to teach eshell to run such applications in a term buffer so that things still work. The most common examples of such apps are less and top (at least for my workflow). All you need to do is tell eshell to treat these applications specially and everything works just fine.

The TL;DR is that you should read Mickey's tutorial and set eshell-visual-commands to run problem applications in a term buffer.

UPDATE [2016-10-04 Tue 14:33]: At least in Emacs 25, it turns out that eshell-visual-commands is already defined to a reasonable default list. You may want to add to it for other problem applications that you discover.

UPDATE [2016-10-05 Wed 12:07]: shell –> eshell

Posted in General | Tagged | 3 Comments

Move Text

If you're the type of writer who likes to move text around as you edit, you might find this Emacs package helpful.

I like how you can specify a region and then move the whole thing. Sure, you can highlight the region, kill it, and then yank it back at the new location but move-text lets you move it around at will and try different locations.

If you use Emacs strictly for coding, you may not find move-text useful but if you're writing papers, reports, novels, or some other type of creative writing, it may be just what you need.

Posted in General | Tagged | Leave a comment

Searching for Words with eww

Wilfed Hughes offers an excellent tip

You can highlight a region in an Emacs buffer and invoke eww to search for the text in that region. I like it because I'm not forced out to a browser; everything stays in Emacs. The search engine is, of course, configurable. It will use whatever you have eww configured (via eww-search-prefix) to use.

Posted in General | Tagged | Leave a comment