Balbaert / Salceanu | Web Development with Julia and Genie | E-Book | www.sack.de
E-Book

E-Book, Englisch, 254 Seiten

Balbaert / Salceanu Web Development with Julia and Genie

A hands-on guide to high-performance server-side web development with the Julia programming language
1. Auflage 2024
ISBN: 978-1-80181-095-1
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection

A hands-on guide to high-performance server-side web development with the Julia programming language

E-Book, Englisch, 254 Seiten

ISBN: 978-1-80181-095-1
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection



Julia's high-performance and scalability characteristics and its extensive number of packages for visualizing data make it an excellent fit for developing web apps, web services, and web dashboards. The two parts of this book provide complete coverage to build your skills in web development.
First, you'll refresh your knowledge of the main concepts in Julia that will further be used in web development. Then, you'll use Julia's standard web packages and examine how the building blocks of the web such as TCP-IP, web sockets, HTTP protocol, and so on are implemented in Julia's standard library. Each topic is discussed and developed into code that you can apply in new projects, from static websites to dashboards. You'll also understand how to choose the right Julia framework for a project. The second part of the book talks about the Genie framework. You'll learn how to build a traditional to do app following the MVC design pattern. Next, you'll add a REST API to this project, including testing and documentation. Later, you'll explore the various ways of deploying an app in production, including authentication functionality. Finally, you'll work on an interactive data dashboard, making various chart types and filters.
By the end of this book, you'll be able to build interactive web solutions on a large scale with a Julia-based web framework.

Balbaert / Salceanu Web Development with Julia and Genie jetzt bestellen!

Weitere Infos & Material


Table of Contents - Julia Programming Overview
- Using Julia Standard Web Packages
- Applying Julia in Various Use Cases on the Web
- Building an MVC ToDo App
- Adding a REST API
- Deploying Genie Apps in Production
- Adding Authentication to Our App
- Developing Interactive Data Dashboards with Genie


1


Julia Programming Overview


Julia is a high-performance, open source computing language, mostly applied to data analysis, machine learning, and other scientific and technical computing applications.

The language combines the ease of use of Python or R with the speed of C and eliminates the need for using two languages to develop data intensive applications. It is as readable and high-level as Python and because of its type inference and optional typing, behaves as a dynamic language. It is also as fast as C, but much more readable. As a new programming language, Julia borrowed some of the best features from other modern languages. For example, like Ruby, it doesn’t use semicolons or curly braces for delimiting code; instead, it uses a more Pascal-like syntax, with end to indicate where a code structure stops.

Julia is not a classic object-oriented language like ; instead, it is more , but it also has a struct data type like C. Functions that act on and transform data are the basic building blocks. The language also has built-in parallel computing capabilities and can scale up very easily.

