Post B1oM1Gsr8OkdJ81VB2 by dabeaz@mastodon.social
(DIR) More posts by dabeaz@mastodon.social
(DIR) Post #B1VeLCfqbRDVDLM0a8 by dabeaz@mastodon.social
2025-12-22T13:18:53Z
1 likes, 0 repeats
I don't know why, but Im feeling a strange urge to try and program Rust using ed. It's probably not a useful skill, but it might qualify as an unusual skill.
(DIR) Post #B1VeLIKnYbwclnYHbc by dabeaz@mastodon.social
2025-12-22T14:26:46Z
0 likes, 0 repeats
Maybe I should write a text editor in Rust using ed.
(DIR) Post #B1VeMpb3NIOWDit6dE by deshipu@fosstodon.org
2025-12-22T14:29:37Z
1 likes, 0 repeats
@dabeaz Bootstrap an ed-like editor by writing it using itself.
(DIR) Post #B1YmG0bRRBeBR6Ct7I by dabeaz@mastodon.social
2025-12-24T02:10:01Z
1 likes, 0 repeats
@ed1conf @sirwumpus Okay, what fresh hell is this? Have you seen the price of RAM recently?
(DIR) Post #B1aTLLBGqaKPtNiMHQ by dabeaz@mastodon.social
2025-12-24T13:00:03Z
0 likes, 0 repeats
After some playing around, I definitely think this needs to happen. Maybe I'll work through the 2nd half of Crafting Interpreters with Rust/ed. Maybe I should record this frivolity as some kind of 20 hour YouTube video.
(DIR) Post #B1aTLMfRJu3SVEpxwW by dabeaz@mastodon.social
2025-12-24T21:48:58Z
0 likes, 0 repeats
Well, I'm about 90 minutes into this project so far. It's, uh, freaky. But, I'm making progress. Translating C to Rust is a whole different game than translating Java. I don't really feel like doing all of this low-level byte oriented free/malloc business. No, I'll just use Vec<> and other nice Rust stuff.
(DIR) Post #B1aTLNLylk5AdAjwFU by dabeaz@mastodon.social
2025-12-24T21:50:09Z
1 likes, 0 repeats
Also, mixing up ed regular expressions with Rust syntax is proving to be an interesting head trip.
(DIR) Post #B1aTLTc9UWaI34LwI4 by dabeaz@mastodon.social
2025-12-24T21:54:21Z
0 likes, 0 repeats
And, in the middle of working on this crazy Rust/ed coding thing, I get an AI-generated email from "Claude" thanking me for my Python work? WTF?!?!?
(DIR) Post #B1i3Glo5NiGlToi2PA by dabeaz@mastodon.social
2025-12-25T02:12:53Z
0 likes, 0 repeats
About 3 hours in now. Made it to the start of scanning (section 16.1.2 in Crafting Interpreters). Wrote a Rust macro. Floundered about with some ed regex for a bit. However, making steady progress.
(DIR) Post #B1i3GnNZXGFWMAJtM8 by dabeaz@mastodon.social
2025-12-25T02:25:54Z
0 likes, 0 repeats
Not sure how long this is going to take, but I'm guess it's definitely going to be a multi-day project (maybe even a week). Pondering: Should I upload the video in progress or wait until the whole thing is done?
(DIR) Post #B1i3GolMOIs6eESP4a by dabeaz@mastodon.social
2025-12-25T15:12:18Z
0 likes, 0 repeats
Ok, let's continue onward with scanning! I already continue this once before in Rust, but the implementation in the second half of Crafting Interpreters takes a different approach with ownership. So, I'll try to stay in the spirit of that as I go.
(DIR) Post #B1i3GpoaTn2zuWyUk4 by dabeaz@mastodon.social
2025-12-25T17:26:18Z
0 likes, 0 repeats
Welp, I've made it through scanning. Take a break in preparation for parsing. Still haven't left the original `ed` session I started yesterday.
(DIR) Post #B1i3Gqocl8ff0w02RE by dabeaz@mastodon.social
2025-12-26T02:44:05Z
0 likes, 0 repeats
Finally made it through the first part of parsing (chapter 17). I'm about 8 hours into the whole project so far. But, done for today.
(DIR) Post #B1i3Grp11AZu8RBrge by dabeaz@mastodon.social
2025-12-26T02:50:30Z
0 likes, 0 repeats
Looks like the next few sections implement features that Rust already has (strings, hashmap, etc.). As instructive as that might be, I'm not going to reimplement all of that from scratch. At least I don't think so.
(DIR) Post #B1i3GsqTDFKtJEsXaq by dabeaz@mastodon.social
2025-12-26T13:32:02Z
0 likes, 0 repeats
Well, up for day 3 of the crusted-ed project. Had a very sloppy bike ride in the rain to prepared for the day. Will now clean up and take care of the pooch before plowing onward into some code cleanup and further chapters.
(DIR) Post #B1i3GtdOHMT3kxlbqS by dabeaz@mastodon.social
2025-12-26T19:19:17Z
0 likes, 0 repeats
Well, I seem to have made it as far as the great abyss--the point where Crafting Interpreters wants me to think about garbage collection. Coding in Rust, this is about to get "interesting." Maybe a short nap is in order first.
(DIR) Post #B1i3GuikEwLR7rHOpU by dabeaz@mastodon.social
2025-12-26T19:27:29Z
0 likes, 0 repeats
The book sets up linked lists of heap-allocated objects (in C). Could be dicey trying to replicate that. Part of me says the whole problem could be avoided by slapping Rc<> on everything. But, that feels like cheating and not in the spirit of the overall affair. So.... hmmm.
(DIR) Post #B1i3Gvc2vKa3tN9Z1k by dabeaz@mastodon.social
2025-12-26T23:11:19Z
0 likes, 0 repeats
So, I've decided to do my own GC. Have now reached the hash table chapter. Rust already has its own HashMap. I could use that as a shortcut. Or I could try to roll with the book and make my own.At the moment, the Hash in the book seems somewhat disconnected from everything else. And I don't recall Lox as having HashMap as a kind of value that you could use in user code. Somewhat inclined to use Rust HashMap<> for this until I run into a reason not to.
(DIR) Post #B1i3Gwc5CgCizmB6iu by dabeaz@mastodon.social
2025-12-27T01:57:46Z
0 likes, 0 repeats
Okay. Day 3 is done. Made it to the part just before global variables are defined. So, tomorrow will probably be dedicated to all things variables. About 15 hours into the project now.
(DIR) Post #B1i3GxTbzf1RfnDr9s by dabeaz@mastodon.social
2025-12-27T23:51:52Z
0 likes, 0 repeats
Day 4 is done and I'm up to about 20 hours of effort now. I've made it through local variables and am preparing to start Chapter 23 on control flow. I can't even express how much fun this project is with the crazy tooling--or lack of tooling as the case may be. The "standard editor" indeed.
(DIR) Post #B1i3Gy9nSolZmcxXua by dabeaz@mastodon.social
2025-12-28T14:05:33Z
2 likes, 0 repeats
"So Mabel, hear me out for a moment. Because of memory safety--Rust. Because of memory prices--ed.""Yeah, the standard editor.""Anyways Mabel, day 5 of my project awaits."
(DIR) Post #B1i3H3RLoymMAWD8T2 by dabeaz@mastodon.social
2025-12-28T14:06:58Z
1 likes, 0 repeats
Say what you will about dogs, but they'll gladly sit there and eagerly listen to your "ideas."
(DIR) Post #B1kuylocOWGi8QkCVU by PeterLudemann@mathstodon.xyz
2025-12-23T01:15:30Z
1 likes, 0 repeats
@robpike @dabeaz MTS had something like readline built into the terminal handler (you could grab a line from anywhere on the screen, modify it, and enter), so the line editor was almost a full screen editor... for quite a while, nobody saw the need to develop a full screen editor, but eventually it was done. (One wonders why unix didn't do something similar, but instead required every interactive program to use readline and provide its own recall system)
(DIR) Post #B1oM12TWhmAgcW44ki by dabeaz@mastodon.social
2025-12-28T14:24:21Z
0 likes, 0 repeats
Meanwhile, I woke up in the middle of the night and mumbled something about "macros." Think I'll warm up with that--in ed (as previously noted).
(DIR) Post #B1oM13EJtnbMxdxRgm by dabeaz@mastodon.social
2025-12-28T17:41:22Z
0 likes, 0 repeats
Well, I've made it through Chapter 23 on control flow and have loops working. Functions await. I suspect things are going to get bad now. Maybe a break for lunch first. And maybe a nap."What do you think Mabel?"
(DIR) Post #B1oM13kZxrPEZh3CyG by dabeaz@mastodon.social
2025-12-28T18:16:42Z
0 likes, 0 repeats
Maybe a bit of reading and some basic preliminaries first. Then a nap. Then work on the hard stuff. That sounds like a plan.
(DIR) Post #B1oM14IbvKd0HEyO12 by dabeaz@mastodon.social
2025-12-28T22:05:31Z
0 likes, 0 repeats
Ah yes. All manner of "hard" stuff (i.e., ownership issues) can be solved with macros. As foretold.
(DIR) Post #B1oM14mk7IjNmh4Ryy by dabeaz@mastodon.social
2025-12-29T00:29:54Z
0 likes, 0 repeats
Well, this chapter 24 on functions is definitely "a beast" as self-described in the opening sentence. I've made it to the part of trying to call functions (not yet working). Debating whether to try and power through after dinner or take a break until tomorrow. Aside: The "flow state" of coding in ed is far more intense than I would have anticipated. Time disappears.
(DIR) Post #B1oM15hSiQ6KcbbkOG by dabeaz@mastodon.social
2025-12-29T02:11:12Z
0 likes, 0 repeats
Welp, hit a wall on the borrow checker with something. Time for sleep I think.
(DIR) Post #B1oM16XvZM4JFK9eAS by dabeaz@mastodon.social
2025-12-29T12:04:51Z
0 likes, 0 repeats
Woke at 4am with a fix in mind so I coded that. It worked. Now, maybe an exercise break before getting native functions implemented.
(DIR) Post #B1oM17K8g6dJeqi9JY by dabeaz@mastodon.social
2025-12-29T13:38:24Z
0 likes, 0 repeats
As I go into day 6 of my big coding project comprising of a single `ed` session, the activity monitor tells me that `ed` has now used a cumulative total of 1.46s of CPU time.
(DIR) Post #B1oM18NMlaoCv9EEz2 by dabeaz@mastodon.social
2025-12-29T15:39:32Z
0 likes, 0 repeats
Made it to the end of chapter 24. An initial benchmark has me running 75% slower than Python 3.13 on a fibonacci example. Honestly not bad consider the primary focus up to now has been on getting it work at all.
(DIR) Post #B1oM19HNPLbzirQyHo by dabeaz@mastodon.social
2025-12-29T18:09:57Z
0 likes, 0 repeats
The fact that I just put two lifetime specifiers on a single structure and managed to get everything to compile and run again is a sure sign it might be time to take another break. I feel this part might be ending badly in the not too distant future... (and I will be undoing aforementioned lifetimes).
(DIR) Post #B1oM1A0kgduLzafD0q by dabeaz@mastodon.social
2025-12-29T23:10:35Z
0 likes, 0 repeats
Yep, ended up undoing all of that. However, now really into some deep quicksand working on the implementation of closures (chapter 25). Pointers, linked lists, recursion, and mutability everywhere in all directions. This is some very happy Rust coding.
(DIR) Post #B1oM1AZ8cnPhiEkfbs by dabeaz@mastodon.social
2025-12-29T23:15:32Z
0 likes, 0 repeats
Is there a hidden level beyond unsafe?
(DIR) Post #B1oM1BC8HobbfAzoOG by dabeaz@mastodon.social
2025-12-30T10:23:52Z
0 likes, 0 repeats
As I get up for day 7....Crafting Interpreters: "Here's this pointer to this thing that points at this other thing. But it doesn't own that. But don't worry, we'll fix that dangling pointer later. Oh, and note that it's kind of wild how we're mutating the thing in the middle of these other things inside this linked thing. LOL!"Rust: <Icy Stare>Ed: "I'm just sitting here laughing while I watch you try to edit/debug the thing."Me: "Here, hold my beer."
(DIR) Post #B1oM1BmI7NWrTJugka by dabeaz@mastodon.social
2025-12-30T12:11:18Z
0 likes, 0 repeats
Did I mention that there's not even any syntax highlighting?
(DIR) Post #B1oM1CRldAhpXxJoOm by dabeaz@mastodon.social
2025-12-30T16:51:02Z
0 likes, 0 repeats
OKAY THEN. LET'S HAVE EVEN MORE MUTABLE LINKED LISTS!The fact that this chapter ends with a little part titled "Challenges" is not lost on me...
(DIR) Post #B1oM1DCYpC8Vt5DBKq by dabeaz@mastodon.social
2025-12-30T17:01:53Z
0 likes, 0 repeats
Oh, AND NULL POINTERS.Took a bit of a short break to rub Mabel's belly. She then whispered something that sounded sort of like "HashMap". So...
(DIR) Post #B1oM1DjWqcVXXKdViq by dabeaz@mastodon.social
2025-12-30T18:15:29Z
0 likes, 0 repeats
Well, Mabel's intuition on the HashMap proved insightful. I now seems to have closures working and Chapter 25 complete.Oh, chapter 26 coming up. Garbage collection. How hard could that be?(In theory, if I've been working my abstractions correctly, this will not be THAT hard. Famous last words).
(DIR) Post #B1oM1EJKhV9DKNO6Wu by dabeaz@mastodon.social
2025-12-30T20:03:28Z
0 likes, 0 repeats
Garbage collection is always better after a nap.
(DIR) Post #B1oM1EsQb1Dj5Do8ES by dabeaz@mastodon.social
2025-12-30T23:59:57Z
0 likes, 0 repeats
Well, I definitely coded up some garbage after that. Think that ends the day for now. Good progress overall.
(DIR) Post #B1oM1FXu6oOh9rDFse by dabeaz@mastodon.social
2025-12-31T10:34:19Z
0 likes, 0 repeats
Too wired to sleep, but now a dilemma. Do I code more on the garbage collector or do I go out biking in the snow? Hmmm. Maybe both!
(DIR) Post #B1oM1G7Lz0kmvnnZ8S by dabeaz@mastodon.social
2025-12-31T12:21:14Z
1 likes, 0 repeats
Like biking in the snow at 4:30am, when you code with ed, you know you'll code alone in a blissful state of flow.
(DIR) Post #B1oM1Gsr8OkdJ81VB2 by dabeaz@mastodon.social
2025-12-31T13:48:58Z
0 likes, 0 repeats
With the bike ride done, it's now time to venture out for a much needed coffee and to discuss the status of my ed adventure...
(DIR) Post #B1oM1HMzKMr0oa7Z8y by dabeaz@mastodon.social
2025-12-31T15:04:24Z
1 likes, 0 repeats
So, I think I successfully convinced Matt Godbolt that coding Rust with ed is the future of coding. cc/ @mattgodbolt