:building_construction: Day 2 of Advent of Future ...
# share-your-work
m
🏗️ Day 2 of Advent of Future of Code: Brutalist Convivial Computing with Teliva Check instructions here: https://buttondown.email/reviewjam/archive/advent-of-foc-day-2-brutalist-convivial-computing/ 🧵 Conversation about the task as comments to this message!
👍 1
❤️ 2
s
@Kartik Agaram Here's my go:

https://youtu.be/J8thgHPFuqo

❤️ 1
k
No video from me, I haven't yet figured out how to do screen recordings under Linux (which I switched to from macOS in October). Just written feedback.
Following the instructions blindly failed pretty quickly: "make linux" stopped because it didn't find gcc. Normal, since I do all serious work with Guix packages (even though the host system is Ubuntu 20.04). So: better list the dependencies in the instructions! A quick look at the Nix script suggested what I needed, and I ended up doing guix shell -D lua openssl -- make linux That makes an environment containing all packages required to compile lua, plus openssl.
Figuring out the counter wasn't hard, but trying to edit it turned out to be tough: as the screenshot shows, there's a color problem that makes the text in the fields invisible. Started from Ubuntu's default terminal, which uses a dark theme.
1
I had the screen in the instructions, so I typed "main" to continue. I got an editor, but neither "delete" nor "backspace" works, so I couldn't do what I wanted (change the numbers in the initial loop). "Delete" insets "J" on my machine, "backspace" inserts "?" with inverted colors.
Without any way to get the source code back into something correct, I went for "abort" (^C), which exits Teliva completely, no questions asked. But then, the title did say "brutalist" 😉
Of course I opened counter.tlv in Emacs in order to fix my mess, but to my surprise I found a lot more stuff in there than just the Lua code, and preferred to give up - downloading a fresh copy looked easier. Good old git habits 😉
Inserting "hello world" succeeded at first try. Lucky for me, since without being able to delete text, experimenting would have been hard!
Task 2 looks impossible without deleting a character, but I did succeed to make the counter jump by 10.
❤️ 1
Task 2 is easier than Task 1, so from a pedagogical point of view, it's perhaps better to invert them.
💡 1
Would have loved to tackle the Towers of Hanoi, but with the "big picture" screen illegible, this looks hopeless.
End of report!
😬 1
❤️ 1
🎉 1
k
Thanks a lot @s-ol, @J. Ryan Stinnett and @Konrad Hinsen! My first lesson here is that I need to include a list of known issues in the Readme. Backspace/delete handling was a known issue; sorry to waste your time, Konrad. I knew there was no way an international keyboard was going to work. I don't know what smarts I need on top of ncurses, but I think I'll pause features to first get this right. I'd hoped I'd fixed the color issues the last time they came up, but clearly they still need testing with a wider variety of terminals. iTerm2 is an obvious miss since it's so ubiquitous. I'll also include the Nix/Guix instructions in the Readme; thanks to @Mariano Guerra for creating them for the jam. Now to go watch @s-ol's video..
😄 1
k
@Kartik Agaram My laptop has a US keyboard, or more precisely what Dell calls an "international keyboard" here in France.
1
🤔 1
k
Could both you and @s-ol try typing
ctrl-h
? Does that work like backspace for you?
The
?
in reverse video indicates that backspace on your keyboard is emitting
^?
, which is the `delete` keycode in ASCII. I thought only Macs did that.. 🤔
I resisted learning about these long-tail compatibility issues for years -- which is how I ended up up the Mu tree 😢 I need to just gear up and get through them. Edit: (By long tail I mean not that they're unimportant, just that there's a combinatorial explosion of cases here, spanning OS, terminal emulator, color scheme and keyboard)
Of course I opened counter.tlv in Emacs in order to fix my mess, but to my surprise I found a lot more stuff in there than just the Lua code
.tlv files are currently a single literal Lua array consisting of a series of edits. Each edit consists of the final state (a Lua string between
[==[
and
]==]
) of a single definition when you switched files or ran the program. Each edit also contains a couple of bits of metadata: a timestamp and an optional note (commit message). Unlike other version control systems, Teliva lets you modify the description of a commit after the fact. The code itself is immutable, though. Anyways, if you go to the bottom of the file you should see your most recent edits.
k
@Kartik Agaram Ctrl-H works fine for backspace. I should have thought of it, being old enough to have used terminals without a backspace key.
👍 1
k
I think I've improved the situation with colors and the backspace key. @Konrad Hinsen your backspace isn't yet supported, but I've at least tried to make the
ctrl-h
hotkey a bit more discoverable. I'd appreciate some eyes on the state of the menu in various contexts: • big picture view • recent changes • editing a definition • ctrl-f when editing a definition • ctrl-g when editing a definition Do the tips make sense? In particular, I'm not sure how to describe what the backspace key does. Feedback appreciated.
k
Maybe I have been using computer for too long, but for my taste, "backspace" is a pretty good description of what "backspace" does! That's what I'd use as a label for
^H
. The menu keeps getting more complete, but it still lacks something essential: a back button. It's the undo of navigation, the button you hit when you moved somewhere by accident, or just to take a quick look at something.
^G
(go) is useful but also confusing. When I edit
main
, I start with the cursor at the beginning. Now I press
^G
and the menu proposes to go to
function
. An excellent idea! But... all I get is a blank screen. What would I expect? Probably a help page explaining why
function
is not something I can edit.
💡 1
❤️ 1
Bug report: At some point, after various jumps and edits, I did
^e
while editing
main
, and Teliva just quit. Worse: I can't get back in. Running the same command line again has no effect.
Color feedback: the two screenshots below show some progress, in particular for the "big picture", but in exchange the syntax coloring of "main" is hard to read.
k
Thanks a lot, Konrad. Sorry about all the troubles 😓 Could you share the .tlv file that doesn't start? Either here or by DM/email/github: http://akkartik.name/contact
One ongoing conversation with @J. Ryan Stinnett over on github: do y'all think 256 colors are now prevalent enough in terminals that I can start assuming everyone will have them? Say any computer refreshed in the last 10 years or so?
👍 1
I just added three 256-color color schemes. 1. Do the attached screenshots have any low-contrast bits? 2. Could you try them out on your side, see if they look different, or if you spot any more subtle issues? You'll need to tweak
COLOR_SCHEME
at src/teliva.h and then rerun
make
for your platform (
make linux
,
make macosx
, etc.) (The 'solarized' isn't really, more just a sense of where I'm getting my inspiration. The default 256-color palette isn't really good enough for Solarized.)
k
These all look OK (though I can't say I like this version of "solarized"). And they look the same when I run Teliva on my own machine!
❤️ 1
j
Just tried it out locally, all of the themes match your screenshots, so this seems like a good approach to avoiding issues with local terminal theme. 😄 Contrast is decent in all of them, though the blue background one is bit hard to read for me.
Maybe you should make the theme some kind of Teliva "system data", so that it can be changed at runtime. 🤓
😄 1
k
@Konrad Hinsen Thanks for the file! Your bug is a doozie: • Start Teliva with any .tlv program • Hit
ctrl-e
to edit • Select any function • Position the cursor on any Lua keyword. The cursor in the editor starts out on the word
function
, which will do. • Hit
ctrl-g
and jump to the word at the cursor. You'll now see a blank editor. ...and you're already doomed. All ways to go elsewhere or run the program will drop a definition for the keyword into the image file. And running with any such definition causes Teliva to just silently quit. Now trying to understand why this happens.
I probably need a way to exit the editor without saving. Protections against losing data are too strong. Ugh, UX is hard.
👆 1
This commit slightly improves things, but more importantly it lays out the desired solution and some interactions with other parts of my long-term plans: https://github.com/akkartik/teliva/commit/46aa8c2cf8
I ended up completely redoing Teliva's file format. Now .tlv files are no longer parsed as Lua, so they're more secure (just string literals, no arbitrary code execution) and also eliminate the bug you ran into, @Konrad Hinsen. The new format is plain text, kinda reminiscent of YAML, and .tlv files always include some documentation up top to help you make sense of what you see: https://github.com/akkartik/teliva/blob/main/counter.tlv
👍 1
One drawback of Lua this experience has uncovered: it's less principled than Lisp in separating
read
from
eval
. At least, I haven't been able to find any sign of a C interface that parses a chunk of Lua without also executing it. In still other words, Lua doesn't expose its AST to manipulation.
k
Early Python was the same: there was eval, built into the language, but no plain parser. It was later added as a module in the standard library. I'd be surprises if there weren't any Lua parsers out there, if only as add-ons. It seems like "code is data" is something that some language communities discover rather late!
😄 1