One third of the way to 100 programming languages
I'm still trying to write code in 100 different programming languages. My progress is being recorded in this repository. I'm roughly one third of the way to 100 languages already!
In this update, I explored stack-based languages and (unintentionally) traveled the programming language syntax continuum, from (almost) no syntax to (almost) only syntax.
Weeks 4 and 5
Given my previous struggles with Forth-like stack-based languages, I decided to focus on stack-based and/or concatenative languages.
RetroForth
RetroForth bills itself as a "modern, pragmatic Forth", and I agree with that description. It adds one-character "sigils" to distinguish numbers, strings, definitions, comments, etc. These sigils allegedly simplify the interpreter, and I think this one extra bit of syntax is helpful.
Overall, I enjoyed Retro's take on Forth, and I finally felt like I was making progress on creating simpler, more idiomatic Forth code.
Notes:
- Got in infinite loops several times
- Fatal errors are just numbers and I don't know where to look them up
Uxntal
Ever since reading about uxn, I'd wanted to see what a simple VM that runs on an NES could look like. After digging in a bit more, I learned that uxn was inspired by Forth--that got my attention!
After writing some code in uxn's assembly language (tal), I'll say that I mostly like uxn (the virtual machine), but... I don't like writing tal (the assembly language). There's a lot of syntax and aesthetic choices that irritate me.
Notes:
- Numbers must be written in lowercase hexadecimal (decimal is not even allowed!)
- Instructions can set a "keep" bit that causes inputs to remain on the stack
- The instruction set doesn't include modulus/remainder (why!?)
- Supports both global and local labels, which is convenient
- Instructions must be UPPERCASE (except for flags), but hexadecimal must be lowercase
- Names like
b1
aren't allowed because they're actually hexadecimal numbers... - Mixing 8-bit and 16-bit values on the stack is tedious
- Must specify
&
on relative references, but not@
on global references... - Pro tip: don't DUP relative addresses!
APL
After playing with J and K (although I couldn't actually find an official implementation of K5), it was time to play with their spiritual predecessor, APL.
With J, I felt like I was re-learning Perl-compatible regular expressions, but with a much larger menu of ASCII sigils. APL is the same, except I can't type (and don't even know the names of) the sigils. Overall, this was probably the most challenging syntax I've encountered outside of esoteric programming languages.
Factor
Factor is the niftiest concatenative language I've tried.
Intriguingly, it borrows heavily from Common Lisp (e.g. restarts, editor integration, multiple dispatch, image-based development). I'd even go as far to say that, in my limited experience, Factor feels like a concatenative expression of Common Lisp.
- Common Lisp-like restarts!
- This Factor tutorial is a great introduction--not just to Forth, but to concatenative languages in general
- Factor's compiler validates documented stack effects
- Factor supports editor integration, e.g. "go to definition"
- Can save images, refresh files from disk, etc.
- Built-in help
- Support for local variables, using
::
Rebol
Rebol is a minimal, but impressively capable scripting language. The entire language, including GUI support is well under 1 MB. How did I not run across Rebol when I was looking for a minimal development environment!? I only scratched the surface of Rebol, but it felt like exactly what I was looking for.
Having said that, I'm uncertain about the future of Rebol--it doesn't even appear to fully support 64-bit architectures.
Notes:
- Entire language is 440 KB!
- Used the console version
- Variables in functions don't default to locals!?
Bash
I've successfully been avoiding writing Bash recently, but I thought it might be fun to see what math looks like in Bash.
Notes:
- Ugly syntax (double parentheses, double brackets)
- Little inconsistencies, e.g.
fi
vsdone
- Lots of symbols to remember:
#
,@
,/
- But very widely deployed!
Julia
From my uninformed perspective, Julia looks like the language that academics should be using instead of Python. I probably shouldn't have said that, but there it is.
Notes:
- Excellent documentation!
- Base runtime includes a constant indicating the precision of floating points numbers!
- Has a REPL, but I didn't use it
- Built-in rational type!