Jump to content
  • Advertisement
moeen k

Rust vs c++. can Rust Change the Future of Game making?

Recommended Posts

Hi.

i just hear alot these days about Rust language. it seems that it outperformes c++ and is faster than c++. its managed like c# and java and has not problem of memory allocation and management and has efficient Garbage collection system. there are some news that some studios prefer to start code on Rust and just use c++ for maintenance. like this:335465559_photo_--_--.thumb.jpg.39276e9410b886f6bdedff365e9b73b6.jpg

im just searching to see that is Rust worth learning for game development or not. as good replacement for c++ is there any plan to see gamedev Api,s like graphics API,s on Rust?

 

 

Share this post


Link to post
Share on other sites
Advertisement

I am just a hobby programmer, so what i write is probably not very ripe and sophisticated 🙂

I spent some time recently checking out Rust and D, very superficially. Rust has this site where they advertise their game ready-ness. I personally had problems with the syntax of Rust, that object.function..subfunction.whereisthis and so on. Also, the philosophy of "you can't count to 8 so i won't let you" wakes the rebel in me. Their learning tutorials spend too much time and space reiterating how it is different from the rest of the languages and that that is good. Actually, i'd like to see how a rust program really runs as fast as a good c program. They are a pretty committed community, so it appears to me.

I had more luck with D. Its syntax is pretty clear and there are actually games written in it, i found even a game engine, because C apis can be integrated without extra gymnastics. And it is not that much slower than C (Mandelbrot set ~30%) when compiled with gdc, the gcc front end for D. But the reference compiler dmd is much slower than gcc, really a factor of 2-3, probably due to bad optimization.

Am very interested in other, more experienced opinions than mine as well !

Edit: i read a gcc frontend for rust is in preparation/being spoken about.

Editedit: Yes, the tweet was proudly presented on the rust forums 🙂

Edited by Green_Baron

Share this post


Link to post
Share on other sites
7 hours ago, Green_Baron said:

i'd like to see how a rust program really runs as fast as a good c program

ripgrep is a good and fast program to to come from the rust community.

C api's can be bound in rust.
Rust is more restrictive than other languages, hence it's "guarantees". Some will like this, some won't.

Can rust change the future of game making?
I'll say yes, and it already has. Not in the sense that all games will be made in Rust, but that it will popularize ideas and then these ideas may be incorporated into c++.

i will say it is nice to have another systems level language. so far I've enjoyed it.

Share this post


Link to post
Share on other sites

Programming language of choice isn't what makes a program fast.  Sure, there are small benchmark type things (like doing matrix transformations, etc.), but those are not a reflection of reality.  It starts with the architecture of your program: how are your the different components defined and implemented?  How do those components interact with each other?  From those interactions, how is the data defined and how does the data flow through the program?  How many nested loops do you have in your functions? How many levels of polymorphism or inheritance? Then there is memory access, how cache friendly are the components in your program?  Are there a lot of components being iterated over whose data is only partially touched within a function?  If you are using a compiled language, do you know what all of the optimization flags do?  Last, know the platform that you are developing for.  Understand the hardware.  At risk of getting on my soapbox, the Right Once, Run Everywhere© mindset is why we have really bad applications that appear to run slower than programs written 20 years ago despite having processor speeds that are orders of magnitude faster (looking at you Photoshop). 

Programming languages are just tools.  Use the best tool for the task at hand.  Sure, you can use a hammer to drive a screw through a piece of wood, but you would find better (and neater) results with a screw driver.

Edited by ThorMalleuson

Share this post


Link to post
Share on other sites
On 9/23/2019 at 3:50 PM, moeen k said:

and has efficient Garbage collection system.

Note: Rust does not use garbage collection. It uses scope and lifetimes at compile time, and reference counts at runtime.

Share this post


Link to post
Share on other sites

thank you for answering my friends.i know games are developed with many different languages and many angines suport many languages but we all know c++ is most language near the hardware and gives lots of optimization responsiblity to developer. graphics APIs like DX and OPENGL officially are made to work with c++. graphics processing is based to with with c++.  one big example is that microsoft tried to make DX for c# but they couldnt as c# base features. now we have rust with mentioned features. i want to know can it replace c++ with these optimization features? @frob

Share this post


Link to post
Share on other sites

Rust positioning as alternate to C not quite C++.

But C dying 20 years and still young. :D

Share this post


Link to post
Share on other sites
7 hours ago, Plotnus said:

Note: Rust does not use garbage collection. It uses scope and lifetimes at compile time, and reference counts at runtime.

^ There's a lot of discussion here about Rust being managed and using a garbage collector - but Rust is not managed, it does not run atop a runtime VM and it does not use a garbage collector.

Rust does have a reference-counted smart-pointer, but so does C++, and that's not usually what is meant by the term "garbage collection".

This is why Rust performs comparably to C++ and could be used as a substitute for C++ if it met your needs (sufficient libraries, etc).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!