from Hacker News

Code Golfing in Commodore BASIC

by Two9A on 10/1/23, 8:46 AM with 40 comments

  • by wazoox on 10/2/23, 10:04 AM

    Back in the 80s when type-in program magazines were common, in France we had the wonderful "Hebdogiciel" with a perpetually running BASIC programming contest called "deulignes" -- which means "twolines".

    "Deulignes" programs could target any platform, but must only take 2 lines of BASIC (most implementations allow only a limited line length, often 255 characters).

    Some programs were really impressive; I remember one complete breakout implementation in MSX-BASIC for instance. People actually made whole (small) games in 2 lines of BASIC!

    Here's an example page : https://archive.org/details/hebdogiciel-french-098/page/n15/...

  • by bump-ladel on 10/2/23, 12:28 PM

    If you enjoy this, then you should definitely checkout 8-Bit Show And Tell’s YouTube channel. The presenter, Robin, regularly does deep dives into code optimisation and fixes on Commodore 64 and other machines.

    https://www.youtube.com/watch?v=jhQgHW2VI0o

  • by qiqitori on 10/2/23, 7:46 AM

    https://gkanold.wixsite.com/homeputerium/games-list-2023 Games written in ten lines of vintage BASIC. (Not related to the article but its title.)
  • by afro88 on 10/2/23, 10:46 AM

    BASIC defaults to the tape device if you leave off the device number in LOAD/SAVE commands. So you can save another byte or two by saving to tape instead.
  • by dep_b on 10/2/23, 8:01 AM

    In a C64 BASIC program keywords like SAVE and PRINT can be abbreviated:

    https://www.c64-wiki.com/wiki/BASIC_keyword_abbreviation

    That would shave off some more precious bytes!

  • by lifthrasiir on 10/2/23, 9:09 AM

    I don't know anything about C64 or C64 BASIC, but would it be possible to intentionally write a shorter binary which will break the interpreter and do what we want instead? For example jump directly to a middle of the kernel ROM routine (akin to ROP in the modern days), or use a bad address in the "next line" offset etc.
  • by einr on 10/2/23, 8:31 AM

    Using line number 1 instead of 10 seems like an easy 1 byte save.
  • by p0w3n3d on 10/2/23, 11:34 AM

    remember when people didn't have FDDs but cassete drives instead, because FDDs were too expensive? Pepperidge Farm remembers