Rust vs Python - Which language will win in AI race

Hi Rust Community,

As you all know, there is a lot of talk about AI and different AI models. I am now considering learning AI. But every repo I check is written in Python. So I want to ask you guys, as I am still learning Rust and it's exciting, can I learn AI with Rust? or in the future Rust can overtake Python, because I don't want to learn Python (the main reason it does not support type system).

Thanks!

For now you won't be able to avoid Python if you want to research or work with cutting-edge AI models.
Dynamic typing is annoying, especially that ML code tends to mix Python types, numpy, and torch types, and mixing them can have large performance overhead or even corrupt data.

For practical applications and running inference using well-known model architectures there's llama.cpp, in C++. Somehow its Rust equivalent didn't get as much traction.

I assume Rust is still very useful for gathering and preprocessing training data, and perhaps DIY-ing smaller classic machine learning algorithms, and creating applications in top of llama.cpp.

Learning Python will be very useful for many things, it is highly recommended to learn it.

For the specific case of AI, most of the utilities are in Python, well, they are in languages like C in Python modules.

And this is the reason why you should learn Rust and Python, to create AI modules for Python in Rust.

Depends what you want to do - if you start from first principles then rust is actually great. (You should not try to avoid python though - it is unavoidable).

Polars is rust and can be used from rust - or nushell if you want to work from the command line.

Instead of matplotlib you use gnuplot or plotters - gnuplot is half forgotten, but it is a great plotting tool.

There are crates with support for linear algebra and SciPy type algorithms. Clearly less mature than python - but on the positive side that means more opportunity to contribute :slight_smile:

Also - if you just want to call AI web API's and build applications based on trained LLMs then rust is fine too.

Sadly there is no way you are going to escape having to lean some Python if you want to play in the AI world. Pretty much everything is provided as Python modules and all the tutorials etc you find will be in Python.

As for "what language will win the AI race"... In reality no AI is actually done with Python. That would be glacially slow. So it's all C++ modules underneath.

Of course in reality no-one uses AI done in C++ and such either. All these huge models need GPU's to get them going at any reasonable speed, C++ and co don't run on GPU's. So I guess it's al CUDA underneath. I have no idea really, anyone here know?

Which part of "AI" do you want to learn? If you want to learn how artificial neurons and networks work. How back propagation does its magic etc the Rust is a fine language to experiment with such things. Which happens to be exactly what was doing over Christmas and New Year.

In my tinkering with writing neural networks from scratch in Rust and trying to train them gnuplot was the first thing I turned to to visualise what is going on. Mind you, I had to ask my AI Assistant for the gnuplot commands to do so....

Now I'm just starting to use plotters, works a treat.

Burn is very easy to use, while candle supported by hugging-face can free you from downloading libtorch and make things portable.

However, performance may be less important in AI related cluster especially in researching. Many who like Rust may think Rust is actually more suitable for machine learning coding due to its type system, but they choose Python because many of their cooperators use python and it costs much time to learn Rust.

In my country, many students even have no time to learn how to write Python in good manner, while most of the tutors still use matlab.

Back to the question, Ai related coding is actually too easy with frames like pytorch, tensorflow, burn and candle. And in fact, most of the time is costed in knowledge learning, multi-gpus debugging, cluster training, data process and so on. All in all, it's too easy, and many would just keep it as easy as possible.

However, maybe some enterprises will concentrate on the performance and stability for providing better service. But for us, who is learning ML, it's up to cooperators or tutor.

In the end, as the one who really respect to Ai, I asked if it wants to be written in Rust, it answers 'I wouldn’t "complain" about being written in Rust!'. Its attitude toward life is truly admirable.

Ha!

Above I mentioned I was tinkering with writing neurons and networks and doing back propagation from scratch in Rust. I told a bit of a fib. I asked my AI assistant to read a text describing how neural nets work and write an implementation of what it described in Rust. The AI Assistant was quite happy to do so and did a very nice job, clear to read and actually works!. I have been asking the AI assistant to expand and improve that neural network code.

Think about it.... I'm getting an AI assistant to create an AI. It's reproducing. I hope this does not get out of control!

In the education system of China, every student will learn Ai in political aspect for passing Postgraduate Entrance Examination.

About how to consider about Ai, the answer in book is:

  • Human social attributes are the essential attributes inherent in human consciousness, which artificial intelligence cannot truly possess. Ai are fundamentally machines rather than humans. They cannot truly have independent, autonomous, and conscious social activities, and it is difficult for them to become independent social entities with awareness of behavioral consequences, self-discipline, and social responsibility.
  • Artificial intelligence can obtain the contents of human consciousness that can be reduced to digital signals, but there are always many things in the human brain that cannot be reduced.

TLDR, in a humorous joke:
Q: What profession will never be replaced by Ai?
A: Accountant. Because Ai cannot go to jail.

In the end, I recommend a film named the wandering earth II. Although it may not as good as I think for you due to different culture, it discusses how human facing Ai to some extends.

Interesting. That seems to view consciousness as something that cannot exist outside of society and social interactions.

Contrast to Descartes's "cogito, ergo sum". Which to me views consciousness as a very personal thing. So much so that it only asserts that "I have conciouness" it does not say or prove that anyone else does. No society required.

Is this some deep different between eastern and western philosophies?

Anyway, in terms of AI. it sees silly to me to even question if it can or cannot have consciousness. We do not have any rigorous definition of consciousness, the above shows we don't even have the same ideas about what consciousness is.

1 Like

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.