Ask HN:
"Best programming language or theory to learn before learning Rust?"
(Replying to PARENT post)
In my experience, particular theory as in CS papers isn't needed for learning Rust. Understanding the runtime stack, RAII from C++ and malloc/free from C helps, but if you haven't already programmed in C and C++, it doesn't make sense to learn them in order to learn Rust. Any introductionary lecture on how the runtime stack works combined with the abstact idea of pointers to heap should be enough (no need to know how heap allocation works in detail).
(Replying to PARENT post)
(Replying to PARENT post)
You can learn all that from Rust, but it is possible you will have a better understanding of the design decisions if you have first experienced writing a C program and having it crash due to some memory management issue.
(Replying to PARENT post)
I would say start straight with Rust. Maybe you will find that it is not what you wanted/expected, and decide that another language will work better for you.
If you do like it and think itβs what you were looking for, you can always go back and read theory, other languages.
Despite its hype, Rust is no silver bullet(lots of unsafe calls in all libraries, mem leaks are still possible, etc..), so give it a go first and see if itβs indeed your cup of tea.
(Replying to PARENT post)
Go ahead and start learning all of the languages you are interested in. At the same time.
There isn't that much information to remember. Each language has simple grammar and only a dozen or two words.
The subtle differences between languages give context to each other.
(Replying to PARENT post)
(Replying to PARENT post)
The primary reason to learn it first is to focus on manual memory management. You could also just delve into C, but I still recommend just beginning with rust and skipping the cruft.
(Replying to PARENT post)
I'm not aware of a Rust from First Principles book or whether Rust is based on an underlying denotational or formal semantics.
However a good bet is mathematics. And you'd be best served by the typed lambda calculus, predicate calculus, and type theory. If there's one thing I've lamented it was missing out on learning early on in my career it was how to structure computer programs as mathematical objects. I've spent much of my life using the wrong metaphors.
(Replying to PARENT post)
If one needs cyclic data structures in Rust, the existing theory of functional data structures is a great model for how to solve such problems. Persistent and reference-count-friendly data structures are brothers from different mothers. Haskell enforces pure functionality. Then one can relax and use Rust, and its arcane features will actually come as a relief.
(Replying to PARENT post)
(Replying to PARENT post)
- working in ASM forces you to really learn the memory model, even moreso than C
- LC3 is a lot simpler than any real assembly so you'll learn it faster
- LC3 was made for students of programming and has documentation that assumes you're not too familiar with CS already
(Replying to PARENT post)
(Replying to PARENT post)
I don't recall which part of the course best covered ideas around scopes and their contents that will come up when you start thinking about memory in rust.. but it definitely wouldn't hurt to do all 3 languages.
(Replying to PARENT post)
If you just want low level acces to hardware it might be easier and more useful to learn C/C++. Easier concepts to grasp, more readable syntax and 1000x more avaible resources to learn or libraries to use.
(Replying to PARENT post)
Don't worry about the borrow checker, liberally apply .clone() every time it complains. Don't try and golf your initial designs. Lots of vec, .clone() and structs that own their contents.
(Replying to PARENT post)
(Replying to PARENT post)
(Replying to PARENT post)
Rust is like Bitcoin, everybody talk about it, but no one really use it.
(Replying to PARENT post)
I think it's a good place to start with memory management issues because you have to deal with it but good practice is enforced. C/C++ is the obvious alternative for that level of programming, but it's less constrained, which is better in some ways but bad in others. If you're wanting to learn Rust eventually, you might as well start there.
If you're wanting to not start with the low-level memory management stuff, and want an introduction to programming per se, there's lots of options.
One thing to think about is OCaml. It's a nice language, similar to Rust in some regards, and in fact Rust was originally written at least partially in OCaml, and for awhile was kind of discussed as a derivative of OCaml in some places. You'll get a mixed imperative-functional kind of introduction without going to quite as low of a level.
Another approach is to to just learn a language. In that case I'd probably recommend Python (probably Python 3) or javascript, because there will be a ton of resources and the skills will directly transfer. If you're looking for something that's maybe more niche but "clean" you could try Julia or Nim. Julia's very numerics focused and is getting used in that area, but doesn't get used out of that, at least so far. Nim is very very niche but a good language, similar to Python but faster and cleaner and some ways. Another thing to think about is Scala, which might transfer to Rust in some ways better than the others (except OCaml).
Honestly, though, I might just start with Rust. It will be heavy going at first, but I think learning the memory stuff is very very useful later. It depends, though. I think you have lots of good options. What's most important is to just dive into something that's interesting to you and start creating stuff, regardless of how small it is. A lot of concepts will transfer across languages.