Newsletter # 30 - Building a text-based application using Swift and ncurses Aug 6 2020
Hello, and welcome to issue #30!
Sometimes I feel a little nostalgic of the "good old days" when the command-line received so much love. I still believe that it is the most useful tool if you want to increase your productivity. Using graphical interfaces feel sluggish compared to a fine-tuned terminal interface. Typing is faster than moving the mouse across the screen, especially if you have a big monitor. So when everyone is so excited about SwiftUI or React, or any other graphical interface framework, I go back to working on the command-line.
These past weeks I've been working on an open-source library. The name of the library is
SwiftCursesTerm . It works as a wrapper for the C library
ncurses(3). If you are not familiar with
ncurses(3), it's a library released 27 years ago (1993) that provides an API to build text-based interfaces.
Many famous command-line applications make use of
ncurses(3). You might recognise some of them, e.g.
emacs(1), the text editor that is almost an operative system of its own. And a few others.
ncurses library is easy to understand, and it can be useful for some command-line applications. So I thought, why not make it available for Swift. And there you have it. You can use the
SwiftCursesTerm library in your Swift projects and make use of
ncurses in your command-line tools.
Check it out and let me know what you think. It is a working progress. You won't have all the features available in
ncurses from the
SwiftCursesTerm. The good thing is that once you imported the
SwiftCursesTerm library, you can make calls to
ncurses functions using the
curses module I created.
If you are interested, I wrote an article where we create a text-based clock that makes use of the library. I think you'll find it fun. I built the clock with the idea that each part of the display will be like a 7-segment display. If anything, I think you'll find the project fun. Here is the link:
Building a text-based application using Swift and ncurses
Recommendations and interesting topics
You probably heard about the latest Twitter hack that was more than a technical hack a social engineering hack. And what baffle most people is that the perpetrators seem to be some teenagers.
It seems fitting this article from August 1984 written by Ken Thompsons (Creator of Unix and C):
Reflections on Trusting Trust
I liked this quote:
"There is an explosive situation brewing. On the one hand, the press, television, and movies make heros of vandals by calling them whiz kids. On the other hand, the acts performed by these kids will soon be punishable by years in prison."
The article is fascinating from the technical and moral aspect. It points to the problem that we glorify the hacks, almost encouraging kids to become "hackers" because it's "cool", but it has real-life consequences. Read it and let me know what you think.
Anyways, food for thought.
And that's it for this newsletter. I hope you are doing well wherever you are.
Tip of the week
Talking about hacks and secure software. Wouldn't be nice to know which Applications have full disk access on your macOS computer?
Well, lucky you, you can do it by querying the TCC ( Apple's Transparency, Consent, and Control Framework) database:
1 sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "SELECT client,allowed FROM access WHERE service == 'kTCCServiceSystemPolicyAllFiles'" | grep '1'$
If you want to learn more about TCC framework, read this article TCC: A Quick Primer - by Fleetsmith