Kay Lack

Kay Lack

@neoeno.bsky.social

tech educator. she/her

669 followers31 following64 posts

deep in the forth mines with hacked together forth, in a hacked together virtual machine, running in a hacked together web-based forth IDE. the next video approaches

my view so far - forth is simple and beautiful. and, like all simple and beautiful things, the closer you look, the more you realise that it is in fact a tightly woven web of disturbing complexity but that might just be me

Wikipedia says that comp sci professor Rao Kosaraju originated the saying "At some point, the learning stops and the pain begins." โ€” what do you think it means?

every day i get up, i make another clone of ed the Standard Unix Text Editor, i do my burpees, and then i study Unix v7's ed.c to figure out how on earth it works. feels like leetcode for trying to get a job at Bell Labs in 1975

new video! this datatype โ†’ [1, 2, 3] โ† is a bit of a marvel. it can store items of any size, grow to any length, rarely causes performance issues, and almost every modern language has one. what is it, really? and how does it work?

View full thread

and that's what it is! most of the time anyway. functional and systems languages often make different choices and then educate their users about them, while general purpose languages like JS also often try to be smart in the edge cases (like sparse arrays)

new video! this datatype โ†’ [1, 2, 3] โ† is a bit of a marvel. it can store items of any size, grow to any length, rarely causes performance issues, and almost every modern language has one. what is it, really? and how does it work?

View full thread

this seems to me VERY sneaky. the append operation for this data structure is mostly O(1), but will occasionally be O(n). but! if you graph out the average operations for n appends to a list, it looks like this

so on average (called 'amortized') this sly little operation is O(1) - constant time. so we now have a very flexible, kiiiind of almost basically constant time access data structure, which is suitable for embedding into the programming languages all the world uses

new video! this datatype โ†’ [1, 2, 3] โ† is a bit of a marvel. it can store items of any size, grow to any length, rarely causes performance issues, and almost every modern language has one. what is it, really? and how does it work?

View full thread

and neither are โ€” these languages (typically, most of the time) use a data structure called a dynamic array. this is essentially a 'wrapper' around a static array. the runtime gives it a fairly generous initial size

new video! this datatype โ†’ [1, 2, 3] โ† is a bit of a marvel. it can store items of any size, grow to any length, rarely causes performance issues, and almost every modern language has one. what is it, really? and how does it work?

View full thread

the problem is โ€” accessing elements means scanning the list until you find the item you want. this is O(n), where the array was O(1). a little worrying for a general purpose data structure everyone is using all of the time (and which people will probably embed in other loops)

so both arrays and linked lists have big downsides, and neither seem to fit the picture of the flexible, fast-access [1, 2, 3] list type we know and love from Python, JS, et al

new video! this datatype โ†’ [1, 2, 3] โ† is a bit of a marvel. it can store items of any size, grow to any length, rarely causes performance issues, and almost every modern language has one. what is it, really? and how does it work?

View full thread

new video! this datatype โ†’ [1, 2, 3] โ† is a bit of a marvel. it can store items of any size, grow to any length, rarely causes performance issues, and almost every modern language has one. what is it, really? and how does it work?

View full thread

the ability to calculate the location of each item, rather than having to search for it, makes arrays very fast for access and storage. and so long as you know every size up front you can use it to store surprisingly complex types too, like 2d arrays or even trees

the snag is that you need to know the element size and array length up front. element size you can get around using pointers, but array length is harder. if your array is hard up against other important data, you can't extend it.

new video! this datatype โ†’ [1, 2, 3] โ† is a bit of a marvel. it can store items of any size, grow to any length, rarely causes performance issues, and almost every modern language has one. what is it, really? and how does it work?

in some ways the 'perfect' list is an array. you take a fixed number of elements of a fixed size and store them one after the other in memory. to access an element you take the start address and add the element size multiplied by the index

the thing is, all of this is SUPPOSED to be about Forth, but did you know Forth uses a linked list to store its keywords? my question was then โ€” why did Chuck Moore implement it that way? and THEN... there are a lot of other things to think about...

You are up to date.