An Application of Org-element

The other day, I saw this query on the reddit Emacs subreddit. I
already have solutions for this type of problem but I’m always
interested in the how people use Org mode to record and report data so
I followed the link that primitiveinds provided for his solution to
generating time reports.

Even if, like me, you already have your time tracking and reporting
needs under control, primitiveinds’ solution is worth looking at for
its own sake. It works by looking for CLOCK entries in an Org buffer
and accumulating the relevant information in the CLOCK line as well
data about the associated task. That might seem like it would require
routine but tedious text manipulation but primitiveinds leverages the
org-element functionality to easily handle the task.

He starts by calling org-element-parse-buffer to generate a tree
representation of the Org buffer. Then he uses org-element-map to
examine each CLOCK element (and only CLOCK elements) to extract the
necessary information. It’s a great technique that can easily be
adapted for other parsing of Org data. The code that primitiveinds
presents is easy to follow and he provides a nice explanation of what
it’s doing.

If you need to programmatically examine Org data for further
processing, you should take a look at primitiveinds’ post. It’s
definitely worth a read.

Posted in General | Tagged , | Leave a comment

SBCL 1.4.6

Most of my Lisp programming lately has been in Emacs-lisp so it’s been
a few months since I’ve used Common Lisp. The other day, though, I
noticed that Version 1.4.6 of Steel Bank Common Lisp (SBCL) had just
been released so I decided it was time to upgrade SBCL and my
Quicklisp library.

As usual, the upgrade completed without incident and the regression
tests—which I always run with an upgrade—completed with no unexpected
errors.

It’s always a pleasure to work with SBCL and, of course, with Slime I
can do so from within Emacs. If you like Lisp and want to try out
Common Lisp, I unreservedly recommend SBCL. It’s an industrial
strength Lisp system that’s actively maintained and works seamlessly
with Emacs. It’s easy to install and update so there’s no reason not
to give it a try.

Posted in General | Tagged , | Leave a comment

C++ and Pointers

The other day, I wrote that C++ is not my favorite language and that
it’s eliminated most of what’s useful about C while retaining most of C’s
disadvantages. Then I saw this post, which says that the 2018 C++
committee is planning the deprecation and later removal of pointers
from the language. My immediate thought was that that proved what I
wrote.

Of course, the post is almost certainly an April Fools joke but here’s
the thing: No one seems to be sure. There’s a long discussion over at
Hacker News where half the commenters are sure it’s a joke and the
other half are convinced it’s true. I asked DuckDuckGo and it didn’t
know either.

It speaks volumes about the language that this should be so. The
language is so full of cruft and has made so many dubious decisions
that knowledgeable people can’t decide if this is another dubious
decision or a joke even though the discussion is happening on April
first.

I’m sure lots of Irreal readers have coded in
C++—I’ve coded in C++—and many of them
probably like the language but its appeal escapes me. These days there
are better alternatives for almost any project so it baffles me that
folks continue to choose C++. No doubt that’s begging to be ruthlessly
schooled on why folks do choose C++ but that’s part of what make the
Irreal community so much fun.

Posted in General | Tagged | Leave a comment

Back to RSS

Lately, I’ve noticed a renewed interest in RSS. The reasons for that
are not hard to understand. As yesterday’s post made clear, social
media has become a toxic wasteland interested only in collecting the
intimate details of our lives and selling them to their real
customers, the advertisers.

The driving force behind the movement back to RSS is the belief that
“news” obtained from social media is over processed white bread
rendered mostly useless by questionable algorithms and adulterated
with advertiser sponsored “content.”

Wired has an article on the return to RSS that considers the major
practical question about that return: what should I use as my RSS
reader? It used to be that for most people the easiest answer was
Google Reader. Then, of course, Google killed the product leading many
to predict the death of RSS and, as a consequence, blogs. Happily
neither of those predictions came true but that still leaves the
problem of what to replace Google Reader with.

If you’re an Emacs user, I can’t recommend Christopher Wellons’ Elfeed
enough. It’s very flexible and runs right in Emacs. Mike Zamansky has
an excellent three-video series on it (1, 2, 3) if you want to see it
in action and how you can customize it.

Before Elfeed, I used Feedly and really liked it. It runs in your
browser so you don’t need to worry about a separate application. I’d
still be using it except I wanted to move my RSS reading into Emacs.
If you’re not an Emacs user or don’t want to use it for reading RSS,
Feedly is an excellent choice.

