Computing: DOS, OS/2 & Windows Programming

Using VSCode as IDE for Julia development.

"Julia was designed with technical and scientific users in mind. These users often have very large data sets or very complex mathematical problems that they want to solve. This means they want to write code that can run on a computer very quickly, so that they don’t have to wait days or even weeks to get a result. Most of the programming languages that run very fast are also quite a bit tricky to use. For example, C and Fortran are known to be very fast, but they require that the user provides a lot of information to the computer about the program they are writing as they write it. This takes more time and often more programming experience than working in a language like Python. People used to think that you had to choose between a programming language that did your calculations quickly and one that took less effort to code in. Computer science is still a rapidly evolving field, however, and luckily the creators of modern programming languages are able to learn from all the programming languages of earlier decades. Julia was designed to give you everything – to be relatively easy and quick to write programs in, but also to run code and perform calculations very quickly."

The paragraph above is about how the developers of Julia describe this relatively new programming language on their website. An important point to add: Julia is entirely free and open source. You can download the Julia binaries (not only for Windows, but also for macOS, Linux, and FreeBSD) from the Julia Downloads webpage (another possibility is to get it from the Microsoft Store). This tutorial is about its installation (and its usage in VSCode; cf. further down in the text) on Windows 10; the Julia release that I used is Julia 1.10.2 (the 64-bit version, downloaded as Windows installer).

The installation is straight forward. Note that, by default, the application is not installed into the usual "C:\Program Files" directory, but somewhere within the actual user's AppData folder. In the Additional tasks window, be sure that Add Julia to PATH is checked!

Installing Julia on Windows 10 - Add Julia to PATH

Julia is shipped with a simple interactive shell development environment. It allows to enter shell commands, as for example ? for help, or exit() to leave the interactive session, as well as Julia statements; this is similar to database command line clients that allow to enter client specific commands as well as SQL statements. The screenshot on the left shows the main help page, the screenshot on the right shows the execution of some Julia statements. Entering expressions like an addition or a sine function will display the expression result. Note the assignment of the string literal "Hello World!" to the variable x and the display of this literal if you enter the name of the variable defined before.

The interactive Julia shell on Windows 10 - Main help page
The interactive Julia shell on Windows 10 - Execution of some Julia statements

This is nice, but for serious development, an editor with at least syntax highlighting, better an IDE that allows to highlight and check the syntax, and to run Julia applications is needed. There are several IDEs available, some specialized for the Julia language, others (like for example Vim) working with Julia as one of several programming languages. The article TOP 8 IDEs and Editors for JULIA on dunebook.com sees Juno as number one, other sites see the best choice to add the Juno features to Atom, the "hackable text editor for the 21st Century". However, if you visit the Juno website, you can read that the IDE will no longer receive updates, because the development focus has shifted to the Julia extension for VSCode. Using Julia with VSCode is without any doubt a good choice. It's about Julia with VSCode 1.82.2, x64, that the rest of this tutorial is about.

VSCode, by Microsoft, is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages and runtimes, among them a Julia extension. The IDE may be downloaded free of charge from the Visual Studio Code website. If you need help with the installation and/or usage, my tutorial Installing VSCode on Windows 10 (including details about how to build C and C++ applications) might be helpful.

You can install the extension directly from the Internet, or download it and install it from the downloaded file. That is what I actually did. The file, that I downloaded and installed, being julialang.language-julia-1.73.2.vsix.

Installing the Julia extension for VSCode on Windows 10

The screenshot below shows the description of the Julia extension for VSCode.

Description of the Julia extension for VSCode

Here is the code of a simple Julia "Hello World" program:
    msg = "Hello World! from Julia."
    println(msg)

Creating a Julia project and running a Julia file in VSCode is really easy. In Windows File Explorer, create a new folder (I called it "hello_julia") for the new project. In the VSCode Sidebar, choose Explorer (first icon on the bar), then push the Open Folder button. Browse to the newly created project folder to open it (you'll have to confirm to trust the authors of the files in this folder). Then, in the main window, click the New file... link and create the file that will contain your (main) source code (I called it "hello.jl"). Add the source code now in the editor window. Finally, to run the program, just push the Run button (triangle icon at the right side of the second horizontal command bar).

Running a simple Julia 'Hello World' program in VSCode [1]

The program output may be viewed in the Output tab of the Messages window.

Running a simple Julia 'Hello World' program in VSCode [2]

There is no build of an executable, so to run hello.jl in Command Prompt, you have to enter
    julia hello.jl

To terminate the tutorial, here is the code of a simple "Mandelbrot" program
    # Mandelbrot function
    # (code from: https://rosettacode.org/wiki/Mandelbrot_set#Julia)

    function mandelbrot(a)
        z = 0
        for i=1:50
            z = z^2 + a
        end
        return z
    end
    for y=1.0:-0.05:-1.0
        for x=-2.0:0.0315:0.5
            abs(mandelbrot(complex(x, y))) < 2 ? print("*") : print(" ")
        end
        println()
    end

And the program output in the Output tab of the Messages window.

Running a simple Julia 'Mandelbrot' program in VSCode

If you find this text helpful, please, support me and this website by signing my guestbook.