From Esolang
Jump to navigation Jump to search

Firefly is an esoteric programming language for the BBC micro:bit.


The micro:bit is a tiny single-board computer that runs Python. It supports several input and output devices, including a speaker (version 2) and a 5x5 array of LEDs, each of which supports ten brightness levels. Firefly is a tiny esolang meant to run on the micro:bit (or the console for program development).

The language follows a "Firefly" as it flies over the 5x5 grid of LEDs. As it flies, it leaves behind it a trail of light. In this way, the Firefly can draw pictures on the 5x5 grid. The language supports music and animation via double buffering.

Firefly is featured in Chapters 14 and 15, and the appendix, of the book Strange Code: Esoteric Languages That Make Programming Fun Again (No Starch Press, 2022).

Language Description

Firefly programs are strings of single-character commands. Some affect the Firefly's movement, others music output, and others which of the two display buffers is shown and drawn to. Any string of valid command characters is a valid Firefly program, which makes the language useful for genetic programming experiments.


Instruction Effect
N Move north
S Move south
E Move east
W Move west
T Stay put (tick of the clock)
0-9 Constant intensity value
I Increment the current value
D Decrement the current value
M Move only, no change in value
R Random value 1 through 9
X Show grid A
Y Show grid B
A Draw on grid A
B Draw on grid B
C Clear active grid
V Clear grid A
Z Clear grid B
J Set note duration
G Set octave
F Play a note
P Pause for 0.1 seconds
L Loop forever
H Halt



Firefly hi.png

Drawing "HI":

Bouncing Ball

Firefly ball.png

A bouncing ball (evolved screens):

Radar Sweep

Firefly radar.png

An animated radar sweep with "beep" (evolved screens):
YVA5383149W7EE27MEIMEWME4IEM6W74M975W932785MWWPPP PXZB37N387IM381IMIMW7495N19W645E8M9M4M188ISWMSEEP PPPYVA852MM7W4699793554MNE6791594415NSI6N42961MSS PPPPXZBMI57S49173ME83I613MN7MN6E18125IMN95EME5SMS EPPPPYVA1TJ7TF744299818E488E52I4M66I7M1462I5WW7E1 22IE1MWWPPPPXZB7E42943MSM76S6617EM55WI36M9454I57I 33M50WMNNPPPPYVA527S43M2S127778795N8E45MW57923311 776S277MNNPPPPXZB697SMW6W99857M662M377242MSI83W35

Computational class

Firefly is not Turing complete.