Julia also provides an extensive standard library from the start. The language’s usage and popularity are steadily rising; it has been downloaded by users from more than 10,000 companies and is used at over 1,500 universities worldwide (https://juliacomputing.com/media/2022/02/julia-turns-ten-years-old/).

This chapter will touch on the main Julia concepts we will need in web development including types, flow control, functions, packages, and modules. We will introduce some examples relating to the ToDo app project theme for of this book.

We’ll also show code snippets from the Genie framework that are used in . We wrap up with a section on how Julia works internally, which makes us better understand Julia’s efficacy in web development. By the end of this chapter, your Julia knowledge will be refreshed, and you’ll be much better prepared to grasp the rest of the book.

In this chapter, we will cover the following topics:

  • Working with Julia
  • Types, flow controls, and functions in Julia
  • Useful techniques in Julia web development
  • Using Julia modules and packages
  • How Julia works
  • Why Julia is a good fit for web development

Technical requirements


To follow through with all the exercises in this chapter and the rest of the book, you will need the following:

All the code examples in this book have been run on a Windows machine. You may find subtle differences in output if you are using Linux/macOS. Where necessary, command variations for both machines have been specified.

The complete source code for this chapter can be found at https://github.com/PacktPublishing/Web-Development-with-Julia-and-Genie/tree/main/Chapter1.

Working with Julia


In this section, we will set up a standard Julia development environment, and learn how to work with Julia scripts as well as the Read–Eval–Print Loop (REPL). The REPL allows you to work with Julia in an interactive way, trying out expressions, function calls, and even executing whole programs.

You’re good to go when typing in julia at the terminal starts up the REPL:

Figure 1.1 – The Julia REPL

Using the REPL to use Julia interactively


Try typing in 256^2, giving the result 65536, or rand(), which gives you a random number between 0 and 1, for example, 0.02925477322848513. We’ll use the REPL extensively throughout the book, and the Genie web framework discussed in allows you to build your entire web app from the REPL.

Some useful REPL keyboard shortcuts you will use often include the following:

  • + : To exit the REPL
  • + : To clear the screen
  • + : To get a new prompt
  • Up and down arrows: To reuse recent commands

To see which folder you are in, type pwd(). To change the current folder, execute cd("path/to/folder").

A feature we’ll use a lot in Genie is creating new files from within the REPL with the touch command. For example, to create an empty testset.jl file in an existing folder structure, testing/phase1, enter the following:

julia> touch(joinpath("testing", "phase1", "testset.jl"))

The REPL returns testing\\phase1\\testset.jl on Windows and testing/phase1/testset.jl on systems.

The joinpath function constructs the directory path starting in the current folder, and touch creates the file.

Using the package mode to jump-start a project


The Julia ecosystem encompasses thousands of libraries, called packages (see https://julialang.org/packages/), for which Julia has a built-in package manager, .

The REPL has a special mode for working with packages, which is started by typing ] at julia> prompt, which brings you to package mode: (@v1.8) pkg>.

Some useful commands in this mode to type in after the pkg> prompt are as follows:

  • st or status: Gets a list of all the packages installed in your environment.
  • add PackageName: Adds a new package (you can add several packages separated by , if needed).
  • up or update: Updates all your packages.
  • up or update PackageName: Updates a specific package.
  • activate .: Activates the current project environment (see the section under ). rm or remove PackageName: Removes a specific package.
  • ?: Lists all available commands.
  • The key: Exits the pkg> mode.

In the next section, , we will work with a comma-separated values (CSV) file of to-do items. The CSV package can be imported and set up to be used in your Julia REPL by typing the following:

julia> using Pkg julia> Pkg.add("CSV") julia> using CSV

The last line of the preceding command brings the definitions of the CSV package into scope.

Alternatively, from the package mode, use the following:

]: (@v1.8) pkg> add CSV

The preceding command installs all packages CSV depends on and then precompiles them. This way, the project gets a jump-start, because the just-in-time (JIT) compiler doesn’t have to do this work anymore.

Using Julia with the VS Code plugin


Julia code can also be saved and edited in files with a .jl extension. Numerous IDEs exist to do that. In this book, we’ll use the VS Code platform with the excellent Julia plugin, which provides syntax highlighting and completion, lookup definitions, and plotting among many other features.

A handy way to start VS Code from the terminal prompt is by typing in code.

Search in the Extensions tab for Julia and install it. Then, open up a new file, and type in println("Hi Web World from Julia!"), and save it as hiweb.jl.

Run the program in VS Code with to see the string printed out. Or start the REPL and type the following to get the same...


Balbaert Ivo :

Ivo Balbaert is a lecturer in web programming and databases at CVO Antwerpen, a community college in Belgium. He received a PhD in applied physics from the University of Antwerp in 1986. He worked for 20 years in the software industry as a developer and consultant in several companies, and for 10 years as project manager at the University Hospital of Antwerp. From 2000 onwards, he switched to partly teaching and partly developing software (at KHM Mechelen, CVO Antwerpen). He also wrote an introductory book in Dutch about developing in Ruby and Rails, Programmeren met Ruby en Rails, published by Van Duuren Media. In 2012, he authored a book on the Go programming language, The Way to Go, published by iUniverse. He has written a number of introductory books for new programming languages, notably Dart, Julia, Rust, and Red, all published by Packt.Salceanu Adrian :

Adrian Salceanu is the creator and lead maintainer of Genie Framework. He has over two decades of professional work experience as a web developer and software architect, leading agile teams in developing, scaling, and maintaining business critical, data-intensive web applications. Currently, he is the technical founder and CEO of Genie Cloud, a no-code app development platform built with Genie. Adrian is the author of Julia Programming Projects (published by Packt in 2018) and an enthusiastic JuliaLang open-source contributor. He has two master's degrees, one in Computing, and another in Advanced Computer Science.



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.