Book Image

Julia 1.0 Programming Cookbook

By : Bogumił Kamiński, Przemysław Szufel
Book Image

Julia 1.0 Programming Cookbook

By: Bogumił Kamiński, Przemysław Szufel

Overview of this book

Julia, with its dynamic nature and high-performance, provides comparatively minimal time for the development of computational models with easy-to-maintain computational code. This book will be your solution-based guide as it will take you through different programming aspects with Julia. Starting with the new features of Julia 1.0, each recipe addresses a specific problem, providing a solution and explaining how it works. You will work with the powerful Julia tools and data structures along with the most popular Julia packages. You will learn to create vectors, handle variables, and work with functions. You will be introduced to various recipes for numerical computing, distributed computing, and achieving high performance. You will see how to optimize data science programs with parallel computing and memory allocation. We will look into more advanced concepts such as metaprogramming and functional programming. Finally, you will learn how to tackle issues while working with databases and data processing, and will learn about on data science problems, data modeling, data analysis, data manipulation, parallel processing, and cloud computing with Julia. By the end of the book, you will have acquired the skills to work more effectively with your data
Table of Contents (18 chapters)
Title Page
Copyright and Credits
Dedication
About Packt
Contributors
Preface
Index

Julia IDEs


Integrated Desktop Environments (IDEs) are integrated tools that provide a complete environment for software development and testing. IDEs provide visual support for the development process, including syntax highlighting, interactive code editing, and visual debugging.

Getting ready

Before installing an IDE, you should have Julia installed (either from binaries or source), following the instructions given in previous recipes.

Note

In the GitHub repository for this recipe, you will find the SublimeText.txt file that contains configuration for Sublime Text described in this recipe. The configuration process of other IDEs described in this recipe is completely done with a point and click interface.

How to do it...

The three most popular Julia IDEs are Juno, Microsoft Visual Studio Code, and Sublime Text. In subsequent sections, we discuss the installation process for each particular IDE. 

Juno

Juno is the recommended IDE for Julia development.The Juno IDE is available athttp://junolab.org/. However, Juno runs as a plugin to Atom (https://atom.io/). Hence, in order to install Juno, you need to take the following steps:

  1. Make sure that you have installed Julia and added it to the command path (following the instructions given in previous sections).
  2. Download and install Atom, available athttps://atom.io/.
  3. Once the installation is complete, Atom will start automatically.
  4. PressCtrl + , (Ctrl key + comma key) to open the Atom settings screen.
  5. Select theInstalltab.
  6. In theSearch packagesfield, typeuber-junoand pressEnter.
  7. You will see theuber-junopackage developed by JunoLab—clickInstallto install the package.
  8. In order to test your installation, click theShow consoletab on the left.

 

Please note that when being run for the first time from Atom, Julia takes longer to start. This happens because Juno is installed along with several other packages that are being compiled before their first use. 

Microsoft Visual Studio Code

Note that at the time of publishing this book the Microsoft Visual Studio Code does not yet support Julia 1.0. However, since we believe that this support will be available very soon, we provide the instructions below.

The Microsoft Visual Studio Code editor can be obtained fromhttps://code.visualstudio.com/.Simply download the installer executable and install using the default settings. After launching Visual Studio Code, perform the following steps:

 

  1. ClickExtensionstab (or press Ctrl + Shift + X).

  2. In the search box, typejulia. You will see Julia Language Support on the list. Click the green Install button to start the installation.

  3. Click File | New File to create a new, empty file.

  4. Click File | Save As... to save the newly created file. In the Save As... type drop-down list, select Julia(please note that the file type list might not be sorted alphabetically and Julia type might be at the bottom of the list).

  5. Open the Terminal tab and issue thejuliacommand.

After following these steps, you will have a Julia file open in the editor and an active Julia Terminal. PressingCtrl + Enter will now send the currently highlighted code line to the Terminal to execute it.

Sublime Text

Another option for the IDE is utilizing the functionality of Sublime Text:

  1. If you are using Sublime Text, then add the package namedJuliathroughPackage Control.
  1. Next, the simplest thing to add is a custom build system for Julia (Tools | Build System | New Build System):
{
    "cmd": ["ConEmu64", "/cmd", "julia -i", "$file"],
    "selector": "source.julia"
}
  1. Now, you can execute an opened Julia script by pressingCtrlB in the console in interactive mode (-iswitch).

The preceding example assumes thatConEmu64andjuliaare defined in the search path. 

The only inconvenience of this method is that if there is an error in the Julia script, the console will be immediately terminated (a cleaner way to test your scripts is to keep your Terminal with Julia open) and use theinclude command, as explained in the recipe Useful options for interaction with Julia in this chapter. 

See also

For integration with other editors and IDEs, take a look at the https://github.com/JuliaEditorSupport project.