brainbaking/content/post/2023/12/my-ideal-scripting-language.md

5.2 KiB

title date categories tags
My Ideal Scripting Language 2023-12-08T20:51:00+01:00
programming
programming languages

December marks the beginning of the countdown to Christmas, traditionally via Advent calendars. For us programmer nerds, a special one exists called Advent of Code where each December day before Christmas we're treated with a challenging programming puzzle. This year a good friend convinced me to join in on the fun and so far I have been really enjoying these silly me-moments.

But which programming language do you pick for such a task? Aha, hurdle number one!

This isn't just a stupid question, but boils down to: which scripting/hacking/prototyping language do you fall back on? Over the years, I've been back and forth various languages for this, and right now, I'm solving Advent of Code in vanilla JavaScript, but I don't think it's the best pick. I've had this debate with myself before when I was a jury member for the Vlaamse Programmeerwedstrijd (Flemish Programming Contest) where similar short and cryptic assignments appeared, and where I used JS, Kotlin, Go, Python, and a bit of Ruby.

What makes a great scripting language? I suppose that's a bit of a personal question and will boil down to preference---hence the title of this post is my ideal scripting language. Nonetheless, I'll try to unravel what I am looking for when coding smaller scripts.

Dynamics. If I'm scripting, I don't have the patience to think about types, nor about possible incorrect type inferences. The programming language should be dynamically typed by nature.

Quick Evaluation. If I'm scripting, I don't have the patience to wait for a compilation and don't want to execute binaries1. Additionally, it should be easy to execute the script, parse the results, etc.

Introspective. It should be easy to quickly try out different snippets, to gradually cobble together something working. That means a command-line based REPL at minimum, or more ideally an integrated evaluative environment that's easy to work with such as any browser's developer console or Elixir's Livebook.

Functional. I like map()/filter()/reduce() chaining and I hate it that I can't do that in Go---at least not without shimming my own. I never liked the way Python approached these either. That doesn't mean that the scripting language should be fully functional. On the contrary, I still want to be able to mutate things if I can't get things done in another way given the time constraints.

Easy to Read. A requirement of any programming language, but as during hacking I tend to be a bit less clean, I don't want to stare at syntax and wonder what that was for again (I'm sorry Perl). Again, chaining .map() for me is easier to read than Python's map() where you'll have to wrap around functions.

Batteries Included. As the famous Python saying goes...

Unit Testing Included. To extend the previous point, I want to quickly and easily be able to write a few unit tests to for example verify the Advent of Code's example input/expected output, and I don't want to bring in external dependencies just for that. Go's built-in test suite is great, and I recently discovered Node also comes with a test runner.

I'm a bit torn on debugging capabilities. Thanks to unit tests and quick evaluation, and due to the limited size and scope of scripts, I find myself needing these less. Languages that compile to other languages (anything on op of JS) or sit on top of the JVM (such as Groovy) do make this more complex.

And then there are requirements I don't care about such as speed (of execution) and ease of low-level (pointer) access.


Given the above requirements, most languages I am familiar with are disqualified, such as C, C++, C#, Java, Go, Kotlin, Groovy. Of course, (most of) these languages aren't designed with scripting in mind. The following languages---to a certain degree---meet the requirements: JS, Ruby, Python, PHP? I'd love to learn Elixir or Lua and dive deeper into a Lisp dialect or even the Pharo "immersive programming experience" to see whether or not I should start switching to something else besides vanilla JS.

It's interesting to read others' opinions on their ideal language. In GOTO 2021, Richard Feldman and Erik Doernenburg discussed their ideal general-purpose programming language, where Elm and Rust are the main stars. But when it comes to scripting, Python's huge community, built-in batteries, and ubiquitousness is admittedly very hard to beat, even though I prefer Ruby's [].size over Python's len([]). As an aside, if you want to entertain yourself on a rainy afternoon, try to search for "ruby vs python" and enjoy the bashing.

It looks like a lot of exciting languages I haven't played with enough also fit the bill. What is your favorite scripting language? Hopefully I'll be wielding another tool for Advent of Code 2024!


  1. Modern languages such as Nim offer ease-of-use features that lessen the pain of compiling, so I'm not completely set on this one. ↩︎