"Rust: The good parts" Core Language Features?

Hello :slight_smile:

I'm trying to learn Rust and I have big difficulties with it. :wink: Just as with C++ at some point in time I understood that I can not learn everything and that there are some aspects of that language I've never heard of and I do not need them and I'd like to do the same thing with Rust.
Do you know any good books or youtube tutorials which focus on core features leaving all the other things aside so I could learn them at later time or never if I do not need them? :wink:
Javascript programmers had the same issue with that language and someone decided to write JavaScript: The Good Parts to solve this issue. :wink:

btw I know that Rust isn't that big programming language but its syntax sometimes makes my head hurts. :wink:

ps
As always sorry for my bad english. :slight_smile:

Cheers.

Do you know about the Rust book?

2 Likes

The TLDR section from the 1st post from @pretzelhammer 's blog series might also be a helpful read :slight_smile:

Yeah I've tried to read it but somewhere in the middle I stopped and I do not know excactly why but as I've already mentioned this kind of books/tutorials where person tries to teach you everything does not work for me very well. :wink: Anyway I'll try some other sources but maybe Rust is not for me and that's all there is to it. :wink:
Cheers.

Hey, I don't know what kind of programming you do, or want to do, but don't give up so easily.

Rust has some valuable new concepts to wrap ones head around and like you I sometimes find the syntax infuriating.

The hardest of all the new concepts is all the stuff about variable lifetimes and the borrow checker. But as it happens you need to understand those concepts get programs working reliably in most other languages.

As for the syntax, well, I could say the same about any other language that is not the one I know well and have become comfortable with over years. One gets used to it.

As a noob, I have probably ignored large chunks of the Rust book. Macros for example, anything to do with async. At some point I picked up enough to get programs running and found myself getting on with that rather than learning more about Rust. I really should get back to my Rust study.

Stick with it, I have a feeling you will find the effort very rewarding.

3 Likes

Try Rust By Example.
I thought it was good years ago. At a glance now, looks a bit heavier than I remember.

Unfortunately there is quite a bit of must know concepts that can't be avoided, or you end up with unpleasant code.

2 Likes

Tech is an industry where imposter syndrome is all too common. Don't put yourself down so easily. I'm confident that if Rust fits your use case, it is the language for you! With an open mind, Rust does not fit every use case. In your shoes, I would try to answer the question from that perspective.

I guess I should add that the underlying subtext is the same as described by others. Learning Rust is like learning everything, really. There's a certain amount of effort that must go into it. And that can be translated into time. You didn't wake up one day with a complete vocabulary, for example. You also didn't absorb mathematics through osmosis. You spent a great number of years learning both, just as we all have.

3 Likes

As someone already mentioned Rust by Example is a good place to pick up the basics (even if you skip some sections). Being in the same boat as you, I found the combination of Rustlings, Exercism's Rust track, and official books works well.

IMO this was good a introduction: Intro to the Rust programming language - YouTube

I was thinking...

Douglas Crockford's "JavaScript: The Good Parts" is a catchy title to stimulate book sales. It plays on the commonly held notion that JS was a silly scripting language and mostly crap. A language on suitable for web developers to do simple things in a browser and that real programmers looked down on and would not deign to touch.

That is thesis I reject despite all the weirdness of JS' type coercions and such that people like to make jokes about. What the book actually did was make a good job of making people aware that JS was a pretty sophisticated language with features that many other commonly used high level languages did not have and have been trying to acquire since. For example first class functions, lambdas, closures, prototypical inheritance, asynchronous (event driven) programming model (Looking at you C++)

"The Good Parts" pointed out JS's sophistication while skipping over the "boring parts" that are common to all other languages.

Similarly the question here presupposes that Rust has a lot of parts that are not good. Which I think we can all agree is not the case.

The book "Rust: The Good Parts" might then be a slender volume that concentrates on all the special and somewhat unique features of Rust, for example the whole variable ownership thing, life times, traits, macros and so on. Whilst skipping over the boring parts that are common to most other languages. Hopefully presenting these concepts/features in a way easily digestible by regular users of other languages. It might not be the book you are looking for.

To be fair, the original implementation of JavaScript is exactly as you described. Unfortunately, the stigma persisted unnecessarily as the language evolved. I think the book title was a good move.

Applied to Rust, it does kind of imply that the language has "bad parts", which is debatable. It has things which some people dislike, but it has almost nothing that is universally despised. Compare to JavaScript, which still has its baggage from the old days...

I'm not sure what you mean there.

As far as I can tell JS was standardized very early on, before it had a lot of users. JS has remained compliant with the original standard whilst gaining some additional features with new revisions of the standard. That stability/dependability over time is a great asset to a programming language.

