Back in the day computer mags had 20-liner competitions. The objective was to cram as much functionality into 20 lines of BASIC and people did amazing stuff with that.
To use the space as best as possible lines were filled to brim and BASIC commands abbreviated. PRINT was ? and other command abbreviations contained PETASCII characters that don't even have a Unicode equivalent[1].
The Commodore 64 particularly had square[2] 8x8 pixel characters and a line on the screen was 40 of them in a row. A logical line from the BASIC interpreter's perspective was still 80 characters long though, which made the program effectively 40 screen lines high.
You see, where this is going. The perfect 20-liner was close to a 40 by 40 square of character salad.
[1] They were one letter and a shifted letter, which could be displayed as symbol depending which mode you were in. They were printed expanded when listing the program. Everything was a bit complicated.
[2] Almost. Pixels were not perfectly square, with the aspect ratio depending on PAL or NTSC.
dspillett 50 minutes ago [-]
> Back in the day computer mags had 20-liner competitions.
In the magazines I remember from my days cutting my programming teeth on an Acorn Electron, there were 10-liners and 1-liners. What some people could squeeze out of 252 bytes was very impressive, even without using extra features (extra graphics primatives for instance) found in other models like the Master series.
selcuka 4 hours ago [-]
There is a 10-byte assembler (Intel) port of the same program:
Current submission title “Print, a one-line BASIC program” is not great. Title from the page:
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
Could also be something like “10 PRINT: a book about a one-line Commodore 64 BASIC program” (taken from the first sentence with “is” changed to a colon).
kstrauser 7 hours ago [-]
From the text: “10 PRINT is a book about a one-line Commodore 64 BASIC program, published in November 2012.”
10 PRINT is their official shortened version.
mryall 4 hours ago [-]
TLDR: the program prints a pseudorandom sequence of characters 205 and 206, which on Commodore 64 are graphics characters similar to / and \.
When repeated across multiple lines, it looks like an intricate random maze. But it is actually just a visual representation of whatever PRNG is used on the platform, with the default seed as set by the BASIC interpreter.
For those that don’t know ascii off the top of the head, it prints either a forward or backward slash repeatedly, which in the c64 font creates a pretty art piece like the graphic at the bottom of the screen.
richardfey 2 hours ago [-]
I tried this on all the basic interpreters available on Ubuntu (yabasic, sdlbasic, basic256 and bwbasic), couldn't get it to work on any of them.
In a couple cases the only remaining issue was the lack of a RND() function definition
drzhivago 2 hours ago [-]
The referenced book was so good until the “considered harmful” sections. As it indicates, GOTO is basically JMP, and I’m sorry if someone is offended by BASIC, but it’s not only the subject of the book but was the promoted language to the masses for early microcomputers, such that people would buy the related BASIC book at the store, along with the computer.
kstrauser 7 hours ago [-]
This is indescribably beautiful. Thanks for sharing it! It went straight to the top of my reading queue.
To use the space as best as possible lines were filled to brim and BASIC commands abbreviated. PRINT was ? and other command abbreviations contained PETASCII characters that don't even have a Unicode equivalent[1].
The Commodore 64 particularly had square[2] 8x8 pixel characters and a line on the screen was 40 of them in a row. A logical line from the BASIC interpreter's perspective was still 80 characters long though, which made the program effectively 40 screen lines high.
You see, where this is going. The perfect 20-liner was close to a 40 by 40 square of character salad.
[1] They were one letter and a shifted letter, which could be displayed as symbol depending which mode you were in. They were printed expanded when listing the program. Everything was a bit complicated.
[2] Almost. Pixels were not perfectly square, with the aspect ratio depending on PAL or NTSC.
In the magazines I remember from my days cutting my programming teeth on an Acorn Electron, there were 10-liners and 1-liners. What some people could squeeze out of 252 bytes was very impressive, even without using extra features (extra graphics primatives for instance) found in other models like the Master series.
https://trixter.oldskool.org/2012/12/17/maze-generation-in-t...
10 PRINT is their official shortened version.
When repeated across multiple lines, it looks like an intricate random maze. But it is actually just a visual representation of whatever PRNG is used on the platform, with the default seed as set by the BASIC interpreter.
https://sta.c64.org/cbm64pet.html
In a couple cases the only remaining issue was the lack of a RND() function definition