Ask HN:

"Best programming language or theory to learn before learning Rust?"

πŸ‘€philonoistπŸ•‘7yπŸ”Ό89πŸ—¨οΈ66

(Replying to PARENT post)

Honestly, I might just jump in and learn Rust.

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.

πŸ‘€spruciefic399πŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

As with natural languages, if you want to learn language X, go learn language X and don't try to learn Y first. So if you want to learn Rust, learn Rust.

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).

πŸ‘€hsivonenπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

Do you know C or other languages with manual memory management? Rust requires an understanding of memory management at a level lower than what languages like Java, Python etc. expose. The complex parts of Rust (borrows checker, lifetimes etc.) are ingenious solutions to problems which simply does not exist in a safe garbage-collected language. And most Rust tutorials assume an understanding of the difference between stack and heap allocation and so on.

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.

πŸ‘€olavkπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

May I ask why you are interest in Rust so much that you are willing to invest time learning another language first before jumping to Rust? Is it the hype?

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.

πŸ‘€noncomlπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

Languages are never prerequisites for other languages.

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.

πŸ‘€thomastjefferyπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

I'd just get started with Rust. There are many great tutorials and references out there, and it's not nearly as hard or scary as some of its critics would have you think.
πŸ‘€zebraflaskπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

C++, but you're better off just starting with rust. C++ is a bottomless, dark pit.

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.

πŸ‘€sail0rm00nπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

I'd think about what your goals are.

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.

πŸ‘€agentultraπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

Haskell is the obvious answer. Rust is the bastard child of Haskell and C (my two loves).

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.

πŸ‘€SyzygiesπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

Depends on what you already know. If you've never programmed before, learn python first.
πŸ‘€sullyj3πŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

LC3 assembly. It won't seem related at first, but:

- 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

http://en.wikipedia.org/wiki/LC-3

http://lc3help.com

πŸ‘€scytheπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

If you haven't programmed at all, starting with Rust may be tough. It's probably easier to start with Python or Javascript to learn programming.
πŸ‘€AnimatsπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

Standard ML in the U Washington 3 language course is very much like the beginning of the rustbook yet without concerning yourself with any memory management.

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.

πŸ‘€yayanaπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

Just jump into Rust heads on. There's no better alternative if you want to learn Rust.

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.

πŸ‘€DeathArrowπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

Extend existing systems that you already know (at any level, user, programmer) with Rust. But extend them in the smallest possible ways, and then iterate. You will hit a wall, but you will have a concrete position to work from. Nginx, SQLite, Redis, Postgres, etc.

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.

πŸ‘€sitkackπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

Learn Zig (https://github.com/ziglang/zig). Aims to be lightweight alternative to Rust, similar to how C is lightweight alternative to C++. Both Zig and Rust use LLVM backend and borrow some concepts from the LLVM IR.
πŸ‘€isaachierπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

I am not skilled enough to make a recommendation but I wanted to say it all depends on your end goal and background. Rust like C and C++ is a general purposr language. I can imagine someone writing not just system apps but webapps and webasm in it(probably done already)
πŸ‘€badrabbitπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

Why not python or Go?

Rust is like Bitcoin, everybody talk about it, but no one really use it.

πŸ‘€lookggπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

I think Rust is a great first language to pick up. Pick a domain you are passionate about and start writing code for problems in the domain in Rust.
πŸ‘€dmanπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

A bit of C might prime you for understanding Rust's solutions to the the problems old system programming languages have.
πŸ‘€hatsunearuπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

If you're new to programming, learning Elm first might be easier.
πŸ‘€skybrianπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0

(Replying to PARENT post)

Rust is overrated. Take a look at D and Chapel.
πŸ‘€mabynogyπŸ•‘7yπŸ”Ό0πŸ—¨οΈ0