Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Julia 1.0 Programming Complete Reference Guide

You're reading from   Julia 1.0 Programming Complete Reference Guide Discover Julia, a high-performance language for technical computing

Arrow left icon
Product type Course
Published in May 2019
Publisher
ISBN-13 9781838822248
Length 466 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ivo Balbaert Ivo Balbaert
Author Profile Icon Ivo Balbaert
Ivo Balbaert
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Installing the Julia Platform FREE CHAPTER 2. Variables, Types, and Operations 3. Functions 4. Control Flow 5. Collection Types 6. More on Types, Methods, and Modules 7. Metaprogramming in Julia 8. I/O, Networking, and Parallel Computing 9. Running External Programs 10. The Standard Library and Packages 11. Creating Our First Julia App 12. Setting Up the Wiki Game 13. Building the Wiki Game Web Crawler 14. Adding a Web UI for the Wiki Game 15. Implementing Recommender Systems with Julia 16. Machine Learning for Recommender Systems 17. Other Books You May Enjoy

Startup options and Julia scripts

Without any options, the julia command starts up the REPL environment. A useful option to check your environment is julia -v. This shows Julia's version, for example, julia version 1.0.0. (The versioninfo()function in REPL is more detailed, and the VERSION constant only gives you the version number: v"1.0.0"). An option that lets you evaluate expressions on the command line itself is -e, for example:

julia -e 'a = 6 * 7;
println(a)'

The preceding commands print out 42 (this also works in a PowerShell window on Windows, but in an ordinary Windows Command Prompt, use " instead of the ' character).

Some other options that are useful for parallel processing will be discussed in Chapter 9, Running External Programs. Type julia -h for a list of all options.

A script.jl file with Julia source code can be started from the command line with the following command:

julia script.jl arg1 arg2 arg3

Here, arg1, arg2, and arg3 are optional arguments to be used in the script's code. They are available from the global constant ARGS. Take a look at the args.jl file, which contains the following:

for arg in ARGS 
    println(arg) 
end 

The julia args.jl 1 Red C command prints out 1, Red, and C on consecutive lines.

A script file can also execute other source files by including them in the REPL; for example, main.jl contains include("hello.jl"), which will execute the code from hello.jl when called with julia main.jl.

Sometimes, it can be useful to know when code is executed interactively in the REPL, or when started up with the Julia VM with the julia command. This can be tested with the isinteractive() function. The isinteractive.jl script contains the following code:

println("Is this interactive? $(isinteractive())")

If you start this up in the REPL with include("isinteractive.jl"), the output will be Is this interactive? true.

When started up in a Terminal window as julia isinteractive.jl, the output is Is this interactive? false.

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit https://github.com/TrainingByPackt/Julia-1-Programming-Complete-Reference-Guide.
You have been reading a chapter from
Julia 1.0 Programming Complete Reference Guide
Published in: May 2019
Publisher:
ISBN-13: 9781838822248
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime