Watching an NDC talk about programming languages I saw this, an implementation of Fizz buzz in APL:
I haven’t ever touched APL, and I know it uses all kinds of weird letters and shapes, but I’m pretty sure it doesn’t use typographical quotes.
Or does it?
Yeah, no, it doesn’t.
Seems to be a case of “copied the code from a web page that performs ‘smart’
quote replacing”. That’s always annoying – not the copying part, but the fact that code on websites gets
demolished by brain-dead Wordpress plugins so often. Replacing the hexadecimal 0x
prefix
with 0×
in the text and even in font ligatures
plays on the same level…
But this got me thinking: How about a compiler that detects code with typographical “enhancements” copied from a website or a Word document and behaves differently? Like a quirks mode for code. Consider:
public class HelloPasteCode { public static void main(String... args) { System.out.println(“Hello world!”); System.out.println(“Hexadecimal 2A is ” + 0×2A); } }
Instead of spewing out ugly error messages:
> java HelloPasteCode.java HelloPasteCode.java:3: error: ')' expected System.out.println(ÔÇ£Hello world!ÔÇ?); ^ HelloPasteCode.java:3: error: not a statement System.out.println(ÔÇ£Hello world!ÔÇ?); ^ HelloPasteCode.java:3: error: ';' expected System.out.println(ÔÇ£Hello world!ÔÇ?); ^ HelloPasteCode.java:3: error: illegal character: '\ufffd' System.out.println(ÔÇ£Hello world!ÔÇ?); ^
…it could do the right thing and just run the copy-pasted code and present the result accordingly. In this context, redirecting STDOUT to a browser window seems approriate:
Of course, not without adding a subtle indicator that we are running in “pasted code quirks mode” at the end. 🤓
PS: To be fair, later in this talk an (unused) slide with well-formed code is rushing by, so there seems to be awareness of the problem somewhere:
Blog
- Dec 2024 – 3
- Nov 2024 – 5
- Oct 2024 – 9
- Sep 2024 – 6
- Aug 2024 – 5
- Jul 2024 – 6
- Jun 2024 – 6
- May 2024 – 7
- Apr 2024 – 8
- Mar 2024 – 4
- Feb 2024 – 9
- Jan 2024 – 10
- Dec 2023 – 8
- Nov 2023 – 1
- Oct 2023 – 5
- Sep 2023 – 5
- Aug 2023 – 8
- Jul 2023 – 1
- Apr 2023 – 1
Recently updated pages
- new art
- hrrngh!
- Knob-Out
- B.S.I. – Byte Scene Investigation
- Coppenheimer
- Hold mode minutiae
- Shall we play a game?
- Worms VBI
- strss
- Modding the Amiga boot hand
- More…