Book description
Learn a new statically compiled programming language to build maintainable and fast software with the help of this comprehensive guide to V programming
Key Features
- Explore the features of the V programming language step by step with this beginner's guide
- Gain strong foundational knowledge of core programming concepts such as modules, functions, and structs
- Learn how to write super-fast programs and applications that compile in a matter of seconds
Book Description
A new language on the block, V comes with a promising set of features such as fast compilation and interoperability with other programming languages. This is the first book on the V programming language, packed with concise information and a walkthrough of all the features you need to know to get started with the language.
The book begins by covering the fundamentals to help you learn about the basic features of V and the suite of built-in libraries available within the V ecosystem. You'll become familiar with primitive data types, declaring variables, arrays, and maps. In addition to basic programming, you'll develop a solid understanding of the building blocks of programming, including functions, structs, and modules in the V programming language.
As you advance through the chapters, you'll learn how to implement concurrency in V Programming, and finally learn how to write test cases for functions. This book takes you through an end-to-end project that will guide you to build fast and maintainable RESTful microservices by leveraging the power of V and its built-in libraries.
By the end of this V programming book, you'll be well-versed with the V programming language and be able to start writing your own programs and applications.
What you will learn
- Become familiar with the basic building blocks of programming in the V language
- Install the V language on various operating systems
- Understand how to work with arrays and maps in V programming
- Discover how to implement concurrency in V programming
- Use channels in V programming to learn the best practices of sharing memory by communicating among coroutines
- Write modular code and build on your knowledge of structs and functions in V
- Get acquainted with writing tests in V programming
- Get to grips with building and querying RESTful microservice in V
Who this book is for
Whether you're a beginner interested in learning a programming language or an experienced programmer looking to switch to a new and better statically compiled programming language, this V programming book is for you.
Table of contents
- Getting Started with V Programming
- Contributors
- About the author
- About the reviewer
- Preface
- Section 1: Introduction to the V Programming Language
- Chapter 1: Introduction to V Programming
- Chapter 2: Installing V Programming
- Section 2: Basics of V Programming
- Chapter 3: Variables, Constants, and Code Comments
- Chapter 4: Primitive Data Types
-
Chapter 5: Arrays and Maps
- Technical references
- Arrays
-
Maps
- The explicit initialization of a map
- The short syntax initialization of a map
- The count of key-value pairs in a map
- Retrieving a value given the key of a map
- Accessing a non-existent key from a map
- Handling the retrieval of missing keys in a map
- Updating the value of the key in a map
- Deleting a key-value pair from a map
- Summary
- Chapter 6: Conditionals and Iterative Statements
-
Chapter 7: Functions
- Technical requirements
- Introducing functions
- Understanding function types
-
Understanding function features
- Functions can return values or simply perform operations
- Functions can take zero or more input arguments
- Functions can return multiple values
- Ignoring return values from functions
- Functions can call other accessible functions
- Functions allow only arrays, interfaces, maps, pointers, and structs as mutable arguments
- Function declarations in script mode should come before all script statements
- Functions do not allow access to module variables or global variables
- Functions do not allow default or optional arguments
- Functions can have optional return types
- Functions are private by default and can be exposed to other modules using the pub access modifier keyword
- Functions allow you to defer the execution flow using the defer block
- Functions can be represented as elements of an array or a map
- Summary
- Chapter 8: Structs
-
Chapter 9: Modules
- Technical requirements
- Introducing modules
-
Working with modules
- Creating a simple V project
- Creating a module
- Importing a module
- Accessing members of a module
- Working with multiple files in a module
- Member scope in the module
- Implications of cyclic imports
- The init function for a module
- Accessing the constants of a module
- Accessing structs and embedded structs of a module
- Summary
- Section 3: Advanced Concepts in V Programming
-
Chapter 10: Concurrency
- Technical requirements
- Introducing concurrency
- Understanding parallelism
- Learning the basic terminology
- Getting started with concurrency
- Implementing concurrency in V
- Spawning a void function to run concurrently
- Implementing a real-life concurrency scenario programmatically
- Learning different approaches to implement concurrent programs
- Sharing data between the main thread and concurrent tasks
- Summary
- Chapter 11: Channels – An Advanced Concurrency Pattern
- Chapter 12: Testing
- Chapter 13: Introduction to JSON and ORM
-
Chapter 14: Building a Microservice
- Technical requirements
- Introducing vweb
- Creating a project and organizing files
- Setting up the vweb web server
- Setting up utility functions and constants for the microservice
- Implementing RESTful endpoints
- Implementing an endpoint to create a note using HTTP verb POST
- Implementing an endpoint to retrieve a note by id using HTTP verb GET
- Implementing an endpoint to retrieve all notes using HTTP verb GET
-
Implementing an endpoint to update a note using HTTP verb PUT
- Defining a route to update a note by id
- Processing requests and handling custom responses for the update endpoint
- Verifying a record exits given its id using the ORM query
- Verifying the uniqueness of the message field of note
- Updating the record using the ORM query
- Building a response for the update endpoint
- Implementing an endpoint to delete a note using the HTTP verb DELETE
- Querying REST endpoints using Postman
- Summary
- Why subscribe?
- Other Books You May Enjoy
Product information
- Title: Getting Started with V Programming
- Author(s):
- Release date: December 2021
- Publisher(s): Packt Publishing
- ISBN: 9781839213434
You might also like
book
Clojure Polymorphism
Learn when and how to use Clojure's polymorphic features to develop efficient multithreaded applications Key Features …
book
Clojure Recipes
“There’s something for everyone here. . . . You can pick up and read this book …
article
Use Github Copilot for Prompt Engineering
Using GitHub Copilot can feel like magic. The tool automatically fills out entire blocks of code--but …
article
Run Llama-2 Models Locally with llama.cpp
Llama is Meta’s answer to the growing demand for LLMs. Unlike its well-known technological relative, ChatGPT, …