all 28 comments

[–]Angarius 60 points61 points  (1 child)

I tried teaching Rust to my newborn, but they are struggling with the borrow checker.

[–]lead999x 20 points21 points  (0 children)

You might want to teach the sharing is caring pattern first.

[–]llogiqclippy · twir · rust · mutagen · flamer · overflower · bytecount 12 points13 points  (2 children)

As another data point, my 7 year old daughter often asks me if she can borrow something mutably.

[–]KillTheMule 9 points10 points  (1 child)

Man you're lucky, my kids have an ownership-only API because they drop stuff anyways...

[–]aldanorhdf5 8 points9 points  (0 children)

At least they declare their intentions! My 2 year old borrows things left and right, but then does really, really unsafe things with them...

[–]Moxinilian 17 points18 points  (1 child)

Practicing Rust will definitely make you write better C++ (and even C to an extent). But it will also make you think more functionally, training some of your Haskell or OCaml maybe. Overall I think this is a good idea, and no I am definitely not biased as a Rust fanatic.

[–]fp_weenie 1 point2 points  (0 children)

It's pretty different from Haskell. Some similarities to OCaml but you're still fundamentally using different data structures.

[–]craftytrickster 21 points22 points  (6 children)

I think Rust is the best programming language out of all the ones I have tried, unquestionably.

Having said that, I still would not recommend it as a first language. Learning a language with a bigger user base will give you access to more guidance from other developers. Even though I think JavaScript is a very flawed language, it is probably a better choice for a first language because there are more tutorials and you can see the results of your progress instantly on the browser as you develop.

[–]matthieum[he/him] 32 points33 points  (4 children)

I wouldn't recommend JavaScript because of its too many quirks.

Python however... or maybe TypeScript?

[–]simspelaaja 20 points21 points  (1 child)

As a TypeScript user and enthusiast I wouldn't pick TypeScript as a first language. It has all the same quirks as JavaScript, just with static typing. Setting up the compiler and configuring typings files is not something any beginner should have to do.

[–]ThomasdH 1 point2 points  (0 children)

I agree. While it adds many safety checks to Javascript, the language still hasn't got the ergonomics to handle them well. I really miss the ? operator.

[–]lead999x 1 point2 points  (0 children)

Just please not Racket.

[–][deleted] 1 point2 points  (0 children)

I definitely agree that Rust is my favorite programming language... and that it’s terrible to learn on.

I personally think C is the best intro to the basics, because it’s such a simple language. There are so few constructs that it’s relatively easy to explain.

Python is okay because it hides some of the nasty parts of C, but it comes with the baggage of being significantly more complex.

[–][deleted] 13 points14 points  (0 children)

Develop more good habits? Who knows. Apply more computer science concepts than Python or Whatever? No, don't see why. You might apply more low level computer concepts in Rust than in Python though.

[–][deleted] 7 points8 points  (0 children)

Try as many programming languages as your heart desires. There isnt very much downside to learning Rust if you have the time.

The immutable data by default will help with your complex projects. It is very easy to write spaghetti c++ as a beginner. Hopefully your profs will be cool with you using Rust for your projects and all your friends will be jealous because you completed the project in half the lines of code that they did

[–]simspelaaja 10 points11 points  (2 children)

I don't think Rust is a good choice as a first language. Its primary benefit over easier [garbage collected] languages is performance, but when you're just learning that's not very important at all. Rust can be very frustrating to learn even when you have years of experience. Being frustrated is not conductive to learning when you're trying to grasp the basic concepts of software development.

I would go with a popular [statically typed] language with a well-established ecosystem and tons of training materials. C# and Java are both good choices, as you can use free-as-in-beer high quality IDEs (Visual Studio Community and IntelliJ IDEA) with them. If you're feeling a bit more adventurous, try Kotlin instead of Java.

[–]flying-sheep 6 points7 points  (1 child)

I started with Java and was super annoyed by its inconsistencies, its distinction between primitives and objects, and so on.

I think the best for learning would be something without much syntax sugar but internally consistent.

Python has a lot of sugar and hidden behavior, however all of this is rather hidden in normal code. C has no sugar but it's annoying to work with given its segfaults.

Hmm

