Why not just use JavaScript?

Dots, a piece of eight lines. All of it is shown further down.
It is the first question anyone asks, and it is a fair one. Nilo compiles to JavaScript. Anything it can do, JavaScript can do. So why not write that in the first place?
Because JavaScript does not know what I am doing.
It has no idea what a point is, or a colour, or a sheet of paper, or a token hash. So every piece begins with machinery: a random generator seeded from the hash, a way to hold a point, a way to mix two colours. None of that is the art. All of it has to be right, and when it is wrong nothing tells me. I get a piece that looks fine and comes out different the next time.
It is also untyped, which I have never liked. I can hand a width to something expecting a colour and find out only by looking.
And small JavaScript is unreadable JavaScript. My work goes on chain, where size matters. To get the size down by hand I would have to write in a way I could not read a month later.
Nilo splits those apart. The file I write is short and plain, in the words of the work. The file that ships is tiny, and I never look at it.
A whole piece
plate(1920, 2400)
random layout
background(#f4f1ea)
for i in 0 ..< 200 {
let p = vec(layout.float(0 ..< 1920), layout.float(0 ..< 2400))
circle(p, layout.float(4 ..< 40))
fill(#1b1b1f)
}That is everything. Eight lines, and every one of them is about the art.
It is not much of a piece. The point is what is missing from the file. There is no generator, no hash parsing,
no canvas setup. random layout gives me a source of random numbers that comes from the token hash, so the same
token always makes the same piece. If I forget and reach for an unseeded random, the compiler refuses.
It ships as 348 bytes.
What it costs
I should be fair about the other side.
- Nobody else knows this language. When I am stuck there is nothing to search for, only one reference page.
- My editor does not understand it yet. No colours, no hints.
- If something is missing from the language I cannot just write it. It has to be built.
For now I think the trade is worth it. I would rather wait for a word that fits than write forty lines around the lack of it.
The piece at the top
The image at the top comes from this token, built for the svg target: 0x3a7f3a7c00000000000000000000000000000000000000000000000000000000
plate(1920, 2400)
random layout
background(#f4f1ea)
for i in 0 ..< 200 {
let p = vec(layout.float(0 ..< 1920), layout.float(0 ..< 2400))
circle(p, layout.float(4 ..< 40))
fill(#1b1b1f)
}