avatarPaulo de Jesus

Summary

The web content provides a comprehensive guide on setting up a Rust development environment using Visual Studio Code on a Windows machine.

Abstract

The article titled "Getting started with Rust in Visual Studio Code" outlines the process for Windows users to set up a Rust programming environment with Visual Studio Code (VS Code). It emphasizes the growing popularity of Rust due to its memory safety and performance, noting its adoption by major companies. The guide includes steps to install VS Code, Microsoft C++ Build Tools, Rust, and the Rust Extension for VS Code. It also details how to create and run a basic Rust application within VS Code, utilizing features like IntelliSense and integrated source control. The article concludes with a note of gratitude to readers and an invitation to follow the author's future work on Medium.

Opinions

  • The author suggests that Rust's memory safety and phenomenal performance are key factors in its increasing popularity.
  • The author implies that Visual Studio Code enhances the Rust development experience with features like IntelliSense and integrated source control.
  • The installation of Microsoft C++ Build Tools is presented as a necessary step for Rust development due to Rust's reliance on LLVM IR compilation.
  • The author recommends the Rust Playground for those who wish to quickly test Rust code snippets without a full development environment setup.
  • The article expresses confidence in Rust's future, predicting it will become one of the top used programming languages in the next five years.
  • The author encourages readers to engage with their content on Medium by following them for updates on new articles.

Getting started with Rust in Visual Studio Code

See how to set up a Rust development environment on your Windows machine using Visual Studio Code.

Rust Language SVG Vector Logos — Vector Logo Zone

Interested in learning Rust? Rust is becoming increasingly popular, largely due to its built-in memory safety and phenomenal performance. With some of the world’s largest companies like Microsoft and Amazon adopting Rust in their own organisations, and supporting the development community, Rust is well on its way to becoming one of top used languages over the next 5 years.¹ For more information on Rust, have a look at the official site: Rust Programming Language (rust-lang.org)

You don’t need an IDE to develop in Rust, a text editor will suffice, but who doesn’t like having cool things like IntelliSense, and integrated source control, am I right? This article will show you how to set up a development environment for Rust by following these steps:

  • Install Visual Studio Code
  • Install Microsoft C++ Build Tools
  • Install Rust
  • Install Rust Extension for Visual Studio Code
  • Create and Run a Basic Rust App

Install Visual Studio Code

Visual Studio Code is a powerful development tool, with support for almost every programming language you can think of. You can download the installation package of the latest version here for free, and then follow the installation instructions.

Select the Windows option

TIP: If you just want to test snippets of code, without having to compile and execute your code, you can do so on the Rust Playground.

Install Microsoft C++ Build Tools

Confused as to why you need to install the C++ compiler for Rust?² It is required by the Rust compiler because Rust first compiles the code down to LLVM IR and then that gets compiled into machine language.

From the Visual Studio downloads page, look for the “Build Tools for Visual Studio” section and click the “Download” button:

Once it has finished downloading, execute the file from your downloads folder and follow the installation instructions.

Install Rust

To install Rust you first need to download the installation file from here:

To launch the installer, execute the rustup-init.exe file (from your downloads folder):

NOTE: If you haven’t already installed the Microsoft C++ Build Tools, the installation will show this as a required prerequisite and instruct you to install it.

Select option "1" (default) and press enter:

Install Rust Extension for Visual Studio Code

Next open up Visual Studio Code and click on the Extensions icon on the left hand side, type "rust" into the search, select the "rust-analyzer" extension, and then click the "install" button:

Create and Run a Basic Rust App

Press CTRL + ' (single quote) to open a new terminal window in Visual Studio Code:

Then change the working directory to wherever you what to create your application folder (I normally use a development folder on my C drive):

Then to set up a new project in the folder, type the following in the terminal window and press enter:

cargo new MyRustApp

Click on the Explorer icon on the left hand side and then click on the Open Folder button:

Then select the new application folder that you just created:

Click on the src folder and then on the main.rs file:

Press F5 to try and run the file in debug mode. Visual Studio might first detect that launch configurations missing. Click on the "Yes" button:

The launch configurations will then be generated:

Again, select on the main.rs file and press F5 to compile and run the app:

Since Rust is a compiled language, you will notice that in the target -> debug folder, there is an executable file for your application:

There we have it! 🎉 We have successfully greeted the entire planet, according to social convention, using Rust. It would have been rude not to.

[1] How Rust went from a side project to the world’s most-loved programming language | MIT Technology Review

[2] What is LLVM? The power behind Swift, Rust, Clang, and more | InfoWorld

Thanks for reading. If you like my articles and find them useful, please follow me on Medium.com so that you know when I publish any new ones.

Rust
Visual Studio Code
Data Engineering
Data
Windows
Recommended from ReadMedium