Kartik Agaram
grep
I need to support files with at least 50-character lines. Requesting URLs on the internet also requires showing long URL strings on the stack.
* One thing I keep rubbing up against is the distinction between editing a program and browsing its state. Bret Victor's demos like https://vimeo.com/36579366 consistently gloss over this. Yes, it's nice to be able to play what-if experiments with your program, but you quickly realize you need to unwind one experiment to try out another. Either you need smart undo, with the ability to somehow drop milestones into the timeline after the fact. Or you need to somehow separate browsing operations from manipulations of the program itself. It feels more feasible to show many copies of a screen object if most of them stay collapsed. Or to truncate URLs if they can be expanded on demand.
I do have one more idea for an interesting demo: supporting APL-like array operations. But I'm not sure if I should go down that road if there are potentially fatal problems with this whole approach.
A Mu-specific constraint here is the lack of a mouse. My UI has a single point on the screen where I can manipulate things. There's no mouse, because mouse support in text-mode terminals is non-standard and requires understanding differences between terminals. Which requires dependencies beyond a Linux kernel. That's something I've managed to sidestep so far by staying extremely lowest-common-denominator in terminal capabilities.
Perhaps I'll switch gears and focus on getting off the Linux kernel. Then I won't need to worry about terminal compatibilities. But then people would be required to use Qemu to play with Mu. Which sucks đ Perhaps that's the fundamental psychological block here: I want to keep Mu easy to try out, but beyond a point I can't undo bad historical decisions without adding some friction to checking it out. Then again, it's not like many people try it out anyway, and requiring Linux is just as much friction for someone on a Mac. Yeah, perhaps there's more OS hacking in my future. Thoughts/suggestions appreciated on this angle as well.Daniel Garcia
12/13/2020, 7:39 PMChris Knott
12/13/2020, 8:35 PMWhat to do about line getting too long?Just infiniscroll to the right within in a window/frame (perhaps I'm misunderstanding the issue, this seems completely analogous to new lines in a source file).
What about awkward values on the stackI think you'll have to just put a marker on the timeline stacks (like [$1]), then on the left of the screen show [$1]["http://example.com/blah/122512"] with the same colouring. The values are const (IIUC), so you can show a single list of values across all stacks in the timeline view
Chris Knott
12/13/2020, 8:39 PMGarth Goldwater
12/13/2020, 8:46 PMKartik Agaram
my initial suspicion on the stack depth stuff is that the stack shouldn't ever really get too deep
Yeah, for sure, stack depth feels like less of a constraint compared to line length and how much horizontal space we devote to the stack state of each word. I don't care about compatibility with Unix or functional equivalence. Just something that is internally consistent and reasonably discoverable. I think if push came to shove I'd make the same trade-off as everyone else and compromise on discoverability. @Chris Knott
Just infiniscroll to the right within in a window/frame (perhaps I'm misunderstanding the issue, this seems completely analogous to new lines in a source file).
You're right. If we can solve the problem of wide values on the stack, long lines seem viable. --- One constraint I hadn't mentioned until now: I'd like for the number of hotkeys this environment needs to be small enough that I can describe them all in the menu at the bottom for some reasonable screen width. Excluding intuitive stuff like arrow keys. I think I have a new idea after this thread. Values on the stack will have 3 possible states: collapsed, truncated and maximized. By default, any value wider/taller than some threshold will be collapsed -- except at the top of the stack, where it's truncated to the threshold width and height by default. Now we need just one new hotkey: toggle the top of stack at the cursor between trunated and maximized. Maximize does exactly what it sounds like. It puts you in full screen mode browsing the data as necessary. The idea is to avoid any ambiguity about what will scroll. No nested scrollbars. Values in the stack are always in read-only mode when maximized; you can only browse within them. This suggests an analogous maximized edit mode for input words (say literal strings or arrays). But I haven't thought that angle through. Ideally I'd like this to be the totality of the UI (or some single prototype UI) for the Mu computer. Just text mode, no mouse. A single cursor on screen, an infinite 2D space that you can move around in, containing panels (functions or sandboxes) that in turn contain values. Panels and values can be collapsed or maximized. Everything one can do to be done within this framework, whether it's editing code or browsing data or running programs. (Tentatively I imagine a single address space so strong sandboxing, no concurrency only lazy streams.) Thoughts?
Chris Knott
12/14/2020, 9:49 AMKartik Agaram
Daniel Garcia
12/15/2020, 3:44 AMKartik Agaram
makewords file |lowercase |sort |unique |mismatches
I believe this would in reality have been something like:
sed 's/ /\n/g' |tr A-Z a-z |sort |uniq |grep -vf dictionary
(The sed
could also be replaced by a call to awk
. sed
was created in 1973, and awk
in 1977.)Kartik Agaram
Daniel Garcia
12/15/2020, 3:48 AMKartik Agaram
Daniel Garcia
12/15/2020, 3:54 AMDaniel Garcia
12/15/2020, 3:57 AMKartik Agaram
Kartik Agaram
Daniel Garcia
12/15/2020, 3:59 AMKartik Agaram
Kartik Agaram
return
seems quite essential. Stops executing the current function and returns top of stack.
* if{
and }
and }else{
. Here's how factorial would look with them:
n fact
= n 1 <= if{ 0 return } n 1- fact n *
* ->
executes rest of line only if top of stack is true. Factorial again, this time in two lines:
n fact
= n 1 <= -> 0 return
n 1- fact n *
* -<
executes one of the next two words depending on whether top of stack is true or false.
* ->
and -<
may also work well with {
and }
which group words together:
n fact
= n 1 <= -> {0 return} n 1- fact n *
A more challenging example is binary search. The gold standard here is Bret Victor's demo in "Inventing on Principle" (linked above; screenshot below). Some attempts in postfix:
array key bsearch
= array key 0 array len bsearch-range # delegate to helper with explicit low and high
# option A
array key low high bsearch-range
= low high >= if{ null return } # not found
low high + 2 div =mid # mid = (low+high)/2
array mid [] key = if{ mid return } # if array[mid] == key, return mid
array mid [] key < if{ array key mid high bsearch-range return } # if array[mid] < key, recurse over [mid, high)
array key low mid bsearch-range # otherwise recurse over [low, mid)
# option B
array key low high bsearch-range
= low high >= -> null return # not found
low high + 2 div =mid # mid = (low+high)/2
array mid [] key = -> mid return # if array[mid] == key, return mid
array mid [] key < -> array key mid high bsearch-range return # if array[mid] < key, recurse over [mid, high)
array key low mid bsearch-range # otherwise recurse over [low, mid)
# option C
array key low high bsearch-range
= low high >= -> null return # not found
low high + 2 div =mid # mid = (low+high)/2
array mid [] =midval # midval = array[mid]
midval key = -> mid return # if midval == key, return mid
midval key < =upper? # upper? = (midval < key)
# return bsearch-range(array, key, upper ? mid : low, upper ? high : mid)
array key upper? -< mid low upper? -< high mid bsearch-range
But how to visualize a function spanning multiple lines that operates on an array? There aren't enough dimensions.Garth Goldwater
12/17/2020, 3:18 PMKartik Agaram
if
could be expanded like a function call. So it's worth trying.Kartik Agaram
break
and loop
words and infix-chunking. It seems promising how break
and loop
carry over like themes from lower levels of the stack. And we really need infix-chunking once we start indexing into arrays. Most of the time you want to see ÂŤarray[i]Âť
with a single stack under it, but to edit it I'm imagining first expanding it to array i []
with 3 stacks under it.
The following mock-up could be 6 months of work. I'm still weighing whether it's worthwhile.