contents/articles/hex.md
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
----- id: hex title: "Introducing hex" subtitle: "A tiny, minimalist, slightly-esoteric, concatenative programming language" draft: true content-type: article timestamp: 1734263361 ----- I have a page on my personal wiki system (which is written in [min](/min) with a [h3](/h3) frontend, and *still* closed-source) titled _Use cases for a new programming language_. The first line I wrote is the following: > A new programming language should only be created if it helps addressing a specific, practical use case Right. That was meant to dissuade me to embark in endless quests for creating yet another (pointless?) little language that _probably_ doesn't really solve any practical purpose. I have a bunch of those lying around or even half-designed in my personal wiki, and of course [min](https://min-lang.org) has been my go-to personal project for many years, and I still enjoy tinkering with it. But... I still wanted to create a new language. The problem with min is that by emphasizing practicality more and more, it became more of a single-file, batteries included programming language that can be used to create web servers, make HTTPS requests, process XML files, ...things like that. The syntax also evolved quite a bit to support complex data types, it has sigils and other oddities (bang-postfixed auto-popping symbols, anyone?). And it is also not that small anymore. Well over 1MB on some platforms. It statically links OpenSSL for Heaven's sake. And it is written in Nim. Because I forgot how to program in C. Sometimes I wish I invested the same amount of time in re-learning C rather than picking a new slightly non-mainstream language to build my ecosystem with. But it's fine, these are not regrets, everything helps shaping up the future, in life. ### Why _hex_? I wanted to create a language that was: - Really minimalist in syntax - Small in size - Cross-platform (compiling to WebAssembly and also [αcτµαlly pδrταblε εxεcµταblε](https://justine.lol/ape.html)) - Was implemented in C (that was more of a personal thing than anything else, but C ain't going anywhere as a language, at least) - Concatenative (I am still fascinated by the concatenative programming paradigm) - Able to do basic operations on strings and numbers, and delegate everything else to external programs - Able to be used to create shell scripts, used as glue code, etc. - It had some quirks. Not many, but _some_ to make it interesting and fun to play with - Be easy to learn and useful to learn more about concatenative programming Then the name. It took me hours of thinking over... weeks to come up with a good name. I then settled with _hex_ because: - It's short and memorable - It has not been used for another programming language yet (go try find 1-3 letter words that are not, you'd be surprised) - It has something magical about it (besides thinking about hexadecimal numbers, it also means _spell_ or a curse) ### MVPL (Minimum Viable Programming Language) Another page of my personal wiki aims at defining what constitutes a _minimum viable programming language_. Here's a list of things that I consider _mandatory_: v integers v strings v arrays v exec external processes v variables v define functions v flow control: conditionals, loops v error handling v file management v std io ...and here's a list of things that are _nice to have_: ? floats ? objects ? booleans ? lexical scoping ? serialization/deserialization ? regex ? networking ? xml ? json |