Hobby programming has a long history of impressive demos or games crammed into a ridiculously tiny space. That tradition lives on today, in Mini Micro, in the form of tweetcode, complete programs in under 280 characters (small enough to fit in a BlueSky/X/Threads/Mastodon post).
In this post I'll share some history of the genre, including some great examples past and present, and show you how to get started creating your own tweetcode demos in Mini Micro.
BASIC 1- and 2-liners
In the early days of home computing, programming was almost always done in some variant of BASIC. Code wizards would craft BASIC incantations that did weird, fun, or surprising things in only one or two lines of code. Sometimes these were very short but interesting, like the famous "10 PRINT" demo (which now has its own website and book about it!).
10 PRINT CHR$(205.5+RND(1));:GOTO 10 This prints a forward or backward diagonal, without a line break, and repeats. The result is an infinitely scrolling maze-like display that's best seen live, but looks something like this:
Often the 1- or 2-liners made use of obscure features of the hardware they were running on, such as POKEs to stuff values into memory, or the way many early machines (including the Apple II) shared memory between the text and graphics displays. That was exploited in this one-liner from a Beagle Bros catalog:
2 PRINT CHR$(21):COLOR=2:FOR X=0 TO 39 STEP 2:FOR Y=1 TO 47 STEP 2:Z=Z=0:PLOT X+Z,Y:NEXT Y,X:POKE 37,255 ...which filled the text display with a checkerboard pattern, something you would never expect from looking at the code.
Here's an even cooler one, also from Beagle Bros:
4 HOME:GR:X=39 5 FOR A=B TO X:COLOR=A:HLIN B,X AT A:VLIN B,X AT A:NEXT:N=N+N=0:POKE 49232+N,0:GOTO 5 This produces an animated graphics/text display. Because it's animated, I can't include a great image of it here; I suggest you copy the above code, go to https://www.scullinsteel.com/apple2/, click the RESET key on the virtual keyboard, paste the code, and then type RUN (and press return/enter) to watch it go.
Computer magazines such as Nibble ran 1- and 2-liner contests. Here is a neat retrospective recently written by somebody who won such a contest with a fireworks display, in two dense lines of BASIC code. He was only 11 at the time.
And sometimes a 1- or 2-liner was a complete game, like the remarkable one-line "Asterisk Tracker" game for the BBC Micro, described here.
1L=0:REP.L=L+3:MO.4:DR.1279,0:DR.1279,452:MOVE1279,572:DR.1279, 1023:DR.0,1023:F.I=1TOL:V.31,RND(32)+5,RND(31),42,30:N.:P.(L-3) /3:X=0:Y=512:REP.PL.69,X,Y:X=X+4:Y=Y(INKEY-74+.5)*8:U.PO.X,Y)= 1ORX=1280:U.X<1280:V.7:REP.U.INKEY-99:RUN PICO-8 Tweetcarts
The PICO-8 fantasy console is a tiny virtual console programmed in Lua. Programs for it are often called "carts" (cartridges), and its community has embraced writing "tweetcarts" in 280 characters or less. Many of these are really impressive.
At PICO-8 Tweetcart Studies, a dozen neat tweetcarts have been collected, and each one broken down into less dense, fully commented programs so you can see how they work.
In most cases he also shows some variations, things you can tweak to change the effect or demonstrate the technique. This is exactly what we should do with tiny programs -- hack them, learn from them, make them your own!
Another great example is this random snowflake generator, right at 280 characters.
You can find more amazing examples at Postcart Gallery and Pancelor's Tweetcart Gallery
Finally, for insight into how these things are developed, check out this forum thread, where the group helps compress a complete Snake game into 280 characters.
Dwitter (JavaScript)
There's a JavaScript community that adopts an even tighter constraint: only 140 characters (not counting a standard support harness). You can view some of their work here. Many of these use a JavaScript trick to compress unreadable binary data into the tweet, but occasionally you find one using readable code like this:
for(i=!t<<21;i--;T=Y-X)x.fillRect(X=i%2e3,i/2e3,T>-1|R>.7,.4-(X=X/200-5,Y=i/4e5-2,R=X*X+Y*Y,R<1?R*T/2:C(e=(T-2)**2+(X+Y-.6)**2*6)/3*(e<5))) ...which produces cool fake-raytracing image:
Mini Micro Tweetcodes
The Mini Micro discord has a #tweetcode channel, and we have occasionally shared Mini Micro programs there, as well as on social media, that do fun things. For example, here's a 279-character program that draws a fractal fern:
import"tc";cls;x=0;y=0;for i in range(99999);g.setPixel 300+58*x,58*y r=rnd*100;xp=x;if r<1 then;x=0;y=0.16*y;else if r<86 then;x=0.85*x+0.04*y y=-0.04*xp+0.85*y+1.6;else if r<93 then;x=0.2*x-0.26*y;y=0.23*xp+0.22*y+1.6 else;x=-0.15*x+0.28*y;y=0.26*xp+0.24*y+0.44;end if;end for And here's a complete, playable game of Hangman in 276 characters:
import"tc" w=file.readLines("/sys/data/englishWords.txt").any s=["_"]*w.len t=10 p=@print while t p s.join if not s.contains("_") then p "YES!" exit end if g=input(t+"? ") k=1 for i in w.indexes if s[i]=="_" and w[i]==g then s[i]=w[i] k=0 end if end for t-=k end while p p w I've formatted this one here with line breaks and indentation; indentation doesn't count, as the editor inserts that automatically. You can use tc.check to both print the program in compact form, and report how close you are to the 280-character limit.
Here's a simple one by Discorde user @dslower that just bounces a UFO around the screen, like the classic DVD screen saver.
import"tc" s=spr("UFO") d=[3,3] clr "#333388" while true s.x+=d[0] s.y+=d[1] if s.x+54>960or s.x-54<0then d[0]*=-1 if s.y+32>640or s.y-32<0then d[1]*=-1 yield end while But, to be honest, Mini Micro users have not yet stepped up to the challenge like some other communities have. I'm hoping to change that.
Mini Micro advantages & challenges
Mini Micro is a higher-level computer than the PICO-8, and quite different from an HTML5 canvas too. It has pros and cons when it comes to writing tweetcodes.
Challenges
- Mini Micro 1.x is slower than PICO-8 or JavaScript. (Mini Micro 2 will be much faster, however!).
- The standard high-res (960x640) pixel display means a lot more pixels to push around when doing pixel operations. (You can scale it to make a lower-res display, however.)
- MiniScript requires some sort of separator (either a line break or semicolon) between statements, so you can't do stuff like
d={}u=0w=0y=4x=4p=print. - Mini Micro function names tend to be a little longer and more readable than the equivalents in other environments.
But balancing those challanges, we have:
Advantages
- Mini Micro has a rich library of built-in images, sounds, and even data files (like the
englishWords.txtfile used by the Hangman game above). - Its SpriteDisplay makes it easy to animate images, including rotation, scaling, and even stretching.
- It has a TileDisplay and a variety of built-in tilesets that could be put to good use.
- It can synthesize sounds on the fly.
- It has a text display (like the BASIC micros of yore, but unlike both PICO-8 and the Dwitter environment).
- It supports page-flipping through its 8-layer display system.
- It has a "tc" module that provides some support for writing compact code.
The tc module
That last point deserves some elaboration. In the /sys/lib directory is an import module called tc. This provides the tc.check function, which can measure the current program against the 280-character limit; but it also provides some handy short aliases for commonly needed APIs:
| Short | Longer equivalent |
|---|---|
cls | clear |
c | char |
t | time |
g | gfx |
k | key |
m | mouse |
µ | yield |
wget | http.get |
sd | display(4) |
tau, τ | 2 * pi |
π | pi |
e | 2.7182818284 |
pal | [color.clear, color.black, … color.white] |
oneTo(count) | range(1, count) |
rect | gfx.drawRect |
frect | gfx.fillRect |
oval | gfx.drawEllipse |
foval | gfx.fillEllipse |
circ | gfx.drawEllipse (by center/radius) |
fcirc | gfx.fillEllipse (by center/radius) |
clr(color) | gfx.fillRect 0, 0, gfx.width, gfx.height, color |
ln(x) | log(x, 2.7182818284) (natural logarithm) |
flip(d1, d2) | display mode switching |
flc(d1, d2, andYield) | flip + clr + yield |
img(name, folder) | file.loadImage with a search |
spr(nameOrURL, x, y, addToSd) | new Sprite + setup |
Importing "tc" gives you all of the above, in the global namespace, plus also imports standard modules stringUtil, listUtil, mapUtil, mathUtil, and qa. These give you a lot of tools to write compact code.
Gauntlet Thrown
I challenge you (yes, you*) to write something cool for Mini Micro in 280 characters or less! Here's how you get started:
- Download Mini Micro if you don't have it already.
- Use the
editcommand to start a program. You'll probably want to start withimport"tc"(note, no space is needed betweenimportand the quotation mark!). Follow that with whatever you dream up. - Press F5, click the Run button, or exit the editor and type
runto try it out. - Type
checkto measure your code and see how close you are to the 280 character goal. - Go to step 2 and repeat until done.
Then when you have something cool, share it! Post it to social media, ideally with a screen shot, and also share it to the discord and our forums.
I can't wait to see what you can do!