The Wired article talks about other readers as well. It’s an
interesting article and provides insight into the reinvigorated
interest in RSS. Definitely worth a read.

Posted in General | Tagged , | Leave a comment

Enough Is Enough

I’m not on Facebook. I’ve never been on Facebook. At first it was
simply a matter of not being a 14 year old junior high schooler.
Later, even adults started hanging out there but I still thought it
was silly and exhibitionist. That makes me an outlier, I know, but it
turns out I was on to something, if only fortuitously.

By now, almost everyone knows about Cambridge Analytica and their use
of Facebook data, supposedly to influence the election. But as Karl
Voit says, the issue isn’t Cambridge Analytica but Facebook.
Collecting and selling your data is their business plan and that’s
exactly what happened with Cambridge Analytica. Despite their demurral
and professed distress at what happened, Cambridge Analytica’s use of
the data was, in fact, well within Facebook’s guidelines and
apparently not uncommon.

Voit goes on to explain that Facebook collects that data whether or
not you agree to the collection and, according to others, even if you
aren’t on Facebook
. Worse, you can’t delete the data. When you try,
it’s no longer visible on your Facebook page but Facebook still has it
and still sells it to anyone willing to pay.

If you want to be horrified, take a look at this tweet thread (click
on the tweet to see the whole thread) that details the type of data
Facebook and Google collect about you:

If that doesn’t scare you, how about the fact that Facebook captured
and retained the phone detail logs
from users of their mobile app?

As Bruce Schneier points out this problem is pandemic. There’s no
longer any excuse. You can wait and hope someone else or the
government solves the problem or you get off Facebook and stop using
Google. Or you can continue to let them collect your most intimate
data and sell it to anyone interested.

Posted in General | Tagged | Leave a comment

A C++ Configuration for Emacs

If you’ve been around for a while, you know that I don’t think very
much of C++. It has all the disadvantages of C while managing to lose
what makes C worthwhile. Others disagree, of course, and in any event
may be required to use it for some or all of their projects.

If you’ve got to use C++, you might as well use Emacs to lighten the
load. (Yes, I’ve heard of Visual Studio: not in this lifetime.) The
problem is that it’s tricky to make a good configuration for C++. When
I see one that looks interesting or useful, I usually write about it
for those who choose to or must use C++.

Nils Deppe not only uses Emacs to write his C++, he’s been doing it in
terminal mode, which he prefers. Lately, he’s been experimenting with
using the GUI version—why wouldn’t you: it’s almost always superior—so
that he can edit Jupyter notebooks from within Emacs. Because of this
and because he was fed up with RTAGS, Deppe has rewritten his C++
configuration
.

He works on a laptop so he’s strived for speed and good battery
performance. His post has some animated gifs that show things in
operation. He also included a link to his Emacs configuration so you
can see exactly how he’s set things up. If you’ve been looking for a
decent C++ configuration for Emacs, you should take a look at Deppe’s
setup. It may be just what you’ve been searching for.

Posted in General | Tagged | Leave a comment

The Right Tool for the Job

On the The Unix Heritage Society mailing list, someone started a
thread commemorating the death of John Backus, who, in addition to
inventing the Backus-Naur form, lead the team that developed the
original FORTRAN. Someone else made a disparaging remark about FORTRAN
and that precipitated a long discussion of the good, the bad, and the
ugly of FORTRAN. Most people who’ve never used FORTRAN—and many who
have—aren’t aware that except in strings and a couple of other places,
blanks don’t affect the syntax and can be omitted. I recall once
looking at a FORTRAN compiler where the first thing it did after
reading a card image was to eliminate all the blanks.

Steve Johnson, the inventor of Yacc, the Portable C Compiler, and
Lint, offered a funny story about FORTRAN and blanks at Bell Labs. His
post is worth reading as an interesting piece of Bell Labs history but
what struck me was how the choice of the right tool for a job enabled
Johnson to complete a task much more quickly than even the world-class
engineers and computer scientists at the lab expected.

The TL:DR is that Johnson, just out of college, had a summer job at
the labs. He was assigned to write a program implementing a state
minimization algorithm. His supervisors expected it to take him the
summer to complete the program. But Johnson had heard about this new
language, SNOBOL, that seemed perfect for the task. Once he got SNOBOL
running, it took him only 3 weeks to do the job.

