Magic in Programming
This blog is a history of myself exploring programming languages and how I believe avoiding 'magic' in languages affected my decisions.
Early on
My father taught me Ruby early on, before I learned to divide. I remember distinctly a lesson on 'magic' in the language, how some things the language weren't perfectly apparent and happened like 'magic'. I was quite fascinated in understanding the magic, what was hidden from me?
Ruby had a lot of magic, and some funny special characters like `@` to denote a global variable versus a local. I didn't have the resources to hunt down all of these peculiarities myself, I understood how most inferred casts happened; a tool every programmer ends up required to know and fix assumptions. I also learned some Python but found it had even more 'magic', and using whitespace as control flow hid when if and defs ended with invisible characters.
I read Code[1], or most of it, a wonderful step-by-step of how computers and their systems were built from simple circuits to the C language. This book most certainly formed most of my opinions such as avoiding analogies where possible, and cursed me with truly loving programming. I remember making the circuit diagrams in Minecraft via redstone.
Digging deeper I found C++, at this point most of the 'magic' was from inferred type casting, which was familiar anyways, and others debating the magic behind constructors and virtuals; it was easy to find more information on what was happening behind the scenes. I felt the computer and I were having an open dialogue, we could talk to each other properly. Still, I ran into curious bugs, but I was older and found solutions and the underlying communication issue my compiler and I were having. I was quite proud to know how to speak such intricate C++, this was bolstered by attending the local C/C++ meet up, where wildly smarter programmers attended and I soaked in as much knowledge as possible.
If I have seen further it is by standing on the shoulders of Giants
I adore this quote, only know finding out by Isaac Newton, one of my favorite mad scientists.
Now I normally program games, previously text based with Ruby and C++. Delving into graphics was daunting, knowing I don't like magic, understanding the entire rendering pipeline seemed impossible. Game engines such as Unity or Game Maker hid so much from me, and all the clicking around was strange. Programming to me was always text, not check boxes and menus. This stubbornness to only do what I could understand left me with SDL2 which is quite good all things considering other game engines including Unity use SDL2 at their core. However these game engines use many techniques and patterns for organizing and aiding development I stood to gain from learning.
At HOFT we made Vessels, my first time working with a team and using a game engine; Unreal 4 in this case. As a narrative game and the main programmer I was tasked to create a dialogue engine, this led me to create a language of my own to serve the game's narrative and gameplay purposes. In my language I set to have a very loud obnoxious error messages, extensible features, minimal special characters, and of course no magic. The "Airlock Dialogue System" worked well, being super-specialized meant I could even catch some hard to spot logic errors.
Rust Makes It's Mark
I hated Rust. I found it's copious special characters hard to track. Borrow checking fixed big memory issues, but logical issues seemed to remain untouched. Yet after spending so long with C++ I had neglected other languages, I felt the need to explore, nobody (other than the meet up group) loved C++ as I did, nor it's many intricacies.
My father had a book on Elixir[2] he's been excited about for a while, it was very new, but very 'magic'. I greatly enjoy it's pipe-function format when possible, and operating over sets of data immutably, but it's very slow and again very magic. I would love to find more use of Elixir.
As a game programmer I saw Jai as a very applicable alternative, with many interesting game-related features shown, fixing many under-the-hood issues C++ has with our game making industry. Although it's not publicly available, it gave a good lead for other languages.
Odin followed very similar syntax to Jai and at the time was almost always talked about with Zig. Comparing both Odin and Zig I quickly favored Zig for it's draconian anti-magic stances. Even casting was never inferred, something I have yet to see another language attempt and promote. Zig at version 0.6 drew all of my attention, I read the docs up and down finding any reason to use this woefully experimental language.
Getting Ziggy With It
Zig lacking OOP inheritance tripped my normal programming flow for a while, I defaulted to inheritance and runtime polymorphism more than I realized. Now I've taken to use less inheritance and more templates/generics if applicable or composition.
As I am now I love Zig, I hope the best for this language and a merry 1.0 whenever it comes. I look back on my C++ as a mountain of invisible details for anyone learning the language, when teaching Zig I find students appreciate the honest communication with the computer, stumbling less. This web server runs on zig!
I've opened my mind to the idea of some magic and special characters in languages, but like to avoid it where possible. I am able to program defensively knowing all those C++ quirks I once loved should be made as explicit as possible.