Noob question about Rust - Can/should I learn it?

Hi,
This is my first question here. I am a Tech Consultant who has done some scripting in Perl/Python. I know a bit of C, but nothing major. In the past I have written scripts that would SSH into devices, run diagnostic commands, filter only required output and email it to a distribution list. I’ve been reading about rust from a while and it seems to be a language generally preferred by folks who write systems software (which I dont think I will ever write).
I’ve also tried learning golang, but found it somewhat difficult to learn. My guess is Rust will be even more difficult to learn, so should I just focus first on getting even better with Python and then may be learn Rust? From what I see, Rust is preferred by seasoned/expert programmers/software engineers.

I am primarily looking for a language where I can write programs for REST APIs and may be create REST APIs. I am not sure if Rust is a good option for doing SSH (python has paramiko and I think it’s better suited for ssh stuff).
Please let me know.

1 Like

Welcome!

Python/Perl are dynamically typed. C has structs but not any advanced type system.

What is the longest Python/Perl program you have written? In my experience, once I hit around 5k Lines of Code, dynamically typed languages become very difficult to use because I can’t look at a variable and know what fields/methods it has. This then results in a very very strong incentive to learn a language with an advanced type system (like Rust).

As for learning Rust itself, I found it really useful to just type manually type in the examples at https://doc.rust-lang.org/rust-by-example/ , hit compile, and fix all the typos. This has the advantage that you can do it almost “mechanically” without much thinking – type, compile, fix typos – and after a while, you learn the basics.

6 Likes

Hi,
Thanks for taking time to reply.
My scripts have been extremely small. May be max 150 lines …

I suggest sticking with Python then, it’s perfect for programs and small scripts like that. For web programming, Python also shines: frameworks like Flask and Django give you a ton of functionality out of the box. The Python ecosystem is simply rich with libraries here, which means that you can make a production website or a REST server with very little effort.

In general, the special quality of a language like Python is that it doesn’t “get in your way”. They let you focus on solving the task at hand, and they’ll server you well for most small and medium-sized projects. Languages like Rust, C++, and others tend to demand much more upfront thinking from the developer. This means that it’s harder to experiment in those languages. The upfront cost you pay in such languages can save you time and effort down the line, if the system you work on becomes big enough.

The languages with static typing can also give you performance benefits compared to languages like Python and Perl. Most programs don’t really need to be exceptionally fast, but if you do need the low-level control and high performance, then you can get it in languages like Rust, C++, and similar.

10 Likes

Hi,
Thank you for taking time to answer. Answered like an honest engineer, but then, that seems to be what Rust is all about. No bullshit honesty :slight_smile:
If I may bother you with just one more question. I am finding it a tad bit hard to get into golang, but you think the effort of learning it is worthwhile? Or I should stick with Python like you originally suggested?
It’s just that the thought of installing a single binary without dependencies seems too promising to me, but hey, I could be wrong. Would be extremely thankful if you could let me know.

1 Like

Golang will help you over Python if you end up writing programs that are either too slow for Python (even after applying tricks and extensions to speed it up), or you write programs large and complex enough to benefit from a type system guiding you.

From your description it seems you’re not writing programs big enough for it to make a difference.

1 Like

It’s really hard to say which language to learn… Go is very popular in certain circles such as anything related to Kubernetes. The single binary deployments are indeed very nice — it comes out of the box with Go, and with Rust you need a few simple commands.

As for comparing the languages, then my take is that Go is much closer to C than to Python. It’s a very “friendly” C with garbage collection and modern features which makes it much safer and nicer to program in. You might like it, so I suggest taking a look.

Rust is a bigger and more advanced language: many more features, and as such, you get more control over the final result. The biggest difference to me is how Rust embraces abstractions whereas Go tries to make things so simple that you don’t bother abstracting over it.

1 Like

Hi kornel,
Thank you. You guys are awesome.
So what you folks seem to echo is I should stick with python and only if the situation demands, go for golang.
Understood. Thank you for your straightforward answers. Now I know what to focus on.

1 Like

Hi mgeisler,
Thank you again for your time and advice.