python or rust?

I'm starting out in programming and I was starting out in Python but I had a great interest in Rust because it's more complex and objective, would it be a good idea to leave Python and learn Rust?

Can’t it be both?

I think Rust is more useful in the sense that there’s more you can do with it. But there’s a lot you can do with Python as well. Not to mention that you can build Python modules in Rust, and call a Python interpreter from Rust.

2 Likes

Python would be easy to get started but the code is falling apart pretty quickly, especially in the hands of a novice. Soon after you start some project you will meet a lot of incomprehensible errors with convoluted causes and trying to figure out what went wrong and where.

With Rust, you will not be able to make a single step. But there is a The Rust Programming Language - The Rust Programming Language that will hand hold you and teach the required basics, and after that you will be able to write simple to medium programs and it will generally scale and you will not be catching some incomprehensible horrors as with Python. (Once I was working with pandas and numpy and after an hour of debugging strange failures and stack traces somewhere deep within pandas itself it turned out that numpy's NaN and pandas's NaN work badly together).

4 Likes

I would definitely take a look at and try both if you’re up to it. It really depends what you’re interested in, both rust and python abstract out low level concepts to a certain degree.

Python is a high level language, and has a ‘garbage collector’, so you do not need to think about things such as memory management; which makes it easy to learn, easy to write and read, and is a great tool for scripting as well. It also has a very rich library ecosystem that can pretty much do whatever you need. Games, AI, you name it, its there

Rust has high level concepts, with low level control. It is a steeper learning curve than python, but once you understand it, it is an extremely powerful and fun language to use. It doesn’t have a garbage collector like python, so you do have to think about memory management, It also has a strict data typing system as well which can be difficult to make sense of, but the compiler will help you through much of this. Also, Cargo is one of the best package managers I have ever come across as well, it is very easy to integrate libraries into your project. You can do anything, literally anything you want in rust and it will run great and avoid many of the pitfalls other low level languages inherently come with.

I recommend building a ‘somewhat’ simple project in both the to see the differences, a server/client project is a ton of fun and you can learn a lot about a language doing a project like that. The way I look at my journey of programming is, python was my first girlfriend, C was my first love and I am now married to rust. For me, I love having the feeling of moving around bits of electricity to perform some action on the computer.

Good luck! Life is short but there is enough time to learn both of these technologies and be proficient in both. Feel free to reach out for any questions.

2 Likes

Either is fine, but depending on your affinities with programming, learning Python first might make your learning experience much easier.

With Rust, you must learn not only the concept of programming but also the concepts of ownership, lifetimes, and sharing references. It's definitely a steeper learning curve. Also, Python is interactive, so it's a great way to learn.

Learning Python will always be useful to you as a programmer, anyway. I'd keep learning with that, even if for a while before taking Rust on. Unless you're feeling at ease with programming and eager to move on to Rust.

1 Like

Hello, @luck

If You are Beigneer Programmer I Recommend Start With Python First Because Easy Language and Scripting Language After You Learn Python You Can learn Rust

Back in the day, a long, long time ago, we were introduced to programming with BASIC and then were expected to become familiar with assembly language.

So my question is why leave Python? Why not pursue both?

I'm not sure "because it's more complex" is a good reason to want to learn anything. Besides I'm not sure Rust is more complex than Python. I'm into Rust for its performance and increased likely hood of correctness as my programs get bigger. Besides there are things Python cannot do, like accessing hardware in an OS or embedded system.

I would recommend using both based on your requirements.

Use Python for Machine learning, web development, scraping, automation. Use Rust when you need performance, system-level programming, game development, and Internet of Things (IoT).

2 Likes

I remember listening to a podcast from ARK invest and the guy
was talking about them setting up Monte Carlo simulations - and they
had done it in python. He said it with pride which I thought was
funny - you don't usually impress developers by mentioning python :slight_smile:

Python is so ubiquitous you will have to learn it if you spend time
programming computers. They ecosystem is huge - 2nd to none.

Python is very useful and easy to learn - the thing Guido had in mind when he invented
it was teaching kids to program. He didn't think about machine learning or writing
"large" programs - which people now do.

I mostly think of it as a scripting language - in the beginning it was an alternative to
bash, perl, awk etc. It is still that way, but now it is also an interface to Numpy, tensorflow,
polars etc. Python programs are best short in my opinion.

If you run older python code, you will often see they are quite stable across versions if
they are pure python. But modules often break - tensorflow 1.x vs tensorflow 2.x. Numpy is now version 2 - Scipy still requires version 1. Version hell.

The new uv package manager (written in rust) has to some extent fixed that - but it still exist - hard to fix sins of the past.

Another thing is duck typing - that is ok in scripts, but with longer programs it is better
to have more strict typing. The python does have types, and you can now type annotate - but the compiler just ignores it and you need a linter to see an effect. It is a limited type system compared to rust - numbers, strings, tuples and dictionaries are the main ones.

2 Likes

A good reason for learning Rust is that AI likes Python so much and excels with it, like with no other language.

Based on my experience, modern AI can generate Python code with ease. AI can give hints on how to fix some borrowing, too, and do some quite decent code review, but in general struggles significantly more with Rust code. This means more work for a human so you may get hired.

1 Like

In my experience my AI friends can generate Rust code competently as well. Perhaps not the most performant code but it works.

Perhaps I have not been asking it to generate code for big enough projects. I generally get it to do small sub tasks one by one, with tests and such, and then get it to put the parts together into the final program. The reason for that bing that I want to review everything AI generates as much as code/tests created by human team members might be reviewed. I don't want to have to review a huge wall of code all at once.

The beauty of getting AI to generate Rust is that the Rust compiler so fussy about types and object lifetimes that if the AI can get the code to compile there is a lot less for me to review, I can focus on the logic of the thing rather than have to look out for silly type and memory misuse errors.

I did try things the other way around. I write the code then ask my AI friends to review it. They seemed to be really keen to please me, writing long essays gushing over how well I had done things that I could not believe they had actually looked for any ways to correct or improve it.

2 Likes

I fully agree with this way of developing Rust with AI.

Also, I enjoy how the entire post is still 95% applicable if you replace mentions of "AI" with "less experienced developer(s)". :slight_smile:

Rust just helps people of varying skill levels stay productive, without having to prove out correctness of the lower level primitives for each and every change.

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