return to table of content

Piet: Programming language in which programs look like abstract paintings (2002)

gnfargbl
6 replies
9h16m

I did enjoy the one which computes π;

> Naturally, a more accurate value can be obtained by using a bigger program.

I think that's a first for me.

amenghra
2 replies
7h31m

I made a JavaScript port, that might be easier to decipher if you are more familiar with js than C: https://quaxio.com/pi.html

blago
1 replies
5h34m

Do you mind me asking, what does the last calculation do: pi=(pi * 100 | 0 ) / 100;

EDIT: Ah, nvm. It's truncating the result to 2 decimal places.

unilynx
0 replies
2h41m

|0

There are just too many ways in JS to say Math.floor

schoen
0 replies
8h27m

That's originally westley.c from IOCCC 1988. As that site says:

Unless otherwise indicated, the code comes from the International Obfuscated C code contest.
lifthrasiir
3 replies
7h45m

If you relax the "functionally" condition enough, it has been already shown that most paint splatters (including art pieces) are actually valid Perl [1].

[1] https://www.mcmillen.dev/sigbovik/

nightpool
1 replies
3h46m

I think the issue in this case is that the Perl programs were "really" created by OCR hallucinations, not graphic artists. Piet, on the other hand, is really executing the painting itself.

tlrobinson
0 replies
2h0m

I think in both cases some amount of interpretation was required:

- for Perl, OCR to a character set

- for Piet, manual “convert[ion] into a clean image file using close colours from the Piet palette”

dylan604
0 replies
32m

and yet, I can write a line of Perl today that I will not remember how/why it does what it does tomorrow. I don't know if this says more about me or the language other than I don't do it enough any more. However, the fact that paint splatters are better than I am is just proof that it is not the language for me

thih9
1 replies
7h54m

This is probably the first time in history that a graphic artist has painted a functionally workable computer program by accident

While impressive organically, it sounds easy when targeted; we could design a programming language where an image of Mona Lisa prints "hello world" - and claim a similar feat.

Perhaps the reverse is more interesting - programmers accidentally wrote a language that could treat real world abstract art as valid input.

cinntaile
0 replies
3h20m

Perhaps the reverse is more interesting - programmers accidentally wrote a language that could treat real world abstract art as valid input.

Isn't that what happened here?

mock-possum
0 replies
8h7m