"Javascript: The good parts" was published in 2008 and describes the language prior to modern revisions of the standard.

Do you have specific example of what you mean?

I like the title as well. It's catchy and to the point. I see the book as a reaction to the fashion for ridiculously gigantic 10Kg tomes that were a popular way to write books about programming languages. Possibly the first time a book concentrated on JS as a language in it's own right without dragging in all the crap that is the DOM API and the browser environment.

Well, the language was originally created in 10 days (1995), so what can you expect?

Off the top of my head:

And of course, we can just let Brendan Eich speak for himself: https://youtu.be/GxouWy-ZE80

My only comment is that the language has a rich history, and the perception of early iterations of JavaScript directly influenced Douglas Crockford to address those concerns in his book. With special consideration to the title.

The Javascript creation story is indeed amazing. I'm not convinced that is the whole story though. Brendan was hired by Netscape to create a scripting language for the browser. He clearly knew a thing or two about language design and had a plan in mind, based on Self if I recall. Netscape did not like the syntax so he had those 10 days to recast it into something normal people would understand. An impressive feat none the less.

I am familiar with all those resources. The "wat" talk is typical of hundreds of such criticisms of JS all over the web. Everyone loves to point and laugh at JS. I don't really buy it. It's not that they are wrong factually. It's just that in practice they don't matter much. Most of the "wat"s are down to not knowing the language and expecting it to be something else.

One could make the same kind of "wat" talk about C (and by extension C++). Given that C has so many undefined behaviors, platform/compiler defined behaviors and general sloppiness.

Wat, you can index off the end of an array?
Wat, you can call a null pointer?
Wat, you can use uninitialized variables?
Wat, adding int's of 32767 and 1 overflows sometimes?
Wat, C does not have a string type?
Wat,...

I could continue, I had so many "wat's" during my first week or two learning C. I could not believe a high level language would be allowed to do that, as my programs crashed into oblivion often bringing the whole machine down with it. Forty years later and nothing has changed in C in that respect, nor C++ by extension.

And yet, those same "real programmers" who pick on JS would not dream of pointing fingers at C and laughing.

A book called "C: The Good Parts" would be very thin :slight_smile:

Some of these comments are getting close to language bashing, which isn't appropriate.

@twar, in addition to The Rust Programming Language book as already mentioned, you may be interested in a (paid) video series that @shepmaster and I authored called Rust in Motion, where we try to cover the concepts that are the most different in Rust compared to other programming languages. The hope is by learning these concepts, you'll have enough background to look up the syntax differences and APIs as you need them, but you won't get stuck on errors that talk about ownership, borrowing, and lifetimes.

No language bashing from me.

Javascript and C are 2nd and 3rd on my favorites list (not necessarily in that order) and still in use here. I don't anticipate that changing any time soon. As such I feel I have earned the right over many years to poke some friendly fun at them. Rust replaced ALGOL in top spot, with the important advantage that I can sensibly use Rust now a days.

If you hear me speaking of Perl, Python, PHP or pretty much any other language that will probably be bashing :slight_smile:

Hi :slight_smile:
I feel the need to explain myself :slight_smile: , when I was talking about good parts of this language I meant those that are most essential and not that there are some bad parts. :wink:
Ownership and borrowing I understand or at least most of it but some other things not quite. For example all those lifetime params for example, I do not know why there are needed, why sometimes they have to be specified and sometimes they do not. :wink:
And no, I'm not asking you to explain this concept to me but I'm just saying as an example. :wink:
I know C++ quite well but when I'm reading some of those Rust concepts I'm really scratching my head I mean literally. :wink:

If you read some of the other threads in this forum, posted in the last few days, that ask questions about lifetimes, you'll get significant understanding of what they mean, why they are needed, and how the compiler uses them to ensure that safe Rust does not lead to use-after-free and other classical memory use errors. (Note that both Microsoft and Google have recently stated that 70% of their major security vulnerabilities arise from such errors.)

1 Like

It's an odd thing. I know a good bit about C++, by no means all of it, I have used it on and off for decades.

C++ has me scratching my head more often than not.

Given the bugs that I have had to deal with when a team of contract C++ programmers is disbanded I gather that more serious C++ professionals than me don't understand it either :slight_smile:

Now if only said contract C++ programmers had enforced all the memory safety rules that Rust enforces I would not have been left with crashing applications to fix and memory leaks to to track down after they were gone.

In short, one needs to understand ownership and borrowing in C++ as well. One needs to understand lifetimes in C++ even if the language does not enforce it. If you don't your code will crash, produce random results or leak memory.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.