IDE:Visual Studio development environment for Raspberry Pi

In our last post we looked at Eclipse as a development environment on the Raspberry Pi. In this post we will look at Microsoft Visual Studio as an alternative. We picked these two to focus on because they are what most professional developers use in other environments. If you are planning on learning tools that will help with a career or job, there are the two that are recommended.

The key benefits for Visual Studio are that it works on multiple platforms (Windows, MacOS, and Linux), supports multiple languages ( C++C#GoJavaPython ), supports multiple tools (ESLintJSHint , PowerShell ), supports complex searching and multi-screen editing, and more.

Visual Studio is easily installed with an sudo apt-get install code command.

Instructions can be found at https://code.visualstudio.com/docs/setup/raspberry-pi on how to install and configure the environment.

Once the code is installed it appears on the pull-down menu from the top of the screen.

When the environment is first installed, a welcome window appears that walks you through the configuration. The first option is to select the languages that will be supported in the development environment.

We select Python first.

After a couple of minutes we can install C/C++ support.

Finally, we can select Java as our third language to support.

We will start with a Java Project. To create a new project, go to Files -> New File

Select New Java Project.

with no build tools

We select a folder to work in, HelloWorld

In this folder we create a new file

Adding the .java extension to the file name automatically classifies it as a Java file.

As we start typing Visual Studio start suggesting ways of completing the statement. In this example, the code suggested is for the main() routine to start the program.

As we type Visual Studio shows options for calls to the call you are using. In this example we started typing System. The IDE showed us multiple options including the out method call. Once we select out we have the option of various ways of outputting data. We select the printf() routine to print a string to the console.

If your code had errors or warnings they would appear on the left side of the line in question and hovering over the red or yellow icon will give more detail on what the problem could potentially be.

At this point we have the option of setting breakpoints, debugging the code, or simply running the code and looking at the console output.

Selecting the Run option we can see the output to the console

In the console window we see the compilation steps required and command line needed to run the code along with the output from the program to the console.

To build a Python file, click on File -> New File

We want to select a Text File type.

The IDE then asks what language we want the file to be.

If we save the file with a “.py” extension it automatically defaults to Python. Alternatively, we can click on Select a language to go to a pull-down menu and define the language type.

In this example, we can add the print() statement and run the program as a Python program.

If we wanted to do something similar with C/C++ we start with File -> New File

We then click to get a pull-down for language selection

From the Select a language link we get a list of potential programming languages.

We select C or C++ and get an option on what compiler to use

We select the default install gcc which will generate our C file.

From here we can Select Run which will compile and run the code. We can look at the compile output by clicking on the C/C++ header on the bottom right corner or look at the console output by clicking on the cppdbg header in the same area.

In summary, we have a professional development environment that supports Python, Java, and C/C++ in our Raspberry Pi environment. The installation was easy. The addition of additional languages was simple. The editing and debugging of the code is much better than the default IDE tools installed by default on the Linux operating system. At this point we can truly start developing applications using either the Eclipse IDE or Visual Studio IDE using tools and processes that professional developers use.