Hacker News new | ask | show | jobs
by 2ndorderthought 52 days ago
The first time I looked at rust code that wasn't in tutorial I was pretty confused. Things I thought I understood I really didn't. I knew maybe 6 programming languages including some c. A lot of people struggle to learn rust because it's an ML as in OCAML and really isn't much like C at all.

Some people adapt to it more easily, especially coming from languages like scala but it has a lot of unique characteristics that aren't in C or are even related. Like lifetimes, dynamic dispatch through enums, the borrowchecker, pattern matching, the ? Operator, etc.

Maybe you all are way smarter than me, super possible, but I wouldn't expect much to translate between go and rust. I think some evidence for that is the blog post here...

2 comments

Scala is a great language. And Rust definitely has noticeable influences from ML. But I’d say Rust is closer to C++ than it is to ML.

But, to be fair to you, I’ve not touched Rust in a couple of years so maybe my memory is fallible here?

I don't think it's a memory thing. The original rust compiler was written in OCAML. I think it's closer to an ML personally because of the strong focus on the type system rather than the chr* magic of c/c++.

Over the years c++ has been influenced to offer things people like from rust. So modern c++ looks a little more like rust. But older c++ really doesn't.

Similarly rusts approach to dynamic dispatch is more like OCAML than c++.

You can use rust and c++ for similar objectives though. Anyone can reduce two technical things until they are identical or expand them until they are completely different.

I think the most sober take is they are sufficiently different from one another.

I think the crux of our disagreement is this:

How much familiarity do you need to be starting from scratch?

In a later comment you said the following:

> You aren't starting from scratch in the same way that if you have written javascript you aren't starting from scratch writing c++.

But I’d argue that you wouldn’t be starting from scratch with C++ as a JS developer either because you already understand all the fundamentals of imperative programming:

- objects, properties and methods

- functions

- iteration (for loops are literally written the same)

- variable assignment

- expression notion and the order of precedence for operators

- global variables vs local variables

And so on and so forth.

Whereas going to ASM, LISP, Forth, or Prolog would require relearning everything you thought you knew about programming.

So to that point, once you learn Go, you could write a function in JS, C, Rust, and so on. You’d know roughly how to structure it and what syntax to use. You might not write the best and most idiomatic version of that function because you might not fully appreciate the differences with type system, variable referencing, macros, and so on. But that’s all knowledge you’d build upon from the experience you already have.

And the reason I make this distinction is because we were specifically talking about using an LLM for teaching.

To learn the nuances between languages of the same paradigm, the best way to learn is to write a project in that language. Whereas when going to something entirely alien like Prolog, you first need to learn the fundamentals (eg “from a book”) before you could even think about starting a project.

And what this guy did was work with an LLM on a project to learn the differences between Go and Rust.

So my point was those two languages are similar enough that the authors approach seems very reasonable to me. Whereas if he’d tried to do this with (for example) Haskell, then I’d have agreed with the naysayers.

Go stick a backend c++ ticket infront of someone who has never written it before but only knows javascript. Give them a PR with issues in it that aren't really whack. Ask them to do a code review. I would wager on the results in favor of them not being proficient in reading the code.

Now do the same with typescript. I bet they have a fighting chance.

You really think a senior C++ developer with 10 years experience and a mastery of C++ could not wing it and solve a JavaScript ticket even if they don’t have any JavaScript experience? Where they can ask a JavaScript developer about existing code.
And you understand 0% of the rust code? You could not understand anything? Wow.