💾 Archived View for tilde.club › ~sulaco › prog_lang.gmi captured on 2022-07-16 at 13:56:39. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

Aesthetically pleasing programming languages

I consider myself to be a hobby programmer. I like constructing something which strictly follows logical rules to produce the desired effect. This was always fascinating to me. Most of the programs I wrote are more or less simple toys with under 1k lines of code. I never tried to make a career out of it because I guess this would also take the joy out of it. The other thing I have with programming is that source code just looks so cool. As you may or may not know the beauty of how a programs flows over the screen is the most important aspect of any programming language. Here are my favorites.

Brainfuck

The complete language consists of only eight commands, so there is absolutely no chance of finding a disruptive character or construct in the source code (without comments of course). Since every command takes up only one character you can arrange your code to have the same number of characters on every line. This is absolute perfection:

,[++++++++++++++>>>+++++++[-<+++++++>]<--[-<++>]
<<[>[->+>+<<]>[-<<-[>]>>>[<[>>>-<<<[->>>>+<<<<]]
>>]<<]>>>+<<[-<<+>>]<<<]>>>>>[-]>[-<<<<<->>>>>]<
<<<+++++++++++[-<+++>]<[->>+<<]>>[-<+<+>>]>+<+++
+++++++[-<-------->]<+[>]>>[<<<-----------------
------------------------------>>>>]<-<<[-]<.,][]

Note that the last two instruction do absolutely nothing. They are only there to keep the character count per line even.

6502 assembler

Like in Brainfuck the character length of each instruction is constant. Each opcode consist of exactly three letters. Hex values are indicated by a lovely dollar sign, number literals by a hash. Every line of code is generally quite short. As long as you don't overdo your commenting the source code fits approximately in a nice square-like shape. Although your compiler is most likely case-insensitive you absolutely have to write your code ALL-CAPS:

;THIS SUBROUTINE ARRANGES THE 8-BIT ELEMENTS OF A LIST IN
;ASCENDING ORDER. THE STARTING ADDRESS OF THE LIST IS IN LOCATIONS
;$30 AND $31. THE LENGTH OF THE LIST IS IN THE FIRST BYTE OF THE
;LIST. LOCATION $32 IS USED TO HOLD AN EXCHANGE FLAG.

SORT8    LDY #$00      ;TURN EXCHANGE FLAG OFF (= 0)
	 STY $32
	 LDA ($30),Y   ;FETCH ELEMENT COUNT
	 TAX           ; AND PUT IT INTO X
	 INY           ;POINT TO FIRST ELEMENT IN LIST
	 DEX           ;DECREMENT ELEMENT COUNT
NXTEL    LDA ($30),Y   ;FETCH ELEMENT
	 INY
	 CMP ($30),Y   ;IS IT LARGER THAN THE NEXT ELEMENT?
	 BCC CHKEND
	 BEQ CHKEND
		       ;YES. EXCHANGE ELEMENTS IN MEMORY
	 PHA           ; BY SAVING LOW BYTE ON STACK.
	 LDA ($30),Y   ; THEN GET HIGH BYTE AND
	 DEY           ; STORE IT AT LOW ADDRESS
	 STA ($30),Y
	 PLA           ;PULL LOW BYTE FROM STACK
	 INY           ; AND STORE IT AT HIGH ADDRESS
	 STA ($30),Y
	 LDA #$FF      ;TURN EXCHANGE FLAG ON (= -1)
	 STA $32
CHKEND   DEX           ;END OF LIST?
	 BNE NXTEL     ;NO. FETCH NEXT ELEMENT
	 BIT $32       ;YES. EXCHANGE FLAG STILL OFF?
	 BMI SORT8     ;NO. GO THROUGH LIST AGAIN
	 RTS           ;YES. LIST IS NOW ORDERED

If you still not convinced keep in mind that the Terminator T-800 runs on a 6502 which is kind of awesome in itself.

BASIC

ALL-CAPS is equally essential in good old BASIC. Another nice feature of the language is that line numbers are mandatory:

100 REM+++++++++++++++++++++
100 REM+     COMPUTE PI    +
120 REM+++++++++++++++++++++
200 N=100:S=0:C=1/N
220 FORI=1TON
230 X=(I-0.5)*C
240 S=S+(4/(1+(X*X)))
250 NEXTI
300 PRINT"PI IS",S*C
320 REM=====================

As you can see you don't even need fugly white-space to program in BASIC. Nevertheless I inserted a space after each line number to create a perfectly straight vertical divider.