There's a 300-page MIT Press book analyzing exactly this line of code: 10 PRINT CHR$(205.5+RND(1)); :GOTO 10. It's free as a PDF and covers the mathematics (Truchet tilings), the C64 hardware, and the cultural history. The article doesn't mention it.
It takes 40 seconds to precompute the lookup table.
Robin released at least 2 faster/improved versions that run in a couple of seconds - less string concatenation which is slow in BASIC https://www.youtube.com/watch?v=Dw2hvtF95Qw
python3 -c 'import random, time, itertools; any(time.sleep(0.01) or print(random.choice("\u2571\u2572"), end="", flush=True) for x in itertools.repeat(None))'
Note that only Python standard modules are imported, no third-party libraries.
The “random” module is needed, because Python does not have a built-in replacement for BASIC’s RND(). The “time” module is merely to add delays, to emulate the style of normal BASIC interpreters on old – i.e. very slow – computers. You could remove it without any change in output. And lastly, the “itertools” module is used to get an infinite loop on a Python one-liner; Python, with its whitespace-based block structure, has a hard time doing anything significant in a single line otherwise.
Basically, folks compete to write the best, most interesting, most inspiring 10 lines of BASIC code imaginable .. and ooh boy, has there ever been some truly amazing stuff! A dynamically generated dungeon crawler, a full implementation of lunar lander, countless arcade-style games, an implementation of Brainfuck .. the list goes on and on .. all in just 10 LINES OF BASIC!
Another source of BASIC inspiration, I find, is in the synthesis one-liner scene - which of course, is dominated by the C64 for its synth goodness, but there are other examples out there where, in just a single line of code, entire techno and other electronic-music tracks are generated, on the fly, by ye' olde 8-bit computer of choice (C64, mostly, though..) The bytebeat techniques in use by some synth-one-liner hackers seem to be continually producing extraordinary results.
I think there is a lot of value in learning BASIC using these kinds of techniques in this day and age. I know for sure I'd struggle to have a full Lunar Lander or Asteroids implementation of just 10 lines of javascript, if that is even feasible .. but seeing so many BASIC implementations is just truly inspiring.
What we have lost in the rush for shiny bloat, eh folks?
The old adage that limits produce wonders, is never truer than in the 10 Line BASIC competition entries ...
Gun nut on the side, he had a rather ill-informed (at best) video on AI a while ago (before the current LLM craze), and has once done a pretty reckless attempt at repairing a unique IBM machine – as in, opening the PSU with a dremel tool and then then bridging a circuit with a paperclip.
I think it’s an embarrassing mistake that I probably would have entirely edited out if I were him. But I don’t watch his hardware restoration videos because he’s a source of electrical knowledge. They’re pure entertainment.
A lot of vintage restorers don't like him and people like him because he goes Wow! Look at This! and then suddenly a bunch of middle aged men with beards have that exact thing on their shelf. And those of us doing preservation and restoration suddenly are priced out of the hobby we've been in for decades.
Also, his technical "work" is not great. In fact, it's really bad. Even his successful fixes show a lack of attention to detail.
It's worth noting that he started his career as a computer scrapper.
The attention thing he can't be blamed for, and it's in any case a mixed blessing (more popularity of a specific retro computer can also have upsides for the existing enthusiasts).
He's definitively not the best hardware restorer. But his historical videos, his games and his X16 project are pretty nice.
Gun nut is fine. One can be a gun nut without supporting the awful ideas/people within that domain. It's the support of awful ideas/people in that domain them that make him "controversial" (a.k.a. anti-social asshole, that insist being an anti-social asshole is simply a personality trait, immune to criticism)
Oh that -- I used to print those out from my C64 to my Star Micronics dot-matrix printer and add selected white-out / ink to make them more interesting.
They did. AND, OR and NOT were bitwise operations as well as conditional operators. E.g. POKE 254, PEEK(254) AND 127 would turn off bit 7 of memory location 254 without affecting other bits.
There's a 300-page MIT Press book analyzing exactly this line of code: 10 PRINT CHR$(205.5+RND(1)); :GOTO 10. It's free as a PDF and covers the mathematics (Truchet tilings), the C64 hardware, and the cultural history. The article doesn't mention it.
All this and no link? Shame!
https://10print.org/10_PRINT_121114.pdf
All this and no link to past discussions?
2019 (142 points, 60 comments) https://news.ycombinator.com/item?id=19481207
Original/2012 (153 points, 89 comments) https://news.ycombinator.com/item?id=4856207
Not a one-liner, but I was impressed by this simple rogue-like written in 10 lines of BASIC:
https://bunsen.itch.io/the-snake-temple-by-rax
It takes 40 seconds to precompute the lookup table.
Robin released at least 2 faster/improved versions that run in a couple of seconds - less string concatenation which is slow in BASIC https://www.youtube.com/watch?v=Dw2hvtF95Qw
This isn't much impressive because can always import some package to do everything to you.
Note that only Python standard modules are imported, no third-party libraries.
The “random” module is needed, because Python does not have a built-in replacement for BASIC’s RND(). The “time” module is merely to add delays, to emulate the style of normal BASIC interpreters on old – i.e. very slow – computers. You could remove it without any change in output. And lastly, the “itertools” module is used to get an infinite loop on a Python one-liner; Python, with its whitespace-based block structure, has a hard time doing anything significant in a single line otherwise.
You could use `iter(lambda:1,0)` to get an infinite iterator, then itertools can be dropped.
Nice!
It's a classic, but removing the line number does not make it zero lines... :P
You could also argue the head compute does not make it faster tbh
It seems that the BASIC's of yesteryear still have a lot to teach us.
My favourite example is the annual BASIC 10 liner competition:
https://basic10liner.com/
Basically, folks compete to write the best, most interesting, most inspiring 10 lines of BASIC code imaginable .. and ooh boy, has there ever been some truly amazing stuff! A dynamically generated dungeon crawler, a full implementation of lunar lander, countless arcade-style games, an implementation of Brainfuck .. the list goes on and on .. all in just 10 LINES OF BASIC!
Another source of BASIC inspiration, I find, is in the synthesis one-liner scene - which of course, is dominated by the C64 for its synth goodness, but there are other examples out there where, in just a single line of code, entire techno and other electronic-music tracks are generated, on the fly, by ye' olde 8-bit computer of choice (C64, mostly, though..) The bytebeat techniques in use by some synth-one-liner hackers seem to be continually producing extraordinary results.
For example:
https://replicate.com/andreasjansson/synth-one-liner/readme
.. and a good treatise on the various techniques:
https://countercomplex.blogspot.com/2011/10/algorithmic-symp...
I think there is a lot of value in learning BASIC using these kinds of techniques in this day and age. I know for sure I'd struggle to have a full Lunar Lander or Asteroids implementation of just 10 lines of javascript, if that is even feasible .. but seeing so many BASIC implementations is just truly inspiring.
What we have lost in the rush for shiny bloat, eh folks?
The old adage that limits produce wonders, is never truer than in the 10 Line BASIC competition entries ...
8-bit Show and tell has a response: https://www.youtube.com/watch?v=Dw2hvtF95Qw
with an even faster implementation in BASIC (much lowers startup time).
The author of the article says the 8-Bit Guy is controversial. Why is that?
Gun nut on the side, he had a rather ill-informed (at best) video on AI a while ago (before the current LLM craze), and has once done a pretty reckless attempt at repairing a unique IBM machine – as in, opening the PSU with a dremel tool and then then bridging a circuit with a paperclip.
Yeah, that paperclip episode was where I stopped watching.
Same. Realized this guy is a total hack.
For reference, here is the video with the timestamp when he shorts the power supply with the paperclip: https://youtu.be/Wh2OCBZpzZ8?t=273
Instead of deleting the video and owning up to his mistake, he just deactivated the comments...
I think it’s an embarrassing mistake that I probably would have entirely edited out if I were him. But I don’t watch his hardware restoration videos because he’s a source of electrical knowledge. They’re pure entertainment.
Maybe it's because he's a bit of a gun nut on the side? He did some computer videos casually carrying a rifle of some kind slung over his shoulder.
I still enjoy his videos.
A lot of vintage restorers don't like him and people like him because he goes Wow! Look at This! and then suddenly a bunch of middle aged men with beards have that exact thing on their shelf. And those of us doing preservation and restoration suddenly are priced out of the hobby we've been in for decades.
Also, his technical "work" is not great. In fact, it's really bad. Even his successful fixes show a lack of attention to detail.
It's worth noting that he started his career as a computer scrapper.
The attention thing he can't be blamed for, and it's in any case a mixed blessing (more popularity of a specific retro computer can also have upsides for the existing enthusiasts).
He's definitively not the best hardware restorer. But his historical videos, his games and his X16 project are pretty nice.
Yeah, I've seen some fixes that gave me the wrong kind of goosebumps.
I like his history videos, though, for instance the ones that talk about graphics modes for a given computer.
Also, your bio says you don't shave. Sure you're not one of those bearded, middle-aged men?
I also live in my mom's basement and write currency libraries.
>currency libraries
Are there some hidden depths to formatting/converting that I'm missing? And yes. I know not to use floats
Most of his restoration work on videos limited to just being cosmetic at best with his expertise just being retrobriting.
When there was an issue on the motherboard, he almost always outsourced to his more tech-savy friends to fix it for him.
I find it funny that being Texan == gun nut. But I'm from Oregon, lots of OreGUNians around here.
Gun nut is fine. One can be a gun nut without supporting the awful ideas/people within that domain. It's the support of awful ideas/people in that domain them that make him "controversial" (a.k.a. anti-social asshole, that insist being an anti-social asshole is simply a personality trait, immune to criticism)
Nah these days you pick a team and cancel the other.
[dead]
Oh that -- I used to print those out from my C64 to my Star Micronics dot-matrix printer and add selected white-out / ink to make them more interesting.
> The 8-Bit Guy’s first nerd flex is making it shorter than one line.
Hate to be that guy, but a line you enter at the prompt is still a line, even if it's not part of an "actual" (stored) program.
The lookup table is interesting. I wonder why pretty much no 1980s home computer BASICs included bitwise operations?
They did. AND, OR and NOT were bitwise operations as well as conditional operators. E.g. POKE 254, PEEK(254) AND 127 would turn off bit 7 of memory location 254 without affecting other bits.
In which BASIC?
All the Commodore BASICs, Applesoft, GW-BASIC, QBASIC from what I remember. Very certain about the Commodore BASICs.
Nothing like ignoring the spirit of the thing by turning it from one line to nearly a dozen.
Think about it the other way: It's an opportunity to talk about lookup tables, loop unrolling and tricks like that.
Also, now different people are pitching in with their own takes, so it turned into a bit of friendly competition.