by petcat · 1y ago · 0 comments
Learning a first programming language is hard. And Rust will only make it harder since all you're going to do is debug compiler errors all day and never even see your program actually run until it's "perfect". This will be incredibly frustrating and you'll give up.
I always tell people to start with Python, JavaScript, or Lua. You can make something fun and interesting for yourself, like a game, and get immediate feedback and you can iterate quickly.
And theoretically, I'm not sure it's that very fun to run your game, have it crash because you passed a string to a function that expected an integer, stare at a backtrace, see where that variable came from, go up the call stack a few levels, and then realize "oh, i forgot to parse that string after the user typed it in". I'd rather get a compile error that underlines the problematic code and says "this is a string, but the function expected an integer". It may be debugging compiler errors all day, but the alternative is debugging runtime errors all week.
I think worst case it's a "sink or swim" course where a large fraction of the cohort wash out and that's bad for numbers (which will annoy bean counter but for a prestige university might actually be OK medium term) and best case the wash out rates are no different but the good students are receiving a lot more value than for today's First Language which is (at the university I'm thinking of) Python.
I think the move assignment semantic and the use of "const" to mean constant are examples of things where Rust is significantly penalized by having older languages teach their insane choices as just "How it is" so that then later a Rust course needs to have students un-learn this stuff when it would be easier to begin there.
Rust wouldn't be a bad language if humans were able to take it in all at once. The problem is, nobody learns like that and Rust is very hard to iterate on if you don't know a lot of the key concepts.
The problem with this is you'll necessarily have to unlearn something or be frustrated when you achieve some level of proficiency in other languages since it still requires all those concepts which don't exist anywhere else.
Don't get me wrong, I love JS/TS since before the "Good Parts" book ever came out. The only advantage it has as a first language is you can start tinkering directly in the browser... Which is something I use to this day... the debug console in the browser, I can exercise a generated API client before the UI features are flushed out.
If you want to learn with the intent of "I want to build $THING." then JS/TS is probably a great language to start with... you will probably want to read something like a for dummies book to start, then bootstrap with a coding ai... and tinker until it works. Note: don't do this for anything security critical when starting out.
Compiler errors are by nature often counterfactual: "compiler couldn't prove that this wasn't none" or "once you pass through this generic method it's no longer known that your list of Animal only contains members of Dog" is usually more confusing and less tractable than a concrete test case that craps out your program. Then you can start poking away with prints at the stacktrace.
If you step through every single line of your execution carefully and inspect all the data, you're virtually certain to unstick yourself. I can't say the same if you get some gobbledygook from the compiler.
I’ve spent most of my professional time in C, Ruby, and a decent amount of time dabbling around in functional languages. All of the core bits of Rust from this post more or less clicked immediately for me. The other features are there, but they’re typically not something you need to internalize to comprehend Rust as a whole.
The biggest hurdle—as for most people—was learning what the borrow checker is really trying to teach you about the structure of your programs and internalizing those lessons. But having some experience with RAII and good practices around manual pointer ownership in C helped pave a pathway toward understanding those concepts.