STRANGE CODE
Esoteric Languages to Make Programming Fun Again
by Ronald T. Kneusel
San Francisco
STRANGE CODE. Copyright 2022 by Ronald T. Kneusel.
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.
First printing
26 25 24 23 22 1 2 3 4 5
ISBN-13: 978-1-7185-0240-6 (print)
ISBN-13: 978-1-7185-0241-3 (ebook)
Publisher: William Pollock
Managing Editor: Jill Franklin
Production Manager: Rachel Monaghan
Production Editor: Miles Bond
Developmental Editor: Alex Freed
Cover Illustrator: Gina Redman
Interior Design: Octopod Studios
Technical Reviewer: Robert Kneusel
Copyeditor: George Hale
Proofreader: Scout Festa
For information on distribution, bulk sales, corporate sales, or translations, please contact No Starch Press, Inc.
directly at or:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 1.415.863.9900
www.nostarch.com
Library of Congress Cataloging-in-Publication Data
Names: Kneusel, Ronald T., author.
Title: Strange code / by Ronald T. Kneusel.
Description: San Francisco, CA : No Starch Press, [2022] | Includes
bibliographical references and index.
Identifiers: LCCN 2022011375 (print) | LCCN 2022011376 (ebook) | ISBN
9781718502406 (print) | ISBN 9781718502413 (ebook)
Subjects: LCSH: Programming languages (Electronic computers)Popular
works. | MicrocomputersProgrammingPopular works. | Programming
languages (Electronic computers)History.
Classification: LCC QA76.7 .K59 2022 (print) | LCC QA76.7 (ebook) | DDC
005.13dc23/eng/20220429
LC record available at https://lccn.loc.gov/2022011375
LC ebook record available at https://lccn.loc.gov/2022011376
No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The information in this book is distributed on an As Is basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.
To all the souls whose beautiful obsession gifted us with such wonderful esolangs.
The late nights were worth it.
About the Author
A programming language enthusiast, Ron Kneusel had his first experience with programming languages circa 1980 when he first encountered an Apple II computer. Decades later, he completed a PhD in machine learning from the University of Colorado, Boulder, and now works in the industry developing deep learning systems. He is the author of Practical Deep Learning: A Python-Based Introduction (No Starch Press, 2021), Math for Deep Learning: What You Need to Know to Understand Neural Networks (No Starch Press, 2021), Numbers and Computers (Springer, 2017), and Random Numbers and Computers (Springer, 2018).
About the Technical Reviewer
Bob Kneusel has worked as a lead software developer and manager in the telecommunications field for more than 20 years. He has diverse experience in mobile application development, device control, and business process automation technology. In this time he has worked with a myriad of programming languages, including BASIC, 6502 machine code, Fortran, Pascal, ADA, Prolog, Lisp, Clipper, C/C++, Progress4GL, Java, HTML/CSS/JavaScript, jQuery[M], Python, and scripting (AOS/VS CLI, DCL, ksh, bash). He holds a bachelors degree in computer science and an MSc in computer information systems.
CONTENTS IN DETAIL
PART I
ON PROGRAMMING LANGUAGES
1
A CHERRY-PICKED REVIEW OF PROGRAMMING LANGUAGES
2
THE ESSENTIALS OF PROGRAMMING LANGUAGES
3
TURING MACHINES AND TURING COMPLETENESS
PART II
ATYPICAL PROGRAMMING LANGUAGES
4
FORTH
5
SNOBOL
6
CLIPS
PART III
ESOTERIC PROGRAMMING LANGUAGES
7
THE ABCS OF ABCS
8
FRACTRAN
9
PIET
10
BRAINFUCK
11
BEFUNGE
PART IV
HOMEGROWN ESOLANGS
12
FILSKA
13
USING FILSKA
14
FIREFLY
15
USING FIREFLY
16
GOING FURTHER
FOREWORD
Consider the following program:
Many who are used to modern programming languages will find this mystifying, yet it was not written in a deceptive style or an esoteric language. Some might recognize the funny w as a lowercase omega and place this as APL, a mathematical programming language created in the 1960s. This program calculates the first nine Fibonacci numbers (seven after the provided 1 1 ) using the power operator, drawn as a star with a diaeresis, a composite mark that has likely never found usein programming or natural languageoutside of APL.
Its also a glimpse of how different ordinary code" might have looked had language design taken a different path. Imagine an alternative computer history in which APLs style dominates. There, computer science is still a subdiscipline of math and this seemingly arcane mathematical lexicon is the norm. APL, after all, has its advantages. Its array-based approach is natural to engineering and scientific computing. Its single-character signifiers are concise next to let or Console.WriteLine . And these symbols are truly international, unlike the English keywords that dominate programming and are increasingly questioned by programmers from other linguistic backgrounds. Perhaps, in a world where APL is dominant, lexemes drawn from a single spoken language like English would seem strange.
In Strange Code, Ron Kneusel asks us to consider unusual languages in depth: those intended for practical programming (the atypicals) or for pure creative joy (the esolangs). Both expand our idea of what code might look like and bring new light to dominant programming styles that we might have accepted unquestioningly.
The atypicals were designed with the same goal as mainstream languages: to shorten the cognitive distance between what a programmer writes and what that code will perform. Only they have found more daring paths to that goal, or simply paths that have not been adopted into the prevailing style of commercial code. Take Forth, a beloved oddball language. Forth does its computation in the stack: it is a language where one must be aware of the state of the stack to understand just how an algorithm will unfold. Learning Forth leads to a different mindset than other languages, yet sometimes provides strategies that are useful in them.