All of us have go-to tools that we turn to first. In terms of
languages, it might be C, Lisp, Python, Ruby, JavaScript, R, or
whatever we’re most comfortable with. But stopping to consider what
tool will make the job easiest can yield large dividends.

Posted in General | Tagged | Leave a comment

Programmers and Hardware

The other day I followed a reddit link to a blog post about forking on
GitHub. I didn’t find the post that interesting but I did find one of
the comments on reddit provocative. Chrisgseaton takes exception to
the notion that “real” programmers have to think about hardware1.
As far as I can tell he wants to think of his programs as running on a
virtual construct that implements a logical model but—ideally—with no
actual hardware underneath.

That’s often a useful model and I don’t consider programmers that
adhere to it “lesser programmers” but I do think that great
programmers always have the underlying hardware in mind. Not
necessarily the actual piece of hardware the program will run
on—because, really, how can you know—but at least some sort of
idealized piece of hardware2.

That sounds almost like the “logical model” that chrisgseaton wants to
think about but it’s really a bit more. Every architecture that I’ve
ever worked on has load, store, arithmetic, and some sort of logical
if commands. Their mnemonics and exact operation will differ, of
course, but to a first approximation they’re the same.

That means that as I code I can imagine—again to a first
approximation—what code will be generated. If you can do that, you can
make intelligent decisions between functionally equivalent ways of
coding an idea. If you can’t do that, I don’t see how you can hope to
produce the best code.

I may feel that way because most of my professional development was
done in C, which is often considered a “high level assembly language.”
On the other hand, I can mentally imagine the final machine code even
when I’m coding in a language like Lisp. Languages like Python are
harder because they’re running on virtual machines but even there it’s
possible to predict what “code” will be generated.

So for me, yes you do have to think about the hardware as you code.
Of course, that’s just me. What do you think?

Footnotes:

1

You may have expand all the comments to see his comment.

2

As a practical matter, though, the majority of developers will
have some sort of x86 architecture as a target. Those developers can
have a fairly specific machine model in mind.

Posted in General | Tagged | Leave a comment

Emacs Über Alles

I’ve written before about EXWM and its use as a window manager for
systems running on X Windows. The basic idea is that Emacs becomes
your windows manager and other applications run in an Emacs buffer.

That’s a boon for those of us who strive to spend as much of our tube
time as possible in Emacs. It’s pretty easy—at least it was for me—to
get all your frequently used application functionality, except for your
browser, under Emacs. With EXWM, you can have even your browser—your
real browser, not eww—run in an Emacs
buffer.

If you’d like to see it in action, Uncle Dave has a video that
demonstrates setting up and using EXWM. It’s a little finicky to set
things up but once you do it runs just like any other window manager.

I’d really like to try it out but, sadly, it only runs under X Windows
and I’m on a Mac. If you’re running a Linux machine, it’s easy to try
it out because it’s just another window manager and you aren’t
committing to a long term relationship with it. It’s possible, as
Uncle Dave’s video shows, to change window managers when you log in.

I don’t think that EXWM is the perfect end state but it comes close.
What I’d really like is to be able to run a browser in Emacs. That’s
being worked on so perhaps we’ll see it before too long. In the mean
time, EXWM is an excellent solution to bringing everything under the
Emacs umbrella.

Posted in General | Tagged | Leave a comment

Why C?

Even though I mostly program in some form of Lisp these days, the
majority of my programming over the years was in C. That’s not hard to
understand: most of my work involved low level communications software
such as radio network controllers and message switches. Not very long
ago, C was used for virtually everything—even things for which it
wasn’t really suited.

These days, C use tends to be restricted to its more natural role as a
language for systems programming and specialized applications where
speed is essential. Even in those niches, C is feeling pressure from
languages like Go and Rust. Many younger engineers have never used C and
are inclined to think of it as a crusty, old language whose time has
passed. Pretty much like the programmers of my generation viewed, say,
COBOL.

Still, C is far from dead and is still the language of choice for many
types of programming. It has a lot going for it: it’s fast, doesn’t
require a run-time engine, and can even get by with a very small
run-time library. The folks over at the SQLite Project have a page in
which they explain why they still use C and have no plans for
changing
.

In addition to the reasons above, the SQLite page also calls out C’s
stability. The very fact that it is an “old” and established language
is a plus for them because the developers don’t have to worry about
the language changing out from under them in the way that a new
language still undergoing development—such as Rust—does. C is still
evolving, of course, but very slowly and always with an eye on
backward compatibility.

Posted in General | Tagged | Leave a comment