Piet J. (yes, that's his real name) was browsing art in a small gallery and saw a work which reminded him of a Piet program. He spoke to the artist, who claimed to know nothing about the language. Piet took a photo of the artwork (left), converted it into a clean image file using close colours from the Piet palette (right), and tried running it.

It ran! The code executes an infinite loop which reads in ASCII characters and prints out the corresponding numerical ASCII values.

Get out of town. Get right out of town.

indigoabstract
0 replies
6h23m

It ran! [...] This is probably the first time in history that a graphic artist has painted a functionally workable computer program by accident.

I think this truly deserves a CS Ig Nobel Prize, if there were one, for making people laugh and then making people think.

boothby
0 replies
2h24m

Sadly, that depends on a discrepency between npiet and the current Piet spec:

The interpreter now begins sliding from its current white codel, in the new direction of the DP, until it either enters a coloured block or encounters another restriction.

The npiet interpreter, instead, rewinds its position to the last colored codel upon peeking through whitespace. One of these days, I intend to add that behavior as an option to the lexer in my Piet compiler[1], but I haven't bothered yet.

Following the spec, the program is a trivial nonhalting loop because the extreme corners of almost all blocks are white-adjacent. Writing complex Piet programs to target multiple interpreters and compilers is quite the challenge, as they've all got subtly different undocumented interpretations of the spec. I think that the output of my Piet backend is more or less interpreter-agnostic, but I've only dug into the details of three or four other interpreters.

[1] https://github.com/boothby/repiet/

blauditore
0 replies
3h2m

I wonder what the chances are that a simple painting like this (a few large rectangular blocks) is a valid program. From skimming the documentation, I tend to think even that every such image would run without error, given that "Any operations which cannot be performed (such as popping values when not enough are on the stack) are simply ignored, and processing continues with the next command."

However, another question is how many of such random images would actually do something "meaningful".

abrookewood
0 replies
8h6m

I just read that ... incredible. I mean the language itself is just bizarre, but that story tops everything.

sedatk
5 replies
9h54m

Piet is a milestone experiment among the esoteric programming languages, but I believe that it falls short of achieving its goal to make programs look like Mondrian paintings unless the developer really intends to do so.

I wish the language structure were designed in a way that anything that’s “written” with it would look like a Mondrian painting.

jack_riminton
4 replies
9h43m

Yes well unfortunately Mondrian only really used the primary colours so that would be rather limiting

wouldbecouldbe
0 replies
9h36m

just have to make them really big

shever73
0 replies
2h58m

It could be done. The FizzBuzzLang esolang uses only the words FIZZ, BUZZ and FIZZBUZZ.

euroderf
0 replies
8h53m

But FWIW Mondrian also showed how to convert a more conventional style into his signature style. This can be seen in Still Life with Gingerpot, numbers 1 and 2.

btbuildem
0 replies
5h31m

Could encode more operators into shape ratios / proportions, line thickness etc.

inglor
2 replies
7h44m

Needs a (1990) in the title?

juped
0 replies
5h48m

I don't think it's that old, but it's way older than 2018

andoando
2 replies
9h26m

Holy shit! Ive been trying to do something just like this for ages.

Wish the sample programs were shown in action.

pyinstallwoes
1 replies
6h14m

What were you trying ?

andoando
0 replies
1h1m

Still trying, but a programming language for visuals where one can define some primitive transformations like two blocks being added, a block moving through space, etc and use transformations to create bigger transformations and so on.

hansoolo
1 replies
8h1m

This is so cool! I wonder if it is possible to get a Piet piece together, where the program returns a certain text given. Like a Piet code generator...

Would make for a great present as print!

boothby
0 replies
2h19m

I did one of those for a codegolf challenge once, it was fun! DMM links to it on the examples page; I'm somewhat amazed that it's still up on pastebin.

https://pastebin.com/zxc9V3UX

WillAdams
1 replies
3h12m

This has always raised a question to me:

What does an algorithm look like?

Is there a real-world possibility of creating something like to _The Glass Bead Game_ from Herman Hesse's novel (originally published as _Magister Ludi_)?

As a visually oriented person, I'd like to think so, and have actually tried to use such tools:

https://community.carbide3d.com/uploads/default/original/3X/...

but the danger has been, for want of an unambiguous answer to the afore-mentioned question, they always run the risk of:

https://blueprintsfromhell.tumblr.com/

https://scriptsofanotherdimension.tumblr.com/

and it's hard striking a balance between visual expressiveness and modularity (which all-too readily results in the wall of text which one is presumably trying to avoid).

boothby
0 replies
35m

What does an algorithm look like?

Writing Piet by hand is a fun way to explore this. Sergei Lewis[1] and I[2] have each written tools to generate Piet code. Sergei's assembler makes much nicer looking code than my Piet backend. All you can really see from my compiler's output is that I'm really lazy and used a trampoline[3]

[1] http://www.toothycat.net/wiki/wiki.pl?MoonShadow/Piet

[2] https://github.com/boothby/repiet/

[3] https://en.wikipedia.org/wiki/Trampoline_(computing)

shrikant
0 replies
8h49m

I would have liked to call the language Mondrian, but someone beat me to it with a rather mundane-looking scripting language.

I'm dating myself with this reference, but some of us old data fogeys might be wondering (well, I am, at any rate) when Piet came out compared to Pentaho's OLAP engine called Mondrian (https://mondrian.pentaho.com/documentation/olap.php)...

sdmike1
0 replies
2h19m

I ran into this in university and burned a late night writing a simple program. It was a really fun experience that I would recommend people try at some point!

renke1
0 replies
8h18m

We had a small course in university on esoteric programming language. Each of us had to select a language (Brainfuck, Piet and a few others) and play around with it. I chose Piet and had a lot of fun with it, but to be honest, my small example application was not really aesthetically pleasing. I guess you have to be a Piet expert to make art with it.

nightpool
0 replies
3h49m

Piet is from 2009, at least. Although this page was last updated in 2018 with some new links i don't know if having the (2018) title makes sense, it feels kinda misleading

madcoderme
0 replies
2h46m

This is probably the first time in history that a graphic artist has painted a functionally workable computer program by accident.

More accurately, a programmer accidentally came up with a language that can run on real world paintings

einpoklum
0 replies
4h22m

Note that "light" is considered to be one step "darker" than "dark"

Now that's deep.

donalhunt
0 replies
9h15m

This is the type of thing, I'd expect to show up in a (crime) thriller, stumping the protagonist / investigators until someone deduces it's a code.

And we all thought QR codes were useful...

dang
0 replies
43m

Related. Others?

Simplified Piet interpreter written in Python - https://news.ycombinator.com/item?id=33130954 - Oct 2022 (2 comments)

Piet, a programming language in which programs look like abstract paintings - https://news.ycombinator.com/item?id=21913483 - Dec 2019 (19 comments)

Piet – A programming language in which programs look like abstract paintings - https://news.ycombinator.com/item?id=13503841 - Jan 2017 (12 comments)

Sample programs in the Piet programming language - https://news.ycombinator.com/item?id=11342442 - March 2016 (27 comments)

Piet – visual programming language - https://news.ycombinator.com/item?id=11266653 - March 2016 (1 comment)

Piet Program Gallery - https://news.ycombinator.com/item?id=7727702 - May 2014 (4 comments)

Enterprise Piet - https://news.ycombinator.com/item?id=4698737 - Oct 2012 (39 comments)

Piet: programming with pixels - https://news.ycombinator.com/item?id=2430357 - April 2011 (3 comments)

Piet is a programming language, whose programs look like abstract art. - https://news.ycombinator.com/item?id=1166462 - March 2010 (28 comments)

Piet: a programming language in which programs look like abstract paintings - https://news.ycombinator.com/item?id=235975 - July 2008 (1 comment)

And you thought BrainFk was hard to understand... - https://news.ycombinator.com/item?id=139872 - March 2008 (2 comments)

---

Bonus:

Mondrian painting has been hanging upside down for 75 years - https://news.ycombinator.com/item?id=33370228 - Oct 2022 (71 comments)

MalcolmDwyer
0 replies
5h34m

It would be interesting to relax the color requirements such that you could encode a program into what looks like image noise. Sort of like steganography, but instead of hidden data, it's a hidden executable program.