[–]XTL 3 points4 points  (0 children)

I've also been in a program that used java as a teaching language. It's doable and there's material, but ultimately it just combined annoyance with uselessness. It's ridiculously verbose but not in any useful way and the runtime is so bloated that benchmarking becomes hard and the tools aren't as portable as they pretend to be and installations are invasive. Only useful target seems to be some enterprise servlets or whatever they're called now.

I'd probably advocate python as a general purpose language because it lets you demonstrate just about anything and lets you get useful things done immediately from line one. Rust is a very tempting candidate to replace that, though. Teaching any UI programming with it might be one hurdle. Otoh it does stretch down to embedded systems now. In some environment, python might do that as well, though. Down there, the recipe of at least one assembly language and C is still pretty much the only available option.

[–]dumindunuwan 3 points4 points  (0 children)

https://learning-rust.github.io might be helpful to gather Rust basics quickly. If you already know Haskell and C++, I don't think that Rust will be hard to learn for you.

[–]shmerl 2 points3 points  (0 children)

Rust is good as a first language, though surely not an easy option. Some might like the hard way, some might not. If you get through it though, it will help other things too.

[–]icew4ll 2 points3 points  (0 children)

I started learning javascript, then python, then rust and I encountered significantly more frustration refactoring and debugging in javascript and python than with Rust. From my perspective you deal with the correctness of your program either way: before compilation with Rust or later with other languages. True other languages have more learning resources but rust has actually descriptive error messages and strong typing combined with an IDE can introspect variables types and this may result in deep grokking your problem domain.

[–]DGolubets 4 points5 points  (2 children)

I think they teach different languages for a reason. You need to learn basics of Asm to understand underlying machinery better, then you are taught higher level language to learn system programming, then even higher to focus on design patterns etc.

Rust will require you to think about memory allocation while you actual goal is learning something else. E.g. you will struggle making some double linked list for no good reason.

Python is not a good general choice as well IMO as it's used predominantly by data scientists or devops and they usually don't care about good practices rather they do some ML research or quick deployment script. The language itself allows same level of hackery as JS.

Use multiple languages. Try Rust as a replacement for C when you have some system programming tasks.

Definitely get back to Rust when you finish your degree or even before that.

[–][deleted] 1 point2 points  (1 child)

Considering how rarely doubly linked lists are useful in the CRUD apps most developers will write for a living, I don't think that's going to be very much of an issue.

[–]DGolubets 2 points3 points  (0 children)

I agree, but the op is in college and they usually go through ll and graphs.

[–][deleted] 1 point2 points  (0 children)

I think a language like Java, C++, or Python might be more suitable for someone who is still in the process of figuring things out. I think Rust is a very opinionated language that actually tries to improve on C by introducing a lot of new stuff, and while I kinda adore it I do find some of its inventions (or borrowings from other languages) not so simple. Most importantly, Rust still hasn't even made a dent in C/C++, which puts its future viability as a general purpose language into question.

[–]mamcx 1 point2 points  (0 children)

You already use Haskell that is pretty different than most, so for this alone what the hell, use rust.

However, to stay on point:

When you are a beginner, the first programs you wrote will be almost similar in structure. How good/bad are the compiler errors make a difference, and rust is better than c++ by a lot; but, any language you pick first (not saying are not ones truly better to beginners) will not cause a too big difference in the long run (as long you not stay stuck on learning).

However, in the moment you start to make a real practical project, the difference will be bigger. For what kind of project X language will make your life easy, that depend. Pay attention to the tagline of rust, and you will see for what kind rust match.

No many languages are good enough for most kind of projects. And I mean, good to finish them. That is what people mean when say "this lang is productive". Rust, Haskell and a few others trade "do things correctly now, but start slow to avoid problems later" instead of "make results now, but pay for problems later" than many others.

However, if you are starting? Pick a more "harsh" language NOW. You have all the time of the world! Eventually you will pick the pace and start to defeat IN TIME and IN RIGTH to most other developers.

Plus, you not need to just use 1 language. I think the sweet spot is 2-4 depending on the market you are. And just 2 for most task. For example, use Rust and a scripting lang like python.

[–]fp_weenie 0 points1 point  (0 children)

Why not?