10 ms·
Piet, a programming language in which programs look like abstract paintings
- plopz 7y agoFor whatever reason, it makes me really happy that esoteric languages like Befunge, vigil or Half-Broken Car in Heavy Traffic exist.
- bussierem 7y agoYou should take a look at Rockstar: https://github.com/RockstarLang/rockstar https://github.com/RockstarLang/rockstar
- boothby 7y agoBears mentioning that Piet is "faster than C" if you use the right compiler. https://github.com/boothby/repiet/blob/master/README.md#but-is-it-faster-than-c https://github.com/boothby/repiet/blob/master/README.md#but-... Among the esoteric languages I've learned, Piet is by far, hands down, my favorite. But it's curiously opinionated about reading input. I don't think any interpreter / compiler gets it right, mine included. Painting (one does not write) Piet code to safely handle input, by that spec, is particularly annoying.
- tess0r 7y agoI agree. I've written an interpreter in rust [1] and input handling, esp for numbers, was really annoying. I guess the best reference for implementing new interpreters is npiet and testing all example images. [1] https://github.com/tessi/rpiet https://github.com/tessi/rpiet
- boothby 7y agoCool, I haven't seen your interpreter! I'll have to give it a read through. npiet is good, and I use its examples for testing, but FYI it diverges from the spec in how it handles whitespace. According to DMM, if the cursor enters a loop entirely within whitespace, the program should terminate. Currently, npiet doesn't have a cycle-detection algorithm so it hangs. One of these days I'll get around to making my test infrastructure and polishing up my tests... but I've recently had some weird thoughts about a place&route algorithm to replace my existing Piet backend and that's more interesting. First step, design a router that creates right-hand-rule paths through whitespace? What am I even doing with my life...
- markemer 7y agoOne of these days we’ll need to get IEEE to formalize a standard.
- tess0r 7y agoI implemented my interpreter with the goal to learn some rust. So please let me know should you find things to improve :) I remember a point in development when I implemented whitespace handling and cycles therein. I thought I had implemented the spec but some example programs did not run properly. Maybe that was because of the divergence in the spec vs. npiet you mentioned. Since my main goal was to learn rust I just made the example programs work and did not double check the spec again. Will look into it again when I find some time :)
- downerending 7y agoC is also "faster than C" if you use the right compiler.
- shakna 7y ago> Well, let's back up a minute for the folks missing context. Recently there have been a spate of blog posts of folks claiming that their pet language is "faster than C" by implementing a feature-incomplete version of the wc utility and running a single benchmark to demonstrate superiority. I believe they are well aware of the limitations that have been shown in these recent benchmarks, and that it doesn't in fact demonstrate superiority in any way.
- boothby 7y agoWell yes, the example uses a C backend and everything. repiet wc.png -o wc.c --backend c --codel_size 10 -O 2 gcc wc.c -o wc -O3 I hacked it together in response to a "brainfuck is faster than C" HN post and stale jokes don't die on my watch.
- downerending 7y agoI, too, was joking. Mostly. :-)
- maddyboo 7y agoThe list of example programs is really fascinating: https://www.dangermouse.net/esoteric/piet/samples.html https://www.dangermouse.net/esoteric/piet/samples.html
- dmos62 7y agoAt the bottom there's a text adventure game and a brainfuck (another esoteric language) interpreter.
- jboy55 7y agoMy phone screen coding question, designed to be obvious and quick, was to do pow(base, exp). I would always tell the interviewee that they could use any language they are comfortable in. Thinking ahead, I wanted to be prepared for the eventual, 'well I'll use Whitespace!'. So I sat down during a hack day and did whitespace, Piet, LolCat and tried to do BF. Piet was the most enjoyably hard. Figuring how to store variables was a nice brain test, I really felt I had acomplished things. Whitespace is super easy in comparison and I couldn't figure out how to do a variable length outer loop in BF.
- dang 7y agoRelated posts, from 2017: https://news.ycombinator.com/item?id=13503841 https://news.ycombinator.com/item?id=13503841 2016: https://news.ycombinator.com/item?id=11342442 https://news.ycombinator.com/item?id=11342442 2014: https://news.ycombinator.com/item?id=7727702 https://news.ycombinator.com/item?id=7727702 2012, cheekily titled: https://news.ycombinator.com/item?id=4698737 https://news.ycombinator.com/item?id=4698737 2011: https://news.ycombinator.com/item?id=2430357 https://news.ycombinator.com/item?id=2430357 2010: https://news.ycombinator.com/item?id=1166462 https://news.ycombinator.com/item?id=1166462 2008 (not much): https://news.ycombinator.com/item?id=139872 https://news.ycombinator.com/item?id=139872
- jagged-chisel 7y agoThe 2012 link says "No such item." Is this it? https://news.ycombinator.com/item?id=4698737 https://news.ycombinator.com/item?id=4698737
- dang 7y agoYup! Thanks. Fixed now.
- zingermc 7y agoA while ago, I tried making a Piet compiler in Haskell that emits LLVM IR. Eventually I found an inconsistency between my interpretation of the spec and npiet's implementation, so some Hello World examples would print something like "Hello wowowowowo...". https://github.com/dmcardle/piet-llvm-frontend https://github.com/dmcardle/piet-llvm-frontend
- dibujaron 7y agoWow, David Morgan-Marr does neat language projects as well as the awesome webcomics? That guy is a machine.