12/26/2023 0 Comments Twitter for mac 280 characters![]() This was the first tweet posted by the new Tootbot. Three months of procrastination later, I finally spent Monday writing the new version and getting it running on the new DF server. In the meantime, I had a copy of the old version of the script on my Mac that I could run manually. There were a few other changes I wanted to make, too - like switching from DF’s RSS feed to the JSON feed as the source for new articles, and supporting Twitter’s 280-character limit. So, I decided I should rewrite that part of the DF Tootbot to do what it should have done all along: use a simple human-readable text file for the history log. Premature optimization is the root of all evil. We shouldįorget about small efficiencies, say about 97% of the time: Impact when debugging and maintenance are considered. Worrying about, the speed of noncritical parts of their programs,Īnd these attempts at efficiency actually have a strong negative Programmers waste enormous amounts of time thinking about, or I ran afoul of Donald Knuth’s well-known axiom: I hope to write Daring Fireball for a long time to come, but I really doubt I have a million posts in me.Ī database was overkill. I wrote a test script and ran it against a 53 MB text file log with 1 million lines. It would have been more than fast enough 10 years ago, and it’s much faster today. Because here’s the thing: reading a simple text file log with tens of thousands of lines is really really fast on a modern computer. It bothered me because the database wasn’t something I could just open in BBEdit and inspect and edit by hand. It bothered me that the script was using a database at all. The script just needs to know which recent articles - articles still in the feed - have already been tweeted. For the purposes of tweeting new entries from the RSS feed, there’s no reason to keep a full historical log. What I could have done is just start over with a new history log on the new server, and manually fill the new database with the last few weeks of entries. 1 There were a lot of major version updates to Perl in the years since I last moved servers. When I first wrote the script 10+ years ago, I used a database, cleverly thinking, “ If this Twitter thing is here to stay, I’ll eventually tweet tens of thousands of posts, so I should use a database so lookups don’t get slow and the whole thing continues to run fast years from now.” The database I chose, unfortunately, is one that sometimes changes its underlying file format with major version updates. What broke when I moved servers was the history log. ![]() The script runs once per minute as a cron job.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |