Resend my activation email : Register : Log in 
BCF: Bike Chat Forums


Rust programming language

Reply to topic
Bike Chat Forums Index -> The Geek Zone
View previous topic : View next topic  
Author Message

Andy_Pagin
World Chat Champion



Joined: 08 Nov 2010
Karma :

PostPosted: 15:57 - 08 Feb 2018    Post subject: Rust programming language Reply with quote

Anyone got experience of Rust? Currently I use C++, is Rust any better and more to the point worth the learning curve?
____________________
They're coming to take me away, ho-ho, hee-hee, ha-haaa, hey-hey,
the men in white coats are coming to take me away.
Yamaha Vity -> YBR125 -> FZS600 Fazer -> FZ1-S Fazer
 Back to top
View user's profile Send private message Send e-mail You must be logged in to rate posts

Rogerborg
nimbA



Joined: 26 Oct 2010
Karma :

PostPosted: 16:22 - 08 Feb 2018    Post subject: Reply with quote

Better for what purposes?
____________________
Biking is 1/20th as dangerous as horse riding.
GONE: HN125-8, LF-250B, GPz 305, GPZ 500S, Burgman 400 // RIDING: F650GS (800 twin), Royal Enfield Bullet Electra 500 AVL, Ninja 250R because racebike
 Back to top
View user's profile Send private message You must be logged in to rate posts

barrkel
World Chat Champion



Joined: 30 Jul 2012
Karma :

PostPosted: 20:52 - 08 Feb 2018    Post subject: Reply with quote

Idiomatic Rust code is usually about as fast as idiomatic C or C++. So performance loss isn't normally something you need to suffer to choose Rust instead. (In some of my test programs, Rust was actually faster than C.)

It's memory safe. That's a major win; stay away from unsafe code, and you'll never get an access violation again; it's also substantially harder to create an unrooted memory leak (but nothing will stop you e.g. adding infinitely many items to a list, and you can create reference counted cycles).

The type system is much better. It's not as flexible, but it's better rooted in theory. C++ has a hacker's type system, with a variety of after the fact patches and fixes to try and fill in the holes, particularly around exception safety. Rust's type system is roughly based on ML, but adapted for execution on metal without GC.

Modelling data structures is much more tricky because of the constraints the type system, and in particular the borrowing system enforces. If you have cycles in your data structures, you're in for a somewhat painful time.

The borrow checker also makes writing concurrent code much easier. Again, it limits some idioms, but it's harder to get into trouble.

To write solid C++, you need to select a bunch of features that work well together, and then stay on the happy path. Wander off the path, and trouble will find you before long. There's an amazing amount of complexity in C++ - people have written books about how to e.g. write exception safe library code - and the language is full of traps for the unwary, like object slicing if you forget to hide your assignment operator, single-arg constructors acting like implicit conversions if you forget explicit, through to the awesomely complicated interaction between templates and overload resolution. Like I said, if you use your delimited subset of C++ and strictly follow a set of patterns, you can be productive. But if you're aware of the bubbling sea of shit underlying it all, you'll want something with more solid foundations.

Rust is something with more solid foundations. Not only do I think it's worth learning; I think people should stop coding in C and C++, and code in Rust instead. The world will have fewer bugs and security problems.

You do need to internalize how the borrow checker works though, and that takes time.
____________________
Bikes: S1000R, SH350; Exes: Vity 125, PS125, YBR125, ER6f, VFR800, Brutale 920, CB600F, SH300x4
Best road ever ridden: www.youtube.com/watch?v=s2MhNxUEYtQ
 Back to top
View user's profile Send private message You must be logged in to rate posts
Old Thread Alert!

The last post was made 6 years, 50 days ago. Instead of replying here, would creating a new thread be more useful?
  Display posts from previous:   
This page may contain affiliate links, which means we may earn a small commission if a visitor clicks through and makes a purchase. By clicking on an affiliate link, you accept that third-party cookies will be set.

Post new topic   Reply to topic    Bike Chat Forums Index -> The Geek Zone All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Read the Terms of Use! - Powered by phpBB © phpBB Group
 

Debug Mode: ON - Server: birks (www) - Page Generation Time: 0.06 Sec - Server Load: 0.07 - MySQL Queries: 17 - Page Size: 38.89 Kb