Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: FXYT – Tiny, esoteric, stack-based, postfix, canvas colouring language (github.com/susam)
82 points by susam on March 23, 2024 | hide | past | favorite | 10 comments



I tried to write a mandlebrot plotter in FXYT. There are a number of challenges! First FXYT only provides a bounded loop - this can be overcome with a bit of inefficiency.

However the deepest stack manipulation allowed is 3 values - the R command (Rotate the three values at the top of the data stack) which makes things supremely awkward. It could do with an PICK instruction (duplicate the n-th on the stack). However as an old FORTH programmer you always knew were getting into trouble if you used PICK.

Despite these limitations I did figure out how to write a mandlebrot plotter. Alas it runs into an iterations limit if the depth is > 7, so here is a very low-res mandlebrot made with FXYT!

NNNN7[SDDN1024/RDDN1024/R+N4096<[RN1+RR]SDDN1024/RDDN1024/R+N4096<![PPN4000N4000]SDDN1024/RDDN1024/RS-XN128-N12N512-+RRN512/YN128-N12+]PPN30

You can cut and paste the string above into https://susam.net/fxyt.html if you wish to see it!

Edit - looks like HN formatting mashes the code...

This link should work

https://susam.net/fxyt.html#NNNN7bSDDpN1024qRDDpN1024qRsN409...


Great demo! Thanks for sharing! Copying the un-mangled code here for future reference:

  NNNN7[SDD*N1024/RDD*N1024/R+N4096<[RN1+RR]SDD*N1024/RDD*N1024/R+N4096<![PPN4000N4000]SDD*N1024/RDD*N1024/RS-XN128-N12*N512-+RR*N512/YN128-N12*+]PPN30*
If you start a line in HN comment with 2 spaces, the line is reproduced verbatim. See https://news.ycombinator.com/formatdoc for more details about this.


I can't find any way for one cell to be affected by the value of a different cell. I haven't thought about it much, but if there were syntax to allow references to adjacent cells, you could do stuff like convolution.

Also, it would be nice to have (a) layers, and (b) alpha values.

Pretty neat to jam it all into a small HTML page.


You could compute the value of adjacent cells and use it in your formula.


I don't see how. There's no notation for addressing cells, and every cell runs the same formula.

It's a bit like a spreadsheet, but with every cell running the same function. But with notation for addressing cells, you could make Conway's Game Of Life with a program just a dozen characters in length.

With a z dimension and cell-addressing, you could probably create something like a weather model. But to be useful, you'd need a bigger canvas than 256x256.

You could probably do some interesting things if the language allowed an arbitrary number of dimensions.


> There's no notation for addressing cells, and every cell runs the same formula.

The adjacent cells are (X,Y-1), (X,Y+1), (X-1,Y), and (X+1,Y), you can use those values in your formula.


Thanks! I didn't see that in the docs. That immediately makes it more interesting.


It could be cool that layers are z dimension in terms of adjacency. It would also bring some challenges but hey, esoteric languages exist for the bold ones!


Reminds me of https://tixy.land popular on HN a few years ago

https://news.ycombinator.com/item?id=24974534

Edit: Ah

> This project is inspired by Martin Kleppe's Tixy project


So every pixel/coordinate can hold 3 bits? Hmm, that is alluring and potentially quite advantageous for storage and computationally aware coordinate spaces.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: