Follow

New project

github.com/akkartik/teliva

"An extremely naïve, brutalist attempt at packaging up simple Lua (5.1) apps with all the stuff needed to edit and build them."

· · Web · 5 · 6 · 10

Fun with the kids on a Saturday morning messing around with daddy's new program.

We gave each ring its own color, and we have it set up to move the towers randomly around after every move. Supremely silly.

You knew this was coming. Conway's Game of Life in text mode using Unicode Braille glyphs.

git clone github.com/akkartik/teliva
cd teliva
make linux
src/teliva life.teliva

Sources: github.com/akkartik/teliva/blo

App runtimes should support modifying apps.

Here's a 2-minute video on how that might look.

archive.org/details/akkartik-2

Teliva now has network access. Including https. And support for streaming APIs. All of luasocket and luasec libraries are supported.

(Obviously none of this is original development. I'm just putting together libraries created by my betters.)

Try it out:
git clone github.com/akkartik/teliva
cd teliva
make linux
src/teliva chesstv.tlv

Known issues:
- Code browser is broken for this app. It's likely the callback.
- Reading from network blocks keypresses.

Main project page: github.com/akkartik/teliva

Beginnings of a Gemini browser in Teliva, a way to share small, hackable, text-mode Lua apps.

Try it out:

git clone github.com/akkartik/teliva
cd teliva
make linux # or macosx or bsd
src/teliva gemini.tlv

Largely built from within Teliva. Here's a session of me implementing links. (video; 45 minutes)

archive.org/details/akkartik-t

Running untrusted apps in Teliva

Programming languages assume you trust all code you run. Browsers assume you trust all network access from websites you visit. With Teliva I'm exploring other approaches in search of a sandboxing model that's both more flexible and easier to understand/trust. Here's a first draft.

archive.org/details/akkartik-t (video; 2 minutes)

Main project page: github.com/akkartik/teliva

@akkartik sometimes i think about how a full operative system made with luajit would be, all the graphical apps being little lua script you can edit with the included text editor

(or maybe not an OS, it could also be a lua-based linux distro)

@nonmateria @akkartik I found someone had done this as an OS built with Luajit; it's still based on Linux but has all its userspace replaced. really neat idea and I was able to actually boot it on physical hardware. https://github.com/dlannan/ljos

@nonmateria @akkartik haha I have no idea; good question

I ported my Love2d-based text editor to ljos a while back and got it running on an old thinkpad from my closet: https://github.com/technomancy/ljos/commit/6d0bc7c303a2a4cf85cfd75022c4c9060b269744

@akkartik hah took me a second to realize it was a tamil word! neat.

@akkartik can you ^E in the editor to edit the editor?

@eris Nope :) The environment is for editing Lua. The editor is built in C.

@akkartik aw man! you should totally write a lua editor such that the editor is editable

@eris @akkartik if you folks haven't already seen it, check out lite from rxi

@maxc @eris Text-mode only at the moment, sadly: merveilles.town/@akkartik/1072

I don't really know what I'm doing when it comes to robustly providing graphics.

@akkartik @eris oh I'm not saying to copy it's approach all the way down to sdl :) just that it's an editor written in c and lua, afair it's actually mostly software rendered too, and I think rxis minimal approach would probably sit well with you even if there's not much that can be directly adopted or whatever haha

@akkartik @eris for the curious, other repos from them worth checking out are fe for a c89 fixed footprint embedded lisp-ish language and dyad for async networking... there's quite a lot of work to explore depending on your interests tbh haha

@akkartik I love the idea behind this; nice work.

I am super curious about the decision to use a version of Lua that dates from 2006 though; even 5.2 fixes almost all of the most glaring flaws in 5.1 without having the higher LOC count of the latest version.

@technomancy Yeah, totally. I'm not really sure what I'm doing there, and might change this. My reasoning at the moment was:

- preserve the luajit option
- go with a smaller implantation if it's still widely used (thanks to luajit)

I'd love to be corrected on either score.

@akkartik I see, yeah. unfortunately those two goals are somewhat at odds with each other; if you prioritize speed you have to sacrifice size.

despite being compatible with 5.1, luajit fixes almost all the big flaws in it, though some of its fixes need to be specifically opted into at compile time.

IMO either switching to luajit or a newer PUC would be better than staying on PUC 5.1 but I can understand wanting to keep options open.

@technomancy That's really helpful. I'm going to keep an eye out for flaws since I haven't experienced them myself yet. Is there a definitive list somewhere?

I plan to write lots of Lua code over the next few weeks and months, so I'm sure I'll run into them for myself.

@akkartik the biggest problems are the inability for coroutines to yield across protected calls or C code boundaries and the inability to construct proxy tables (using metamethods) that can be iterated.

these are both issues which beginners are unlikely to hit on their own, but coroutines and metamethods are both pretty important as means of abstractions for using 3rd-party code. if your goals don't involve users pulling in libraries, maybe it's less of an issue.

@akkartik this doesn't work for libraries but if you control the final environment you can more or less fix the metamethod problem completely in userspace: https://gitlab.com/technomancy/bussard/-/blob/master/metatable_monkey.lua

it's very ugly but it gets the job done. I used this in my game Bussard to implement read-only tables being exposed to the in-game sandbox which allows users to run whatever code they write while playing.

now that I think about it, a similar approach could work for teliva.

@akkartik other main 5.1 drawbacks are: lack of utf8 support (easily backported), lack of bitwise operations (also backportable) and lack of integers (have to upgrade to 5.3 to get this if you want it; I've never personally needed it yet)

@technomancy @akkartik Also worth noting for those metamethods, if you're already working from C, is the native patch approach as seen in the Lua wiki http://lua-users.org/wiki/GeneralizedPairsAndIpairs

Though in the case of __ipairs you get the extra confusion of the fact that Lua 5.3 went on to deprecate it and 5.4 to remove it in favor of making ipairs respect __index and __len :(

@technomancy @akkartik Correction: ipairs respects __index and stops when it hits a nil, it doesn't check __len.

Not sure what I conflated it to throw __len in when I misremembered but figured I should correct myself after @technomancy asked me about it!

@akkartik can retrieved string be evaluated in lua vm?
Very cool project. Amazing progress in a few week :flan_aww:

@klve Thanks! :pilin: :pilin:

Yeah it's totally dynamic. I'm actually actively trying to hold back the dynamism :) I want to avoid situations where a program behaves differently after restarting, because what was in memory diverged from what got persisted into the .tlv file.

@akkartik Hmm, this magical editing thing might be doable in Guix... Although it would require rebuilds after a change is committed...
It's already pretty easy to make a slightly customized package by unpacking the result of `guix build --source lua` and then rebuilding it (or a whole manifest) with --with-source=lua=/path/to/custom/lua . And it takes care of rebuilding dependents and doesn't disturb the rest of the system.

@akkartik With languages and frameworks that support live reloading, this could even be implemented without restarts. Eg.: the kernel has various live patching solutions, so this could be used to create live updates to it. And if it can be done with a beast like the kernel it can be done with something like Lua as well.
And if the package has debug info, the editor could even open on the currently executed line....

Sign in to participate in the conversation
Merveilles

Revel in the marvels of the universe. We are a collective of forward-thinking individuals who strive to better ourselves and our surroundings through constant creation. We express ourselves through music, art, games, and writing. We also put great value in play. A warm welcome to any like-minded people who feel these ideals resonate with them.