against my better judgement, i checked my twitter and noticed someone asking a bit about programming language design. so,
there's a lot of different axes by which you might judge a programming language, and these very often get mixed up. here's the ones that are most relevant for the impending rant:
- learnability: how easy it is to learn? how simple is the syntax, use of conventions or design patterns; are there good examples and tooling?
- improvisability: how much do you need to learn, before it becomes useful? can you keep going off a simplified understanding of it to do what you need, or does its full complexity hit you before you can get anything going?
- explicitness: how much does the code literally say, and how much does the compiler/runtime figure out? how much must the programmer spell out, and how much could i get out of reading it in a plaintext editor?
- defensiveness: how much does the language disallow? how often will it look at my "sensible" code and say, "are you sure? this doesn't seem quite right"
these, and others, combine to make up things like "conciseness" and "maintainability", and further into loosely-defined nonsense labels like "scripting languages", "beginner languages", and "enterprise languages".
now, what's often called a "beginner language" is one that focuses on improvisability, because it's being thrown at people who specialize in something completely unrelated to CS but need some calculations done. yeah, this is the only thing python's got going for it: you can know nothing about how computers work, and eventually limp towards something that achieves your narrow purpose.
and this comes at a pretty big cost to almost everything else. you can't ask the user to be explicit about what they're trying to achieve, even if they knew what that was, because you'd be spending weeks explaining type systems. you can't be defensive, because your entire purpose is to run anything that looks somewhat mathematical.
take the program:
x = 1
x = 2
by calling this "valid", we've already decided a lot about the language:
- variables don't need to be defined before use, or assignment causes definition
- variables don't need to be specified as modifiable, they just are (by default, but where would be specify otherwise?)
- we don't need line delimiters, everything fits on one line or we arbitrarily decide where to split multi-line code
- we don't need to write types, the language can figure it out
and all of these come at a cost to our defensiveness: we can't point out typos, accidentally reassigning the wrong variable, wrongly-parsed multi-line code... and it's important to talk about pointing out, because this is inherently tied to errors. this tiny language cannot provide the cohesive error reporting you get from "real" languages, but they are no less necessary for the beginner.
when you add more of python's decisions - common to other "simple" "beginner" "scripting" languages - it gets even worse. yeah, sure, imported code is just a variable you can overwrite. everything is dynamically typed at runtime, and even with source code type hints, our beginner is not annotating their own functions. of course the libraries you're using can redefine basic parts of the language and inspect your code, for your convenience.
eventually, they write something you cannot possibly make sense of - they trip up one of your various invisible rules, and you have to throw up an unintelligible error message. "something was nil in this massive list of functions" is probably all they'll get out of it, before looking for another tutorial to copy from or just rewriting the whole thing.
this isn't meant to belittle those programmers at all. it's just frustration at the languages, and the choices that lead to them staying in use...
and of course someone's going to look at it all and go "that's almost what we want, but what if we added even more non-standard layers to it & made all the pre-existing examples useless?" and they make GDScript. no, renaming callbacks doesn't make them less difficult to learn. no, you can't hack together your own shitty IDE and call it a day.
other kinds of "scripting" languages are in greyer ground. they often want to handle one-use programs that do a particular narrow task, maybe shuffling numbers from a bunch of files, and because they depend on the local computer so much, like, you can't do type safety when you're invoking a different statically-unknown program every line. but they would also benefit from the safety improvements... jury's still out on that one
eh, i'll continue this some other day, maybe i'll talk about what a "good" beginner's language would be like (and for what "beginners", anyways). enough for now
i have several Thoughts(TM) on this
first off, GDScript
it feels like they took python, went "how do we make this even more annoying?" and stuck it in an IDE worse than emacs; i just use C# nowadays even though it's worse documented and supported
funny you should mention rust, since that's part of why i came up with "improvisability" in the first place. beyond the smallest of rust programs, as soon as you start working with your own data structures, you need to understand what's going on, the language can't let you fudge it, that'd defeat the whole purpose.
but... honestly i hear a lot more complaining about "everything should be rust" fanatics, than i ever have seen these same fanatics. and i'm inclined to cut them some slack, because rust is working in a fundamentally different ballpark, and these criticisms - especially the conflation of "memory-safe" with "security safe" - usually miss that. maybe i'll write a post about that later...
anyways, i never meant to say that someone like you, with a decade in programming experience in multiple languages, should dislike python. in fact, i made it pretty clear that i was only going to consider one factor in that post: people who are new to programming and want to use it to fulfill a specific one-off or regular purpose, not interested in a lengthy CS education; it's why i focused on error reporting for most of it.
like you pointed out, it's good for frequently writing one-off scripts, and that's part of why it's used so frequently. all of it's scientific libraries make it very easy for someone to pick it up and start getting results out of it, relevant to their field, without too much specialized learning.
except, wait, someone needs to maintain those libraries still! you can't avoid needing to maintain code in the language. and sure, you could take an approach where important Library Code is written in one clear explicit style, and the users write in another Quick Fast Scuffed style; but now you've created a separate "learners' dialect", a sectioned-off part of the language where things are missing, that looks visually (and perhaps even functionally!) different to the stuff they're writing. they can no longer use them as relevant examples, or try to figure it out themselves.
and these libraries solve that with... more magic. more implicit operations, more overloaded syntax and "just pass whatever arguments we'll figure it out", all of which leads to worse and worse error messages. it gets harder and harder for anyone or anything to spot the holes in the code without intimate familiarity with the library, or cross-referencing against the examples given in the documentation.
(the documentation also gets improved though, i'll give it that.)
also, i've been getting more and more doubtful over time about how good programmers actually are at judging what's good for their use case. generally overvaluing "number of characters i need to type" over "the pain and suffering i'll experience reading this later", even in cases where it should be very clear that the code needs maintaining over time.
(read: don't make a fucking compiler in JS)
anyways, i think a broader point to be made is that "some programming languages are better than others" - i mean, it's true of every other tool ever created in the history of Tools, why not these? there's lessons to be learned from how languages have been used, to bring forward to newer better ones going forward. and sometimes people actively ignore those lessons, like in GDScript-
(PS: sorry if this sounded dissmissive or antagonistic, i just have a lot to say }:3)
