In this post, you'll see the difference between Rust and C/C++ in a developer’s perspective
C++ is an incredibly fast and efficient programming language. Its versatility knows no bounds and its maturity ensures support and reliability are second to none. Code developed in C++ is also extremely portable, all major operating systems support it. Many developers begin their coding journey with the language, and this is no coincidence. Being object-oriented means it does a very good job of teaching concepts like classes, inheritance, abstraction, encapsulation and polymorphism. Its concepts and syntax can be found in modern languages like C#, Java and Rust. It provides a great foundation that serves as a high speed on ramp to the more popular, easier to use and modern alternatives.
Now it’s not all rosy. C++ has a very steep learning curve and requires developers to apply best practices to the letter or risk ending up with unsafe and/or poor performing code. The small footprint of the standard library, while most times considered a benefit, also adds to the level of difficulty. This means successfully using C++ to create useful complex libraries and applications can be challenging. There is also very little offered in terms of memory management, developers must do this themselves. Novice programmers could end up with debugging nightmares as their lack of experience leads to memory corruption and other sticky situations. This last point has lead many companies to explore fast performing, safe and equally powerful alternatives to C++. For today’s Microsoft that means Rust.
The majority of vulnerabilities fixed and with a CVE [Common Vulnerabilities and Exposures] assigned are caused by developers inadvertently inserting memory corruption bugs into their C and C++ code - Gavin Thomas, Microsoft Security Response Center
Rust began as a personal project by a Mozilla employee named Graydon Hoare sometime in 2006. This ambitious project was in pre-release development for almost a decade, finally launching version 1.0 in May 2015. In what seems to be the blink of an eye it has stolen the hearts of hordes of developers going as far as being voted the most loved language four years straight since 2016 in the Stack Overflow Developer Survey.
The hard work has definitely paid off. The end result is very efficient language which is characteristically object oriented. The fact that it was designed to be syntactically similar to C++ makes it very easy to approach. But unlike the aforementioned it was also designed to be memory safe while also employing a form of memory management without the explicit use of garbage collection.
The ugly truth is software development is very much a trial and error endeavor. With that said Rust has gone above and beyond to help us debug our code. The compiler produces extremely intuitive and user friendly error messages along with great direct linking to relevant documentation to aid with troubleshooting. This means if the problem is not evident, most times the answer is a click away. I’ve found myself rarely having to fire up my browser to look for solutions outside of what the Rust compiler offers in terms of explanation and documentation.
Rust does not have a garbage collector but most times still allocates and release memory for you. It’s also designed to be memory safe, unlike C++ which very easily lets you get into trouble with dangling pointers and data races. In contrast Rust employs concepts which help you prevent and avoid such issues.
To how fast and predictable its performance is. Everything in our lives evolves. Our smartphones, our cars, our home appliances, our own bodies. C++ while still incredibly powerful, fast and versatile can only take us so far. There is no harm in exploring alternatives, especially one as exceptional and with as much promise as Rust.
What do you guys think? Have you or would you give Rust a try? Let us know your thoughts in the comments section below.
Thanks for reading ❤
If you liked this post, share it with all of your programming buddies!
Why is this <em>(adding a type with a value)</em> possible? (tried with g++ and gcc.)
(int) + 4*5;
Why is this (adding a type with a value) possible? (tried with g++ and gcc.)
I know that it doesn't make sense (and has no effect), but I want to know why this is possible.
This C# tutorial for beginners helps you learn C# programming from scratch. Watch this C# fundamentals for beginners tutorial and get started!
1 | Course Introduction
Hear an introduction to the topic, learn expectations for the series, and hear tips on how to get the most out of it. Plus, find out where to download the software you need.
2 | Creating Your First C# Program
Learn how to create a simple application, and get an explanation of common solutions to different problems you might encounter as you begin writing and compiling code.
3 | Understanding Your First C# Program
To better understand the grammar of C# at a high level, return to the program we just built to break apart each of the key words and symbols.
4 | Working with Code Files, Projects, and Solutions
Learn how to open and close individual files in a project, the relationship between projects and solutions, and more.
5 | Understanding Data Types and Variables
Add C# syntax to your vocabulary by exploring fundamental building blocks: data types and variables. In addition, learn about basic topics, such as naming conventions and data type conversions.
6 | The if Decision Statement
Get an introduction to the if Decision statement, along with the conditional operator. Find out how to refactor code to make it more compact and less likely to produce errors.
7 | Operators, Expressions, and Statements
Learn how to create a properly formed C# statement made up of expressions that include operators and operands. Hear about compilation errors that occur when the syntax rules of C# are ignored.
8 | for Iteration Statement
Look at several different types of iteration statements, how to utilize "code snippets" to help remind you of the syntax for this complex statement, and debugging in action.
9 | Understanding Arrays
Learn about arrays, and see how to declare and utilize arrays. Watch demos on a couple of powerful built-in methods that give arrays added features.
10 | Defining and Calling Methods
Create a helper method, create and call methods to retrieve a value, create and use input parameters, learn about string formatting, and create overloaded methods.
11 | While Iteration Statement
Learn a new iteration statement that allows you to continue performing a block of code until a condition is no longer true.
12 | Working with Strings
Look at built-in String methods to manipulate the content inside of a literal string and at the StringBuilder class for concatenating many strings together in a memory- and resource-friendly manner.
13 | Working with Dates and Times
Find out how to work with Date and Time data, how to create new instances of DateTime, how to add time, and how to format the data for display. Take a look at the TimeSpan class.
14 | Understanding Classes
Learn how classes are defined and new instances are created, how to define Properties, and how to both set values and get values for a given instance of the class.
15 | More About Classes and Methods
Dig into more details about classes: create a new instance, add class references, pass the reference to a method. Plus, review overloaded methods, static versus instance methods, and constructors.
16 | Understanding Scope and Accessibility Modifiers
Explore variable scope and how accessibility modifiers are used by the .NET Framework Class Library to expose or hide implementation of their given services to consumers of that given class.
17 | Understanding Namespaces and Working with the .NET Class Library
Learn about namespaces and how to find the classes for your applications by searching Bing and MSDN.
18 | Creating and Adding References to Assemblies
Learn about .NET assemblies: code libraries and executables, debug and release versions of assemblies. Plus, see how to reference assemblies, utilize NuGet, and create references to custom libraries.
19 | Working with Collections
See an "old style" collection, along with several of the newer, strongly typed generic collections (List and Dictionary) utilizing the generics syntax.
20 | Working with LINQ
Explore Structured Query Language and the LINQ syntax. See a demo projecting data onto existing types and new anonymous types.
21 | Enumerations and the Switch Decision Statement
See a demo on the use of Enumerations, create a custom enumeration, and then use it in a simple application that demonstrates a third Decision statement, the switch.
22 | Gracefully Handling Exceptions
Learn how to use the try catch finally block to anticipate potential problems so as to shield the end user from those problems as much as possible. Explore best practices when checking for exceptions.
23 | Understanding Events and Event-Driven Programming
Learn how events are utilized in the .NET Framework Class Library. Begin with the Timer class, and graduate to building a basic "Hello world" application.
24 | Where to Go from Here
Hear approaches to solving common issues, where to go for help, how to search for answers, and become part of the .NET community. View a long-term path to learn more about developing applications.
Thanks for reading ❤
If you liked this post, share it with all of your programming buddies!