29,99 €
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.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 260
Veröffentlichungsjahr: 2022
A hands-on guide to high-performance server-side web development with the Julia programming language
Ivo Balbaert
Adrian Salceanu
BIRMINGHAM—MUMBAI
Copyright © 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Pavan Ramchandani
Publishing Product Manager: Himani Dewan
Senior Editor: Divya Anne Selvaraj
Technical Editor: Saurabh Kadave
Copy Editor: Safis Editing
Project Coordinator: Manthan Patel
Proofreader: Safis Editing
Indexer: Subalakshmi Govindhan
Production Designer: Joshua Misquitta
Marketing Coordinator: Anamika Singh
First published: November 2022
Production reference: 1231122
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80181-113-2
www.packt.com
Julia has long been viewed as a tool that was merely for niche scientific computing, and if you wanted to do something beyond crunching numbers, you were out of luck. Ivo Balbaert’s and Adrian Salceanu’s work had to dispel this myth in Web Development with Julia and Genie. I have had the chance to interact with Adrian over the last few years in my role supporting the Julia community, and it has blown me away to see his conviction that Julia developers (and more broadly those in the computing ecosystem) should have access to world-class web development tools in the same language as their computational tools.
Adrian’s deep conviction has given birth to the Genie Framework, a production-ready ecosystem to build web apps natively in Julia. But Adrian’s belief in this space goes beyond his open source contributions. He has also made a big bet with Genie Cloud, the company he co-founded, which is trying to bring this unique mix of computational tools and web expertise to developers through a low code interface.
There are no people better suited to teach the information in this book than this book’s authors. By learning directly from the creator of the framework, you will be able to learn the philosophy of the ecosystem which extends well beyond simple usage examples that you would find in traditional documentation. Adrian also has extensive experience in the Julia ecosystem, which he garnered over many years of maintaining and contributing to various packages and Julia projects.
I am absolutely thrilled to see the Genie Framework’s usage growing and continuing to challenge the narrative that Julia is only for scientific computing. I expect that readers of this book will come away with a tremendous amount of respect for just how impressive the Genie Framework is, and all the hard work it took from Adrian and other contributors. I am so glad to have Adrian and Ivo as part of the Julia community and look forward to seeing the impact of this book and the Genie Framework in the years to come.
Logan Kilpatrick
Julia Project, Lead Developer Community Advocate
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.
I want to thank the reviewers for helping to increase the value and accuracy of the book, and a special thanks to our senior editor, Divya Anne Selvaraj, for her relentless devotion to improving the text.
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.
Abhimanyu Aryan is a Julia developer at Genie Framework OSS. Previously, he worked as an ML engineer for an aerospace company for defense services and taught full-stack JavaScript at India’s leading boot camp. He started his career as a Unity developer, working on various augmented reality and virtual reality use cases for Fortune 500 companies.
He also contributed a chapter on Android in Economics of Information Technology: Emerging Trends and Prospects, by Dr. Sunil Phougat and Dr. Pushp Deep Dagar, Savera Publishing House, 2015.
Mattia Nicolò Careddu is a software and data engineer from Milan, Italy, and a Genie contributor. Currently, he is the lead AI engineer and software engineer at nCore, an HR scaleup based in Milan, while also pursuing a bachelor’s degree in statistics and big data. He also founded PlayLife Events, a tech start-up in the event world, based in Italy. He is passionate about technology, AI, and start-ups.
This book provides an overview of web development in Julia and teaches you how to build MVC applications with a REST API and an interactive data dashboard using the Genie web framework.
The intended audience has web development experience, preferably some experience with Julia as well, and wants to blend these to become able to write web applications with Julia.
Chapter 1, Julia Programming Overview, reviews the Julia programming language in order to prepare you for web development with Julia. We’ll work with Julia in the REPL and with the Visual Studio Code editor, which is how we’ll build web apps in the rest of the book. Then, we will look at the types, flow controls, functions, and methods that you’ll need in any Julia app.
Chapter 2, Using Julia Standard Web Packages, delves into what Julia’s standard library and JuliaWeb have to offer for building web apps. First, we will look at working with the Sockets package and building two versions of a TCP echo server. Then, we will examine how to work with the WebSockets package, followed up with a thorough discussion of the HTTP package. Next, we'll build several web server examples and see how to route incoming requests. Finally, it will all come together when working with JSON data using a REST web server.
Chapter 3, Applying Julia in Various Use Cases on the Web, examines what the Julia community has built over the past 5 years in the way of tools to build web-based applications. To make a static website, Franklin is available to you as a valuable choice. If you need to build a cross-platform Electron-based GUI app, you can combine WebIO, Blink, and Interact to accomplish this. If your next project is to build a web dashboard, look no further than Dash for Julia. We will also discuss the architecture of microservices, the current state of WASM in the Julia ecosystem, and which cloud platforms are readily available for Julia. Finally, you will get an overview of all the mature web frameworks in Julia, giving you a better idea of which to apply when and gain a quick start to working with any of them.
Chapter 4, Building an MVC ToDo App, guides us through creating a complete application in the Genie Julia web framework, which you can take as a blueprint for starting your own project. You’ll learn how to generate a new MVC project and its model, how to create views to display the data, and how to route the browser requests through a controller function to its intended view. You’ll also see how you can add data validation functions and set up automatic testing for your app.
Chapter 5, Adding a REST API, enriches our to-do application with a REST API. You’ll learn how to code the CRUD functions for this API. The REST API exposes your data to the world – that’s why testing and documenting are especially important. You’ll learn how to write these specific tests, and how to document the API using Swagger.
Chapter 6, Deploying Genie Apps in Production, discusses the different possibilities for deploying Genie apps. First, we’ll see how to customize a production environment and then learn how to package our app in a Docker container, how to set up a repository on GitHub with the automatic execution of tests (as in, CI), and how to deploy our app in a Docker container using Git. We’ll also learn how to improve the app’s startup by using PackageCompiler.jl. Finally, we will explore an alternative method of deployment using Heroku.
Chapter 7, Adding Authentication to Our App, takes us through adding an authentication layer to our app, so that only registered users will be able to use it, and a user will only see their own to-do items. Also, we will expand our tests for this new functionality.
, Creating an Interactive Data Dashboard, explores using the Genie Builder tool to build a dashboard to-do application. We’ll learn how to generate mock data, create and visualize a time series, and make various types of charts and filters.
You will need a version of Julia installed on your computer – preferably Julia 1.8. You can install it from https://julialang.org/downloads/.
All code examples have been tested using Julia 1.8 on Windows OS and Linux. Visual Studio Code can be downloaded fromhttps://code.visualstudio.com/.
For Part 2 of this book (Chapters 4-8), make sure you use the most up-to-date version of the Genie web development framework (version 5, at the time of writing this book).
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Web-Development-with-Julia-and-Genie. If there’s an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/PymYa.
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “If the file has no header line, specify the header=falsekeyword argument.”
A block of code is set as follows:
if todo2.priority > todo1.priority println("Better do todo2 first") else println("Better do todo1 first") endWhen we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
<h4 class="container"> Sorry, no results were found for "$(params(:search_movies))" </h4>Any command-line input or output is written as follows:
user@DESKTOP$ nc localhost 8080 Hello Server, can you hear me? # client messageBold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “Search in the Extensions tab for Julia and install it.”
Tips or important notes
Appear like this.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Once you’ve read Web Development with Julia and Genie, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
Thanks for purchasing this book!
Do you like to read on the go but are unable to carry your print books everywhere?
Is your eBook purchase not compatible with the device of your choice?
Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.
Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.
The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily!
Follow these simple steps to get the benefits:
Scan the QR code or visit the link below:https://packt.link/free-ebook/9781801811132
Submit your proof of purchaseThat’s it! We’ll send your free PDF and other benefits to your email directlyBy the end of this part, you will understand the core components of the Julia programming language that serve as a basis for web development.
Need help with basic concepts of Julia? Or looking to learn more about its importance? The first three chapters are all about the basic principles of Julia, helping you to understand why Julia is a good fit for web development.
By the end of this part of the book, you will be able to use the foundational Julia packages such as Sockets, JSON, JSON3, HTTP, and WebSockets, and combine them in writing a REST services endpoint to-do app.
Moreover, you’ll explore building a static website with Franklin; creating a dashboard with Dash; how Julia can interact with JavaScript, microservices, and cloud services; and gain insights regarding choosing the right Julia framework for a project.
This part of the book comprises the following chapters:
Chapter 1, Julia Programming OverviewChapter 2, Using Julia Standard Web PackagesChapter 3, Applying Julia in Various Use Cases on the Web